master
Devin Ivy 2021-04-11 23:24:33 -04:00 committed by cemal
parent b2a42533b6
commit d08aa81411
4 changed files with 136 additions and 107 deletions

View File

@ -1,21 +1,21 @@
'use strict'; 'use strict';
const Path = require('path'); const Path = require('path');
const Hoek = require('@hapi/hoek'); const Hoek = require('@hapi/hoek');
const Manifest = require('./server/manifest'); const Manifest = require('./server/manifest');
const Plugin = require('./lib/plugins/@hapipal.schwifty'); const Plugin = require('./lib/plugins/@hapipal.schwifty');
// Take schwifty registration's knex option // Take schwifty registration's knex option
// but specify the plugin's migrations directory // but specify the plugin's migrations directory
module.exports = Hoek.applyToDefaults( module.exports = Hoek.applyToDefaults(
{ {
migrations: { migrations: {
directory: Path.relative(process.cwd(), Plugin.options.migrationsDir) directory: Path.relative(process.cwd(), Plugin.options.migrationsDir)
} }
}, },
Manifest Manifest
.get('/register/plugins', process.env) .get('/register/plugins', process.env)
.find(({ plugin }) => plugin === '@hapipal/schwifty') .find(({ plugin }) => plugin === '@hapipal/schwifty')
.options.knex .options.knex
); );

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
module.exports = { module.exports = {
options: { options: {
migrationsDir: `${__dirname}/../migrations` migrationsDir: `${__dirname}/../migrations`
} }
}; };

View File

@ -1,34 +1,39 @@
{ {
"name": "hapipal-boilerplate", "name": "hapipal-boilerplate",
"version": "3.0.0", "version": "3.0.0",
"main": "lib/index.js", "main": "lib/index.js",
"scripts": { "scripts": {
"start": "node server", "start": "node server",
"test": "lab -a @hapi/code -I \"__core-js_shared__,CSS,regeneratorRuntime,core\" -L", "test": "lab -a @hapi/code -L",
"lint": "eslint ." "lint": "eslint ."
}, },
"dependencies": { "dependencies": {
"@hapi/boom": "9.x.x", "@hapi/boom": "9.x.x",
"@hapipal/haute-couture": "4.x.x", "@hapipal/haute-couture": "4.x.x",
"joi": "17.x.x" "@hapipal/schwifty": "6.x.x",
}, "joi": "17.x.x",
"devDependencies": { "objection": "2.x.x"
"@hapi/code": "8.x.x", },
"@hapi/eslint-config-hapi": "13.x.x", "peerDependencies": {
"@hapi/eslint-plugin-hapi": "4.x.x", "knex": "0.21.x"
"@hapi/glue": "8.x.x", },
"@hapi/hapi": "20.x.x", "devDependencies": {
"@hapi/inert": "6.x.x", "@hapi/code": "8.x.x",
"@hapi/lab": "24.x.x", "@hapi/eslint-config-hapi": "13.x.x",
"@hapi/vision": "6.x.x", "@hapi/eslint-plugin-hapi": "4.x.x",
"@hapipal/confidence": "6.x.x", "@hapi/glue": "8.x.x",
"@hapipal/hpal": "3.x.x", "@hapi/hapi": "20.x.x",
"@hapipal/hpal-debug": "2.x.x", "@hapi/hoek": "9.x.x",
"@hapipal/toys": "3.x.x", "@hapi/lab": "24.x.x",
"babel-eslint": "10.x.x", "@hapipal/confidence": "6.x.x",
"dotenv": "8.x.x", "@hapipal/hpal": "3.x.x",
"eslint": "7.x.x", "@hapipal/hpal-debug": "2.x.x",
"exiting": "6.x.x", "@hapipal/toys": "3.x.x",
"hapi-swagger": "14.x.x" "babel-eslint": "10.x.x",
} "dotenv": "8.x.x",
} "eslint": "7.x.x",
"exiting": "6.x.x",
"knex": "0.21.x",
"sqlite3": "5.x.x"
}
}

View File

@ -1,45 +1,69 @@
'use strict'; 'use strict';
const Dotenv = require('dotenv'); const Dotenv = require('dotenv');
const Confidence = require('@hapipal/confidence'); const Confidence = require('@hapipal/confidence');
const Toys = require('@hapipal/toys'); const Toys = require('@hapipal/toys');
const Schwifty = require('@hapipal/schwifty');
// Pull .env into process.env
Dotenv.config({ path: `${__dirname}/.env` }); // Pull .env into process.env
Dotenv.config({ path: `${__dirname}/.env` });
// Glue manifest as a confidence store
module.exports = new Confidence.Store({ // Glue manifest as a confidence store
server: { module.exports = new Confidence.Store({
host: 'localhost', server: {
port: { host: 'localhost',
$param: 'PORT', port: {
$coerce: 'number', $param: 'PORT',
$default: 3000 $coerce: 'number',
}, $default: 3000
debug: { },
$filter: 'NODE_ENV', debug: {
$default: { $filter: 'NODE_ENV',
log: ['error', 'start'], $default: {
request: ['error'] log: ['error', 'start'],
}, request: ['error']
production: { },
request: ['implementation'] production: {
} request: ['implementation']
} }
}, }
register: { },
plugins: [ register: {
{ plugins: [
plugin: '../lib', // Main plugin {
options: {} plugin: '../lib', // Main plugin
}, options: {}
{ },
plugin: { {
$filter: 'NODE_ENV', plugin: '@hapipal/schwifty',
$default: '@hapipal/hpal-debug', options: {
production: Toys.noop $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',
$default: '@hapipal/hpal-debug',
production: Toys.noop
}
}
]
}
});