Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function main() {
require('@google-cloud/trace-agent').start({
logLevel: 4,
enabled: true,
projectId: credentials.ProjectId,
bufferSize: 1,
// flushDelaySeconds: 0,
credentials: JSON.parse(Buffer.from(credentials.PrivateKeyData, 'base64').toString("ascii"))
})
runServer(`${JSON.parse(Buffer.from(credentials.PrivateKeyData, 'base64').toString("ascii"))} `)
}
'use strict';
require('@google-cloud/trace-agent').start();
require('@google-cloud/debug-agent').start({
allowExpressions: true
});
const path = require('path');
const Hapi = require('hapi');
process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
});
// Set up the server
const server = new Hapi.Server({
host: '0.0.0.0',
port: process.env.PORT || 8080
});
let errorHandler = {
report(err) {
// eslint-disable-next-line no-console
console.error(err);
},
express(req, res, next) {
next();
}
};
if (process.env.NODE_ENV === "production") {
require("@google-cloud/trace-agent").start();
require("@google-cloud/debug-agent").start();
errorHandler = require("@google-cloud/error-reporting")();
}
module.exports = {
pubsub() {
return require("@google-cloud/pubsub")();
},
datastore() {
return require("@google-cloud/datastore")();
},
errors: errorHandler
};
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
'use strict';
// Activate Google Cloud Trace and Debug when in production
if (process.env.NODE_ENV === 'production') {
require('@google-cloud/trace-agent').start();
require('@google-cloud/debug-agent').start();
}
const path = require('path');
const express = require('express');
const session = require('express-session');
const passport = require('passport');
const config = require('./config');
const logging = require('./lib/logging');
const {Datastore} = require('@google-cloud/datastore');
const DatastoreStore = require('@google-cloud/connect-datastore')(session);
const app = express();
app.disable('etag');
app.set('views', path.join(__dirname, 'views'));
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/* eslint no-console: "off" */
const traceApi = require('@google-cloud/trace-agent').start({
serviceContext: {
service: 'image-diff'
}
});
const Storage = require('@google-cloud/storage');
const debug = require('@google-cloud/debug-agent').start();
require('@google-cloud/profiler').start();
const diff = require('./diff');
const storage = new Storage();
/**
* Generic background Cloud Function to be triggered by Cloud Storage.
*
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
'use strict';
// Activate Google Cloud Trace and Debug when in production
if (process.env.NODE_ENV === 'production') {
require('@google-cloud/trace-agent').start();
require('@google-cloud/debug-agent').start();
}
const request = require('request');
const waterfall = require('async').waterfall;
const express = require('express');
const bodyParser = require('body-parser');
const config = require('./config');
const logging = require('./lib/logging');
const images = require('./lib/images');
const model = require('./books/model-datastore');
// When running on Google App Engine Managed VMs, the worker needs
// to respond to HTTP requests and can optionally supply a health check.
// [START server]
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
'use strict';
const config = require('./config');
// TODO: Load the trace-agent and start it
// Trace must be started before any other code in the
// application.
require('@google-cloud/trace-agent').start({
projectId: config.get('GCLOUD_PROJECT')
});
// END TODO
require('@google-cloud/debug-agent').start({
allowExpressions: true,
projectId: config.get('GCLOUD_PROJECT')
});
const path = require('path');
const express = require('express');
const scores = require('./gcp/spanner');
const {ErrorReporting} = require('@google-cloud/error-reporting');
const errorReporting = new ErrorReporting({
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
'use strict';
// Activate Google Cloud Trace and Debug when in production
if (process.env.NODE_ENV === 'production') {
require('@google-cloud/trace-agent').start();
require('@google-cloud/debug-agent');
}
const request = require('request');
const waterfall = require('async').waterfall;
const express = require('express');
const config = require('./config');
const logging = require('./lib/logging');
const images = require('./lib/images');
const background = require('./lib/background');
const model = require(`./books/model-${config.get('DATA_BACKEND')}`);
// When running on Google App Engine Managed VMs, the worker needs
// to respond to HTTP requests and can optionally supply a health check.
function runServer(content) {
const tracer = require('@google-cloud/trace-agent').get();
const server = require('restify').createServer();
server.get('/', (_, res, next) => {
const customSpan = tracer.createChildSpan({ name: 'gen-content' });
res.send(`${JSON.stringify(tracer.getConfig())} ${tracer.getWriterProjectId()} ${content}`)
customSpan.endSpan();
next()
});
server.listen(process.env.PORT || 8080, function () {
console.log('%s listening at %s', server.name, server.url);
});
}
'use strict';
require('@google-cloud/trace-agent').start();
require('@google-cloud/debug-agent').start({
allowExpressions: true
});
const loader = require('@grpc/proto-loader');
const grpc = require('grpc');
const analyzer = require('./analyzer');
const logger = require('./logger');
const packageDef = loader.loadSync('cloudcats.proto');
const proto = grpc.loadPackageDefinition(packageDef).cloudcats;
const server = new grpc.Server();
server.addService(proto.Worker.service, {
analyze: call => {
analyzer.analyze(call)