File tree Expand file tree Collapse file tree 2 files changed +21
-12
lines changed
Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -72,15 +72,17 @@ server.applyMiddleware({ app, path: '/graphql' });
7272const httpServer = http . createServer ( app ) ;
7373server . installSubscriptionHandlers ( httpServer ) ;
7474
75- const eraseDatabaseOnSync = process . env . TEST_DATABASE ? true : false ;
75+ const isTest = ! ! process . env . TEST_DATABASE ;
76+ const isProduction = ! ! process . env . DATABASE_URL ;
77+ const port = process . env . PORT || 8000 ;
7678
77- sequelize . sync ( { force : eraseDatabaseOnSync } ) . then ( async ( ) => {
78- if ( eraseDatabaseOnSync ) {
79+ sequelize . sync ( { force : isTest || isProduction } ) . then ( async ( ) => {
80+ if ( isTest || isProduction ) {
7981 createUsersWithMessages ( new Date ( ) ) ;
8082 }
8183
82- httpServer . listen ( { port : 8000 } , ( ) => {
83- console . log ( ' Apollo Server on http://localhost:8000 /graphql' ) ;
84+ httpServer . listen ( { port } , ( ) => {
85+ console . log ( ` Apollo Server on http://localhost:${ port } /graphql` ) ;
8486 } ) ;
8587} ) ;
8688
Original file line number Diff line number Diff line change 11import Sequelize from 'sequelize' ;
22
3- const sequelize = new Sequelize (
4- process . env . TEST_DATABASE || process . env . DATABASE ,
5- process . env . DATABASE_USER ,
6- process . env . DATABASE_PASSWORD ,
7- {
3+ let sequelize ;
4+ if ( process . env . DATABASE_URL ) {
5+ sequelize = new Sequelize ( process . env . DATABASE_URL , {
86 dialect : 'postgres' ,
9- } ,
10- ) ;
7+ } ) ;
8+ } else {
9+ sequelize = new Sequelize (
10+ process . env . TEST_DATABASE || process . env . DATABASE ,
11+ process . env . DATABASE_USER ,
12+ process . env . DATABASE_PASSWORD ,
13+ {
14+ dialect : 'postgres' ,
15+ } ,
16+ ) ;
17+ }
1118
1219const models = {
1320 User : sequelize . import ( './user' ) ,
You can’t perform that action at this time.
0 commit comments