Skip to content
This repository was archived by the owner on Jan 20, 2020. It is now read-only.

Commit 4e701f1

Browse files
author
Luciano Nooijen
committed
Added Knex config
1 parent 2b6b380 commit 4e701f1

File tree

6 files changed

+302
-13
lines changed

6 files changed

+302
-13
lines changed

.env.example

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Node settings
2+
NODE_ENV=development
3+
PORT=5000
4+
5+
# Sqreen
6+
ENABLE_SQREEN=false
7+
SQREEN_TOKEN=token
8+
9+
# Database
10+
DB_CLIENT=postgres
11+
DB_HOST=localhost
12+
DB_USER=root
13+
DB_NAME=blog
14+
DB_PASS=root

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@ POST routes are protected
1818

1919
# Todo
2020

21-
* Support .env
2221
* Add TDD configuration
2322
* Create Restify/Express server
24-
* Configure Knex and migrations
2523
* See if https://github.com/Vincit/knex-db-manager might be a viable option
2624
* Integrate Helmet or similar
2725
* Add authentication
26+
* Create DB structure in Knex
27+
* Configure routing
2828
* Create documentation, API documentation using Swagger
2929
* Add performance testing script
3030
* Later on, maybe add CLI for creating admin users
3131
* Later on, add support for caching results
32+
33+
## Notes
34+
35+
* Node ENVs: DEVELOPMENT, PRODUCTION, TEST

knexfile-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
client: 'sqlite3',
3+
connection: {
4+
filename: './test.sqlite3',
5+
},
6+
};

knexfile.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Update with your config settings.
2+
3+
// eslint-disable-next-line
4+
const {
5+
DB_CLIENT,
6+
DB_HOST,
7+
DB_USER,
8+
DB_NAME,
9+
DB_PASS,
10+
} = process.env;
11+
12+
module.export = {
13+
client: DB_CLIENT,
14+
connection: {
15+
host: DB_HOST,
16+
database: DB_NAME,
17+
user: DB_USER,
18+
password: DB_PASS,
19+
},
20+
pool: {
21+
min: 2,
22+
max: 10,
23+
},
24+
migrations: {
25+
tableName: 'knex_migrations',
26+
},
27+
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
"test:api": "NODE_ENV=test jest",
1717
"test:performance": "NODE_ENV=test exit 0",
1818
"coverage": "NODE_ENV=test jest --coverage",
19-
"migrate": "exit 0",
19+
"migrate": "knex migrate:latest",
2020
"reinstall": "rm -rf node_modules && yarn"
2121
},
2222
"dependencies": {
2323
"dotenv": "^6.1.0",
24+
"knex": "^0.15.2",
2425
"sqreen": "^1.26.2",
2526
"yarn": "^1.12.1"
2627
},

0 commit comments

Comments
 (0)