From d08aa81411318c9b46457498ce9aea5113bce2ed Mon Sep 17 00:00:00 2001 From: Devin Ivy Date: Sun, 11 Apr 2021 23:24:33 -0400 Subject: [PATCH] commmmr --- knexfile.js | 42 ++++++------ lib/plugins/@hapipal.schwifty.js | 14 ++-- package.json | 73 +++++++++++--------- server/manifest.js | 114 +++++++++++++++++++------------ 4 files changed, 136 insertions(+), 107 deletions(-) diff --git a/knexfile.js b/knexfile.js index a12119b..de1360b 100644 --- a/knexfile.js +++ b/knexfile.js @@ -1,21 +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 -); +'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 +); \ No newline at end of file diff --git a/lib/plugins/@hapipal.schwifty.js b/lib/plugins/@hapipal.schwifty.js index 317f87a..0d6ee5f 100644 --- a/lib/plugins/@hapipal.schwifty.js +++ b/lib/plugins/@hapipal.schwifty.js @@ -1,7 +1,7 @@ -'use strict'; - -module.exports = { - options: { - migrationsDir: `${__dirname}/../migrations` - } -}; +'use strict'; + +module.exports = { + options: { + migrationsDir: `${__dirname}/../migrations` + } +}; \ No newline at end of file diff --git a/package.json b/package.json index 77ab7db..9041b92 100644 --- a/package.json +++ b/package.json @@ -1,34 +1,39 @@ -{ - "name": "hapipal-boilerplate", - "version": "3.0.0", - "main": "lib/index.js", - "scripts": { - "start": "node server", - "test": "lab -a @hapi/code -I \"__core-js_shared__,CSS,regeneratorRuntime,core\" -L", - "lint": "eslint ." - }, - "dependencies": { - "@hapi/boom": "9.x.x", - "@hapipal/haute-couture": "4.x.x", - "joi": "17.x.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/inert": "6.x.x", - "@hapi/lab": "24.x.x", - "@hapi/vision": "6.x.x", - "@hapipal/confidence": "6.x.x", - "@hapipal/hpal": "3.x.x", - "@hapipal/hpal-debug": "2.x.x", - "@hapipal/toys": "3.x.x", - "babel-eslint": "10.x.x", - "dotenv": "8.x.x", - "eslint": "7.x.x", - "exiting": "6.x.x", - "hapi-swagger": "14.x.x" - } -} +{ + "name": "hapipal-boilerplate", + "version": "3.0.0", + "main": "lib/index.js", + "scripts": { + "start": "node server", + "test": "lab -a @hapi/code -L", + "lint": "eslint ." + }, + "dependencies": { + "@hapi/boom": "9.x.x", + "@hapipal/haute-couture": "4.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", + "@hapipal/hpal-debug": "2.x.x", + "@hapipal/toys": "3.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" + } +} diff --git a/server/manifest.js b/server/manifest.js index 0344f12..76c4c42 100644 --- a/server/manifest.js +++ b/server/manifest.js @@ -1,45 +1,69 @@ -'use strict'; - -const Dotenv = require('dotenv'); -const Confidence = require('@hapipal/confidence'); -const Toys = require('@hapipal/toys'); - -// Pull .env into process.env -Dotenv.config({ path: `${__dirname}/.env` }); - -// Glue manifest as a confidence store -module.exports = new Confidence.Store({ - server: { - host: 'localhost', - port: { - $param: 'PORT', - $coerce: 'number', - $default: 3000 - }, - debug: { - $filter: 'NODE_ENV', - $default: { - log: ['error', 'start'], - request: ['error'] - }, - production: { - request: ['implementation'] - } - } - }, - register: { - plugins: [ - { - plugin: '../lib', // Main plugin - options: {} - }, - { - plugin: { - $filter: 'NODE_ENV', - $default: '@hapipal/hpal-debug', - production: Toys.noop - } - } - ] - } -}); +'use strict'; + +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` }); + +// Glue manifest as a confidence store +module.exports = new Confidence.Store({ + server: { + host: 'localhost', + port: { + $param: 'PORT', + $coerce: 'number', + $default: 3000 + }, + debug: { + $filter: 'NODE_ENV', + $default: { + log: ['error', 'start'], + request: ['error'] + }, + production: { + request: ['implementation'] + } + } + }, + register: { + plugins: [ + { + 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', + $default: '@hapipal/hpal-debug', + production: Toys.noop + } + } + ] + } +});