connect to db with knex
This commit is contained in:
parent
8a203cb096
commit
90e078fa86
6 changed files with 1329 additions and 1 deletions
8
packages/server/server/data/db.js
Normal file
8
packages/server/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/server/server/knexfile.js
Normal file
37
packages/server/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
|
||||
}
|
||||
}
|
||||
|
||||
};
|
8
packages/server/server/migrations/20200107214047_init.js
Normal file
8
packages/server/server/migrations/20200107214047_init.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
|
||||
exports.up = function(knex) {
|
||||
|
||||
};
|
||||
|
||||
exports.down = function(knex) {
|
||||
|
||||
};
|
1269
packages/server/server/package-lock.json
generated
1269
packages/server/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