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 1
1
import Express from 'express' ;
2
+ import mongoose from 'mongoose' ;
2
3
import path from 'path' ;
3
4
import webpack from 'webpack' ;
4
5
import webpackDevMiddleware from 'webpack-dev-middleware' ;
@@ -10,6 +11,23 @@ import renderPreviewIndex from './views/previewIndex';
10
11
11
12
const app = new Express ( ) ;
12
13
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
+
13
31
// Run Webpack dev server in development mode
14
32
if ( process . env . NODE_ENV === 'development' ) {
15
33
const compiler = webpack ( config ) ;
You can’t perform that action at this time.
0 commit comments