Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {escapeProps, generateProps} from '../helpers/props';
import Layout from '../../client/containers/layout';
import Log from 'log';
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import RegisterAuthPage from '../../client/components/pages/registration-auth';
import RegisterDetailPage from
'../../client/components/forms/registration-details';
import _ from 'lodash';
import config from '../../common/helpers/config';
import express from 'express';
import target from '../templates/target';
const router = express.Router();
const log = new Log(config.site.log);
router.get('/', (req, res) => {
// Check whether the user is logged in - if so, redirect to profile page
if (req.user) {
return res.redirect(`/editor/${req.user.id}`);
}
const props = generateProps(req, res);
const markup = ReactDOMServer.renderToString(
);
return res.send(target({markup, title: 'Register'}));
import EditionPage from '../../../client/components/pages/entities/edition';
import EntityRevisions from '../../../client/components/pages/entity-revisions';
import Layout from '../../../client/containers/layout';
import Log from 'log';
import Promise from 'bluebird';
import PublisherPage from '../../../client/components/pages/entities/publisher';
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import WorkPage from '../../../client/components/pages/entities/work';
import _ from 'lodash';
import config from '../../../common/helpers/config';
import target from '../../templates/target';
type PassportRequest = $Request & {user: any, session: any};
const log = new Log(config.site.log);
const entityComponents = {
author: AuthorPage,
edition: EditionPage,
editionGroup: EditionGroupPage,
publisher: PublisherPage,
work: WorkPage
};
export function displayEntity(req: PassportRequest, res: $Response) {
const {orm}: {orm: any} = req.app.locals;
const {AchievementUnlock, EditorEntityVisits} = orm;
const {locals: resLocals}: {locals: any} = res;
const {entity}: {entity: any} = resLocals;
// Get unique identifier types for display
// $FlowFixMe
var Extractor = function (data, option) {
this.data = data
// Grab NODE_ENV to set debug flag!
var debug = process.env.NODE_ENV === 'debug'
_log = new Log(option.log || (debug ? 'debug' : 'info'))
_basePath = option ? (option.basePath || __dirname) : __dirname
_utils = new Utils({
basePath: _basePath
})
// Check lang parameter
if (!_.isArray(this.data.lang) || !this.data.lang.length) {
throw new Error('lang parameter is required.')
}
// Declare all var from configuration
var files = _utils.expand(this.data.src),
dest = _utils.getRealPath(this.data.dest || '.'),
jsonSrc = _utils.expand(this.data.jsonSrc || []),
jsonSrcName = _.union(this.data.jsonSrcName || [], ['label']),
interpolation = this.data.interpolation || {startDelimiter: '{{', endDelimiter: '}}'},
function init(app, config) {
const log = new Log(config.site.log);
const influxConfig = config.influx;
const influx = new Influx.InfluxDB({
database: influxConfig.database || 'bookbrainz',
host: influxConfig.host || 'localhost',
password: 'grafana',
schema: [
{
fields: {
duration: Influx.FieldType.INTEGER
},
measurement: 'response_times',
tags: [
'domain',
'path',
export function start(dirname, userPort = 8080) {
log = new Log('info');
expressServer = new ExpressServer().listen(dirname);
var options = {
debug: true,
allow_discovery: true
};
expressServer.app.use('/multi', ExpressPeerServer(expressServer.server, options));
expressServer.server.on('connection', onConnection);
expressServer.server.on('disconnect', onDisconnect);
}
this.adapterPath = Path.join(__dirname, 'adapters');
}
this.name = name;
this.events = new EventEmitter;
this.brain = new Brain(this);
this.alias = alias;
this.adapter = null;
this.Response = Response;
this.commands = [];
this.listeners = [];
this.middleware = {
listener: new Middleware(this),
response: new Middleware(this),
receive: new Middleware(this)
};
this.logger = new Log(process.env.WEBBY_LOG_LEVEL || 'info');
this.pingIntervalId = null;
this.globalHttpOptions = {};
this.parseVersion();
if (httpd) {
this.router = new ExpressRouter(this).router;
} else {
this.router = new NullRouter(this).router;
}
this.adapterName = adapterName;
this.loadAdapter();
this.errorHandlers = [];
this.on('error', (err, res) => {
this.invokeErrorHandlers(err, res);
});
this.onUncaughtException = (err) => {
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
import * as MusicBrainzOAuth from 'passport-musicbrainz-oauth2';
import * as error from '../../common/helpers/error';
import Log from 'log';
import _ from 'lodash';
import config from '../../common/helpers/config';
import passport from 'passport';
import status from 'http-status';
const log = new Log(config.site.log);
const MusicBrainzOAuth2Strategy = MusicBrainzOAuth.Strategy;
async function _linkMBAccount(orm, bbUserJSON, mbUserJSON) {
const {Editor} = orm;
const fetchedEditor = await new Editor({id: bbUserJSON.id})
.fetch({require: true});
return fetchedEditor.save({
cachedMetabrainzName: mbUserJSON.sub,
metabrainzUserId: mbUserJSON.metabrainz_user_id
});
}
function _getAccountByMBUserId(orm, mbUserJSON) {
const {Editor} = orm;
constructor(io) {
this.log = new Log('info');
this._io = io;
this._players = {};
this._addEventListeners();
}
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
import * as propHelpers from '../../client/helpers/props';
import ErrorPage from '../../client/components/pages/error';
import Layout from '../../client/containers/layout';
import Log from 'log';
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import config from './config';
import {generateProps} from './props';
import status from 'http-status';
import target from '../templates/target';
const log = new Log(config.site.log);
export class SiteError extends Error {
constructor(message) {
super();
/*
* We can't access the subclass's default message before calling super,
* so we set it manually here
*/
this.message = message || this.constructor.defaultMessage;
this.name = this.constructor.name;
this.status = this.constructor.status;
}
static get defaultMessage() {