connect to db with knex
This commit is contained in:
parent
bbdc63f61c
commit
c14a76e996
6 changed files with 1329 additions and 1 deletions
8
packages/play-node-go/server/data/db.js
Normal file
8
packages/play-node-go/server/data/db.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
const knex = require('knex');
|
||||
const knexfile = require('../knexfile');
|
||||
|
||||
|
||||
const env = process.env.NODE_ENV || 'development';
|
||||
const configOptions = knexfile[env];
|
||||
|
||||
module.exports = knex(configOptions);
|
37
packages/play-node-go/server/knexfile.js
Normal file
37
packages/play-node-go/server/knexfile.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Update with your config settings.
|
||||
require('dotenv').config()
|
||||
|
||||
module.exports = {
|
||||
|
||||
development: {
|
||||
client: 'postgresql',
|
||||
connection: process.env.PG_CONNECTION_STRING
|
||||
},
|
||||
|
||||
staging: {
|
||||
client: 'postgresql',
|
||||
connection: process.env.PG_CONNECTION_STRING,
|
||||
migrations: {
|
||||
directory: './data/migrations',
|
||||
},
|
||||
seeds: { directory: './data/seeds' },
|
||||
pool: {
|
||||
min: 2,
|
||||
max: 10
|
||||
}
|
||||
},
|
||||
|
||||
production: {
|
||||
client: 'postgresql',
|
||||
connection: process.env.PG_CONNECTION_STRING,
|
||||
migrations: {
|
||||
directory: './data/migrations',
|
||||
},
|
||||
seeds: { directory: './data/seeds' },
|
||||
pool: {
|
||||
min: 2,
|
||||
max: 10
|
||||
}
|
||||
}
|
||||
|
||||
};
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
exports.up = function(knex) {
|
||||
|
||||
};
|
||||
|
||||
exports.down = function(knex) {
|
||||
|
||||
};
|
1269
packages/play-node-go/server/package-lock.json
generated
1269
packages/play-node-go/server/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,10 @@
|
|||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "node ./bin/www"
|
||||
"start": "node ./bin/www",
|
||||
"make-migration": "./node_modules/.bin/knex migrate:make",
|
||||
"migrate": "./node_modules/.bin/knex migrate:latest",
|
||||
"seed": "./node_modules/.bin/knex seed:run"
|
||||
},
|
||||
"dependencies": {
|
||||
"chai": "^4.2.0",
|
||||
|
@ -14,6 +17,7 @@
|
|||
"dotenv": "^8.2.0",
|
||||
"express": "~4.16.1",
|
||||
"http-errors": "~1.6.3",
|
||||
"knex": "^0.20.7",
|
||||
"morgan": "~1.9.1",
|
||||
"pg": "^7.17.0",
|
||||
"socket.io": "^2.3.0"
|
||||
|
|
|
@ -6,6 +6,8 @@ const path = require('path');
|
|||
const cookieParser = require('cookie-parser');
|
||||
const logger = require('morgan');
|
||||
|
||||
const db = require('./data/db');
|
||||
|
||||
const dotenv = require('dotenv');
|
||||
dotenv.config();
|
||||
|
||||
|
|
Loading…
Reference in a new issue