File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 11import Express from 'express' ;
2+ import mongoose from 'mongoose' ;
23import path from 'path' ;
34import webpack from 'webpack' ;
45import webpackDevMiddleware from 'webpack-dev-middleware' ;
@@ -10,6 +11,23 @@ import renderPreviewIndex from './views/previewIndex';
1011
1112const app = new Express ( ) ;
1213
14+ // This also works if you take out the mongoose connection
15+ // but i have no idea why
16+ const mongoConnectionString = process . env . MONGO_URL ;
17+ // Connect to MongoDB
18+ mongoose . Promise = global . Promise ;
19+ mongoose . connect ( mongoConnectionString , {
20+ useNewUrlParser : true ,
21+ useUnifiedTopology : true
22+ } ) ;
23+ mongoose . set ( 'useCreateIndex' , true ) ;
24+ mongoose . connection . on ( 'error' , ( ) => {
25+ console . error (
26+ 'MongoDB Connection Error. Please make sure that MongoDB is running.'
27+ ) ;
28+ process . exit ( 1 ) ;
29+ } ) ;
30+
1331// Run Webpack dev server in development mode
1432if ( process . env . NODE_ENV === 'development' ) {
1533 const compiler = webpack ( config ) ;
You can’t perform that action at this time.
0 commit comments