Skip to content

Commit 66973ef

Browse files
committed
(flavor) objection v3.0.0
1 parent 839e7af commit 66973ef

File tree

6 files changed

+62
-2
lines changed

6 files changed

+62
-2
lines changed

knexfile.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
const Path = require('path');
4+
const Hoek = require('@hapi/hoek');
5+
const Manifest = require('./server/manifest');
6+
const Plugin = require('./lib/plugins/@hapipal.schwifty');
7+
8+
// Take schwifty registration's knex option
9+
// but specify the plugin's migrations directory
10+
11+
module.exports = Hoek.applyToDefaults(
12+
{
13+
migrations: {
14+
directory: Path.relative(process.cwd(), Plugin.options.migrationsDir)
15+
}
16+
},
17+
Manifest
18+
.get('/register/plugins', process.env)
19+
.find(({ plugin }) => plugin === '@hapipal/schwifty')
20+
.options.knex
21+
);

lib/migrations/.gitkeep

Whitespace-only changes.

lib/models/.gitkeep

Whitespace-only changes.

lib/plugins/@hapipal.schwifty.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
module.exports = {
4+
options: {
5+
migrationsDir: `${__dirname}/../migrations`
6+
}
7+
};

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@
1010
"dependencies": {
1111
"@hapi/boom": "9.x.x",
1212
"@hapipal/haute-couture": "4.x.x",
13-
"joi": "17.x.x"
13+
"@hapipal/schwifty": "6.x.x",
14+
"joi": "17.x.x",
15+
"objection": "2.x.x"
16+
},
17+
"peerDependencies": {
18+
"knex": "0.21.x"
1419
},
1520
"devDependencies": {
1621
"@hapi/code": "8.x.x",
1722
"@hapi/eslint-config-hapi": "13.x.x",
1823
"@hapi/eslint-plugin-hapi": "4.x.x",
1924
"@hapi/glue": "8.x.x",
2025
"@hapi/hapi": "20.x.x",
26+
"@hapi/hoek": "9.x.x",
2127
"@hapi/lab": "24.x.x",
2228
"@hapipal/confidence": "6.x.x",
2329
"@hapipal/hpal": "3.x.x",
@@ -26,6 +32,8 @@
2632
"babel-eslint": "10.x.x",
2733
"dotenv": "8.x.x",
2834
"eslint": "7.x.x",
29-
"exiting": "6.x.x"
35+
"exiting": "6.x.x",
36+
"knex": "0.21.x",
37+
"sqlite3": "5.x.x"
3038
}
3139
}

server/manifest.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const Dotenv = require('dotenv');
44
const Confidence = require('@hapipal/confidence');
55
const Toys = require('@hapipal/toys');
6+
const Schwifty = require('@hapipal/schwifty');
67

78
// Pull .env into process.env
89
Dotenv.config({ path: `${__dirname}/.env` });
@@ -33,6 +34,29 @@ module.exports = new Confidence.Store({
3334
plugin: '../lib', // Main plugin
3435
options: {}
3536
},
37+
{
38+
plugin: '@hapipal/schwifty',
39+
options: {
40+
$filter: 'NODE_ENV',
41+
$default: {},
42+
$base: {
43+
migrateOnStart: true,
44+
knex: {
45+
client: 'sqlite3',
46+
useNullAsDefault: true, // Suggested for sqlite3
47+
connection: {
48+
filename: ':memory:'
49+
},
50+
migrations: {
51+
stub: Schwifty.migrationsStubPath
52+
}
53+
}
54+
},
55+
production: {
56+
migrateOnStart: false
57+
}
58+
}
59+
},
3660
{
3761
plugin: {
3862
$filter: 'NODE_ENV',

0 commit comments

Comments
 (0)