Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var redis = require('redis').createClient(process.env.REDIS_PORT, process.env.REDIS_HOST);
redis.auth(process.env.REDIS_PASSWORD);
} else if (process.env.REDISCLOUD_URL) {
var redisUrl = require('url').parse(process.env.REDISCLOUD_URL);
var redis = require('redis').createClient(redisUrl.port, redisUrl.hostname);
redis.auth(redisUrl.auth.split(":")[1]);
} else {
var redis = require('redis').createClient();
}
redis.select(process.env.REDIS_DB || 1);
// Get Mongo configuration
var mongoUrl = process.env.MONGO_URL || process.env.MONGOHQ_URL ||
'mongodb://localhost:27017/project';
// The store creates models and syncs data
var store = derby.createStore({
db: liveDbMongo(mongoUrl + '?auto_reconnect', {safe: true})
, redis: redis
});
function createUserId(req, res, next) {
var model = req.getModel();
var userId = req.session.userId || (req.session.userId = model.id());
model.set('_session.userId', userId);
next();
}
expressApp
.use(express.favicon())
// Gzip dynamically
.use(express.compress())
// Respond to requests for application script bundles
Server.setupMongo = function()
{
var _this = this;
this.mongoUrl = defconf.database;
this.store = derby.createStore({
db:
{
db: liveDbMongo(_this.mongoUrl + '?auto_reconnect', {safe: true}),
redis: _this.redis
}
});
// the store creates models and syncs data
}
var express = require('express');
var derby = require('derby');
var racerBrowserChannel = require('racer-browserchannel');
var liveDbMongo = require('livedb-mongo');
var MongoStore = require('connect-mongo')(express);
var $$app$$ = require('../$$app$$');
var error = require('./error');
var expressApp = module.exports = express();
var mongoUrl = process.env.MONGO_URL || 'mongodb://localhost:27017/project';
var store = derby.createStore({
db: {
db: liveDbMongo(mongoUrl + '?auto_reconnect', {safe: true})
, redis: require('redis').createClient()
}
});
function createUserId(req, res, next) {
var model = req.getModel();
var userId = req.session.userId || (req.session.userId = model.id());
model.set('_session.userId', userId);
next();
}
expressApp
.use(express.favicon())
// Gzip dynamically
, gzippo = require('gzippo')
, derby = require('derby')
, auth = require('derby-auth')
, app = require('../app')
, serverError = require('./serverError')
// SERVER CONFIGURATION //
var expressApp = express()
, server = module.exports = http.createServer(expressApp)
derby.use(derby.logPlugin)
derby.use(require('racer-db-mongo')); // This line is new
var store = derby.createStore({
listen: server,
db: {type: 'Mongo', uri: process.env.MONGOHQ_URL || 'mongodb://localhost/snippets'}
})
//Authentication
auth.store(store);
var options, strategies;
strategies = {
facebook: {
strategy: require("passport-facebook").Strategy,
conf: {
clientID: process.env.FACEBOOK_KEY,
clientSecret: process.env.FACEBOOK_SECRET
}
}
var http = require('http')
, path = require('path')
, express = require('express')
, gzippo = require('gzippo')
, derby = require('derby')
, app = require('../auth')
, serverError = require('./serverError')
, MongoStore = require('connect-mongo')(express)
, dbUri = 'mongodb://localhost/derby-auth';
var expressApp = express(),
server = http.createServer(expressApp)
derby.use(require('racer-db-mongo'));
var store = derby.createStore({
db: { type: 'Mongo', uri: dbUri, safe: true },
listen: server
});
module.exports = server
var ONE_YEAR = 1000 * 60 * 60 * 24 * 365
, root = path.dirname(path.dirname(__dirname))
, publicPath = path.join(root, 'public')
/**
* (1)
* Setup a hash of strategies you'll use - strategy objects and their configurations
* Note, API keys should be stored as environment variables (eg, process.env.FACEBOOK_KEY, process.env.FACEBOOK_SECRET)
* rather than a configuration file. We're storing it in conf.js for demo purposes.
*/
var app = require('../src/app');
var path = require('path');
var racerBrowserChannel = require('racer-browserchannel');
var liveDbMongo = require('livedb-mongo');
var racerBundle = require('racer-bundle');
var error = require('./error');
var mongoUrl = process.env.MONGO_URL + process.env.MONGO_DB;
var connectStore = require('connect-mongo')(session);
var sessionStore = new connectStore({url: mongoUrl});
store = derby.createStore({db: liveDbMongo(mongoUrl + '?auto_reconnect', {safe: true})});
derby.use(racerBundle);
var publicDir = path.join(__dirname, '/../public');
var loginOptions = require('./../config/loginOptions');
hooks(store);
var expressApp = module.exports = express()
.use(favicon(path.join(publicDir, '/images/favicon.ico')))
.use(compression())
.use(serveStatic(publicDir))
.use(cookieParser(process.env.SESSION_COOKIE))
.use(session({
secret: process.env.SESSION_SECRET,
store: sessionStore
exports.setup = function setup(app, options, cb) {
var store = derby.createStore({
db: liveDbMongo(process.env.MONGO_URL + '?auto_reconnect', {safe: true}),
redis: redisClient
});
var publicDir = path.join(__dirname, '/../../public');
var expressApp = express()
.use(favicon(path.join(publicDir, '/images/favicon.ico')))
.use(compression())
.use(serveStatic(publicDir));
if (options && options.static) {
if (Array.isArray(options.static)) {
for (var i = 0; i < options.static.length; i++) {
var o = options.static[i];
expressApp.use(o.route, serveStatic(o.dir));