File tree Expand file tree Collapse file tree 5 files changed +103
-1
lines changed Expand file tree Collapse file tree 5 files changed +103
-1
lines changed Original file line number Diff line number Diff line change 1+ // Update with your config settings.
2+
3+ module . exports = {
4+
5+ development : {
6+ client : 'sqlite3' ,
7+ connection : {
8+ filename : './dev.sqlite3'
9+ }
10+ } ,
11+
12+ staging : {
13+ client : 'postgresql' ,
14+ connection : {
15+ database : 'my_db' ,
16+ user : 'username' ,
17+ password : 'password'
18+ } ,
19+ pool : {
20+ min : 2 ,
21+ max : 10
22+ } ,
23+ migrations : {
24+ tableName : 'knex_migrations'
25+ }
26+ } ,
27+
28+ production : {
29+ client : 'postgresql' ,
30+ connection : {
31+ database : 'my_db' ,
32+ user : 'username' ,
33+ password : 'password'
34+ } ,
35+ pool : {
36+ min : 2 ,
37+ max : 10
38+ } ,
39+ migrations : {
40+ tableName : 'knex_migrations'
41+ }
42+ }
43+
44+ } ;
Original file line number Diff line number Diff line change 1616 "bugs" : {
1717 "url" : " https://github.com/marcpre/learning_jquery_repeater-field/issues"
1818 },
19- "homepage" : " https://github.com/marcpre/learning_jquery_repeater-field#readme"
19+ "homepage" : " https://github.com/marcpre/learning_jquery_repeater-field#readme" ,
20+ "dependencies" : {
21+ "cookie-parser" : " ^1.4.3" ,
22+ "express" : " ^4.16.2" ,
23+ "knex" : " ^0.14.0" ,
24+ "morgan" : " ^1.9.0" ,
25+ "pg" : " ^7.4.0" ,
26+ "pug" : " ^2.0.0-rc.4"
27+ },
28+ "devDependencies" : {
29+ "nodemon" : " ^1.12.1"
30+ }
2031}
Original file line number Diff line number Diff line change 1+ require ( 'dotenv' ) . config ( )
2+ const express = require ( 'express' )
3+ const path = require ( 'path' )
4+ const logger = require ( 'morgan' )
5+ const bodyParser = require ( 'body-parser' )
6+ const cookieParser = require ( 'cookie-parser' )
7+ const session = require ( 'express-session' )
8+ const passport = require ( 'passport' )
9+
10+ const index = require ( './routes/index' )
11+
12+ const app = express ( )
13+
14+ // view engine setup
15+ app . set ( 'views' , path . join ( __dirname , 'views' ) )
16+ app . set ( 'view engine' , 'pug' )
17+ app . use ( logger ( process . env . LOG_ENV ) )
18+ app . use ( bodyParser . json ( ) )
19+ app . use ( bodyParser . urlencoded ( {
20+ extended : false ,
21+ } ) )
22+ app . use ( express . static ( path . join ( __dirname , '/../public' ) ) )
23+ app . use ( cookieParser ( ) )
24+
25+ // routes
26+ app . use ( '/' , index )
27+
28+ // Start Server
29+ const port = process . env . APP_PORT || 8080
30+ const host = process . env . APP_URL || '0.0.0.0'
31+
32+ app . listen ( port , host , ( ) => {
33+ console . log ( `Listening on ${ host } :${ port } /login` )
34+ } )
35+
36+ module . exports = app
Original file line number Diff line number Diff line change 1+ // Loading from an external file
2+ const config = require ( '../../knexfile' )
3+
4+ const env = process . env . DB_ENV
5+ const knex = require ( 'knex' ) ( config [ env ] )
6+
7+ knex . on ( 'query' , ( queryData ) => {
8+ console . log ( queryData )
9+ } )
10+
11+ module . exports = knex
You can’t perform that action at this time.
0 commit comments