Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var sprintf = util.format;
var os = require('os');
var createCache = require('lru-cache');
var restify = require('restify');
var bunyan = require('bunyan');
var clone = require('clone');
var auth = require('smartdc-auth');
// --- Globals
var log = bunyan.createLogger({
level: 'info',
name: 'smartdc',
stream: process.stderr,
serializers: restify.bunyan.serializers
});
var VERSION = require('../package.json').version;
var RESTIFY_VERSION = 'unknown';
try {
RESTIFY_VERSION = require('../node_modules/restify/package.json').version;
} catch (e) {}
var SIGNATURE = 'Signature keyId="/%s/keys/%s",algorithm="%s" %s';
var ROOT = '/%s';
var KEYS = ROOT + '/keys';
var KEY = KEYS + '/%s';
var PACKAGES = ROOT + '/packages';
var PACKAGE = PACKAGES + '/%s';
var DATASETS = ROOT + '/datasets';
var restify = require('restify');
var u = require('../api/urls');
var bunyan = require('bunyan');
var _ = require('lodash');
var debug = require('debug')('seguir:server');
var defaultLogger = bunyan.createLogger({
name: 'seguir',
serializers: restify.bunyan.serializers
});
function bootstrapServer (api, config, next) {
var server = restify.createServer({
name: 'seguir',
version: '0.1.0',
log: config.logger || defaultLogger
});
// Default middleware
server.use(restify.bodyParser({mapParams: true}));
server.use(restify.queryParser({mapParams: false}));
server.use(restify.gzipResponse());
server.use(restify.CORS());
server.use(function (req, res, cb) {
assert.optionalString(opts.scheme, 'opts.scheme');
// TODO: options to control the trust db for CA verification
// TODO add passing through other restify options
// Restify/Node HTTP client options.
// opt.agent (optional, bool or object)
assert.optionalString(opts.userAgent, 'opts.userAgent');
// opts.proxy (optional, bool or object or string);
this.log = opts.log
? opts.log.child({
component: 'registry',
serializers: restify.bunyan.serializers
})
: bunyan.createLogger({
name: 'registry',
serializers: restify.bunyan.serializers
});
this.insecure = Boolean(opts.insecure);
this.repo = common.parseRepo(opts.name);
if (opts.scheme) {
this.repo.index.scheme = opts.scheme;
} else if (common.isLocalhost(this.repo.index.name)) {
// Per docker.git:registry/config.go#NewServiceConfig we special
// case localhost to allow HTTP. Note that this lib doesn't do
// the "try HTTPS, then fallback to HTTP if allowed" thing that
// docker-docker does, we'll just prefer HTTP for localhost.
this.repo.index.scheme = 'http';
}
if (opts.username && opts.password) {
var buffer = new Buffer(opts.username + ':' + opts.password, 'utf8');
static create(options) {
// TODO: Consume external log
let mantaLog = mod_bunyan.createLogger({
name: 's3-manta-bridge',
level: (options.manta.logLevel || 'info'),
stream: process.stdout,
serializers: mod_restify.bunyan.serializers
});
if (!options.manta.user) {
throw new Error('Manta username must be set');
}
if (!options.manta.keyId) {
throw new Error('Manta key id must be set');
}
let mantaUrl = MantaClientFactory._findMantaUrl(options);
mantaLog.debug('Remote Manta host: %s', mantaUrl);
let rejectUnauthorized = MantaClientFactory._isRejectUnauthorizedEnabled(options);
let params = {
* Main entry-point for the Boilerplate API.
*/
var filed = require('filed');
var restify = require('restify');
var uuid = require('node-uuid');
var Logger = require('bunyan');
var log = new Logger({
name: 'boilerplateapi',
level: 'debug',
serializers: {
err: Logger.stdSerializers.err,
req: Logger.stdSerializers.req,
res: restify.bunyan.serializers.response
}
});
var server = restify.createServer({
name: 'Boilerplate API',
log: log
});
// TODO: Add usage of the restify auditLog plugin.
// '/eggs/...' endpoints.
var eggs = {}; // My lame in-memory database.
server.get({path: '/eggs', name: 'ListEggs'}, function (req, res, next) {
*/
/*
* Copyright (c) 2015, Joyent, Inc.
*/
/*
* bunyan logger for tests
*/
var bunyan = require('bunyan');
var restify = require('restify');
module.exports = bunyan.createLogger({
name: 'sdc-docker-test',
serializers: restify.bunyan.serializers,
streams: [
{
level: process.env.LOG_LEVEL || 'error',
stream: process.stderr
}
]
});
function getLog(name, stream, level) {
return (bunyan.createLogger({
level: (process.env.LOG_LEVEL || level || 'fatal'),
name: name || process.argv[1],
stream: stream || process.stdout,
src: true,
serializers: restify.bunyan.serializers
}));
}
function getLog(name, stream, level) {
return (bunyan.createLogger({
level: (process.env.LOG_LEVEL || level || 'fatal'),
name: name || process.argv[1],
stream: stream || process.stdout,
src: true,
serializers: restify.bunyan.serializers
}));
}
var bunyan = require('bunyan');
var getopt = require('posix-getopt');
var restify = require('restify');
var uuid = require('node-uuid');
var manta = require('manta');
///--- Globals
var LOG = bunyan.createLogger({
name: path.basename(process.argv[1]),
level: (process.env.LOG_LEVEL || 'info'),
stream: process.stderr,
serializers: restify.bunyan.serializers
});
///--- Functions
function ifError(err) {
if (err) {
console.error(err.toString());
process.exit(1);
}
}
function parseOptions() {
var option;
/**
* A worker will listen for jobs on the job queue, and execute them.
*/
var async = require('async');
var restify = require('restify');
var bunyan = require('bunyan');
var logger = bunyan.createLogger({
name: 'seguir',
serializers: restify.bunyan.serializers
});
function bootstrapWorker (api, config, next) {
var follower = function (cb) {
api.messaging.listen('seguir-publish-to-followers', function (data, next) {
logger.debug('Processing publish-to-followers message', data);
api.feed.insertFollowersTimeline(data, next);
}, cb);
};
var mentions = function (cb) {
api.messaging.listen('seguir-publish-mentioned', function (data, cb) {
logger.debug('Processing publish-mentioned message', data);
api.feed.insertMentionedTimeline(data, cb);
}, cb);