Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Setup code that should run before all tests.
// Give mongoose a promise implementation.
import Promise from 'bluebird';
import mongoose from 'mongoose';
mongoose.Promise = Promise;
// make mixpanel null
global.mixpanel = {
track() { return null; },
identify() { return null; },
};
/* eslint-disable no-console */
/**
* Configuration for the database
*/
import mongoose from 'mongoose';
import constants from './constants';
// Remove the warning with Promise
mongoose.Promise = global.Promise;
// If debug run the mongoose debug options
mongoose.set('debug', process.env.MONGOOSE_DEBUG);
// Connect the db with the url provide
try {
mongoose.connect(constants.MONGO_URL);
} catch (err) {
mongoose.createConnection(constants.MONGO_URL);
}
mongoose.connection
.once('open', () => console.log('MongoDB Running'))
.on('error', e => {
throw e;
});
import config from './../config/config'
import app from './express'
import mongoose from 'mongoose'
// Connection URL
mongoose.Promise = global.Promise
mongoose.connect(config.mongoUri)
mongoose.connection.on('error', () => {
throw new Error(`unable to connect to database: ${mongoUri}`)
})
app.listen(config.port, (err) => {
if (err) {
console.log(err)
}
console.info('Server started on port %s.', config.port)
})
/* eslint-disable import/newline-after-import, import/imports-first*/
require('dotenv').config({ silent: true });
import express from 'express';
import path from 'path';
import morgan from 'morgan';
import mongoose from 'mongoose';
import bodyParser from 'body-parser';
import webpack from 'webpack';
import hotMiddleware from 'webpack-hot-middleware';
import devMiddleware from 'webpack-dev-middleware';
import webpackConfig from '../webpack.config';
import api from './api';
mongoose.Promise = Promise;
const PORT = process.env.PORT || 3000;
const MONGO = process.env.MONGODB_URI || 'mongodb://localhost/reactBoilerplate';
const app = express();
const compiler = webpack(webpackConfig);
app.use(devMiddleware(compiler, {
publicPath: webpackConfig.output.publicPath,
noInfo: true,
quiet: false,
stats: {
assets: true,
colors: true,
version: true,
hash: true,
timings: false,
chunks: false,
chunkModules: false,
import compression from "compression";
import App from "./../client/App.js";
import { configureStore } from './../client/store.js';
import createRoutes from "./../client/routes.js";
import { ChunkExtractor } from '@loadable/server';
import mongoose from 'mongoose';
import axios from "axios";
import serverConfig from "./config.js";
import csrf from "csurf";
import serialize from 'serialize-javascript';
import morgan from 'morgan';
import logger from './middlewares/logger.js';
import authRoutes from './routes/auth.js';
import commonRoutes from './routes/common.js';
mongoose.Promise = global.Promise;
mongoose.connect(serverConfig.mongodb.url, serverConfig.mongodb.options, function (err) {
if (!err) {
logger.info("mongodb connected to " + serverConfig.mongodb.url);
require('./utils/initDB.js');
} else {
logger.error(err);
process.exit(1);
}
});
const app = express();
app.use(morgan('short', { "stream": logger.stream }));
app.use(compression());
import mongoose from 'mongoose'
var conn
if (!conn) {
process.on('unhandledRejection', function(reason, promise) {
console.log(promise);
});
const url = process.env.MONGO_URL || (typeof __TEST__ != 'undefined' && __TEST__ ? 'mongodb://localhost/daipay_test' : 'mongodb://localhost/daipay')
console.log(`connecting to ${url}`)
mongoose.connect(url, { useNewUrlParser: true })
mongoose.Promise = global.Promise
conn = mongoose
}
export default conn
import express from "express";
import path from "path";
import mongoose from "mongoose";
import bodyParser from "body-parser";
import dotenv from "dotenv";
import Promise from "bluebird";
import auth from "./routes/auth";
import users from "./routes/users";
import books from "./routes/books";
dotenv.config();
const app = express();
app.use(bodyParser.json());
mongoose.Promise = Promise;
mongoose.connect(process.env.MONGODB_URL, { useMongoClient: true });
app.use("/api/auth", auth);
app.use("/api/users", users);
app.use("/api/books", books);
app.get("/*", (req, res) => {
res.sendFile(path.join(__dirname, "index.html"));
});
app.listen(8080, () => console.log("Running on localhost:8080"));
import React from 'react';
import ReactDOM from 'react-dom';
import { createStore, applyMiddleware } from 'redux';
import { Provider } from 'react-redux';
import ReduxThunk from 'redux-thunk';
import { Db, Server } from 'mongodb';
import reducers from './reducers';
import Routes from './router';
import mongoose from 'mongoose';
import './seeds';
mongoose.Promise = Promise;
const App = () => {
const store = createStore(reducers, {}, applyMiddleware(ReduxThunk));
return (
);
};
const db = new Db('upstar_music', new Server('localhost', 27017));
db.open()
.then(() => {
window.db = db;
mongoose.connect('mongodb://localhost/upstar_music');
if (err) {
logger.error('connect to %s error: ', mongodbUrl, err.message);
}
}
if (process.env.NODE_ENV === 'production') {
mongoose.connect(mongodbUrl, {
useMongoClient: true
}, handleErr);
} else {
mongoose.connect(mongodbUrl, {
useMongoClient: true
}, handleErr);
}
mongoose.Promise = global.Promise;
export default mongoose;