Skip to content

Commit

Permalink
(flavor) objection v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
devinivy committed Apr 12, 2021
1 parent 839e7af commit 66973ef
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 2 deletions.
21 changes: 21 additions & 0 deletions knexfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

const Path = require('path');
const Hoek = require('@hapi/hoek');
const Manifest = require('./server/manifest');
const Plugin = require('./lib/plugins/@hapipal.schwifty');

// Take schwifty registration's knex option
// but specify the plugin's migrations directory

module.exports = Hoek.applyToDefaults(
{
migrations: {
directory: Path.relative(process.cwd(), Plugin.options.migrationsDir)
}
},
Manifest
.get('/register/plugins', process.env)
.find(({ plugin }) => plugin === '@hapipal/schwifty')
.options.knex
);
Empty file added lib/migrations/.gitkeep
Empty file.
Empty file added lib/models/.gitkeep
Empty file.
7 changes: 7 additions & 0 deletions lib/plugins/@hapipal.schwifty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

module.exports = {
options: {
migrationsDir: `${__dirname}/../migrations`
}
};
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@
"dependencies": {
"@hapi/boom": "9.x.x",
"@hapipal/haute-couture": "4.x.x",
"joi": "17.x.x"
"@hapipal/schwifty": "6.x.x",
"joi": "17.x.x",
"objection": "2.x.x"
},
"peerDependencies": {
"knex": "0.21.x"
},
"devDependencies": {
"@hapi/code": "8.x.x",
"@hapi/eslint-config-hapi": "13.x.x",
"@hapi/eslint-plugin-hapi": "4.x.x",
"@hapi/glue": "8.x.x",
"@hapi/hapi": "20.x.x",
"@hapi/hoek": "9.x.x",
"@hapi/lab": "24.x.x",
"@hapipal/confidence": "6.x.x",
"@hapipal/hpal": "3.x.x",
Expand All @@ -26,6 +32,8 @@
"babel-eslint": "10.x.x",
"dotenv": "8.x.x",
"eslint": "7.x.x",
"exiting": "6.x.x"
"exiting": "6.x.x",
"knex": "0.21.x",
"sqlite3": "5.x.x"
}
}
24 changes: 24 additions & 0 deletions server/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const Dotenv = require('dotenv');
const Confidence = require('@hapipal/confidence');
const Toys = require('@hapipal/toys');
const Schwifty = require('@hapipal/schwifty');

// Pull .env into process.env
Dotenv.config({ path: `${__dirname}/.env` });
Expand Down Expand Up @@ -33,6 +34,29 @@ module.exports = new Confidence.Store({
plugin: '../lib', // Main plugin
options: {}
},
{
plugin: '@hapipal/schwifty',
options: {
$filter: 'NODE_ENV',
$default: {},
$base: {
migrateOnStart: true,
knex: {
client: 'sqlite3',
useNullAsDefault: true, // Suggested for sqlite3
connection: {
filename: ':memory:'
},
migrations: {
stub: Schwifty.migrationsStubPath
}
}
},
production: {
migrateOnStart: false
}
}
},
{
plugin: {
$filter: 'NODE_ENV',
Expand Down

0 comments on commit 66973ef

Please sign in to comment.