| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- const Dotenv = require('dotenv');
- const Confidence = require('@hapipal/confidence');
- const Inert = require('@hapi/inert');
- const Vision = require('@hapi/vision');
- const Schwifty = require('@hapipal/schwifty');
- const HapiSwagger = require('hapi-swagger');
-
- // Pull .env into process.env
- Dotenv.config({ path: `${__dirname}/.env` });
-
- // Glue manifest as a confidence store
- module.exports = new Confidence.Store({
- server: {
- host: process.env.API_HOST,
- port: {
- $filter: 'NODE_ENV',
- $default: {
- $param: 'API_PORT',
- $coerce: 'number',
- $default: process.env.API_PORT
- },
- test: { $value: undefined } // Let the server find an open port
- },
- debug: {
- $filter: 'NODE_ENV',
- $default: {
- log: ['error', 'start'],
- request: ['error']
- },
- production: {
- request: ['implementation']
- }
- }
- },
- register: {
- plugins: [
- {
- plugin: '../lib', // Main plugin
- routes: {
- prefix: '/api'
- },
- options: {
- jwtKey: {
- $filter: 'NODE_ENV',
- $default: {
- $param: 'APP_SECRET',
- $default: 'app-secret'
- },
- production: { // In production do not default to "app-secret"
- $param: 'APP_SECRET'
- }
- }
- }
- },
- // Documentaion deps
- Inert,
- Vision,
- {
- plugin: HapiSwagger,
- options: {
- info: { title: 'Test API Documentation' }
- }
- },
- {
- plugin: Schwifty,
- options: {
- $filter: 'NODE_ENV',
- $default: {},
- $base: {
- migrateOnStart: true,
- knex: {
- client: process.env.DB_TYPE,
- useNullAsDefault: true,
- connection: {
- host : process.env.DB_HOST,
- user : process.env.DB_USER,
- password : process.env.DB_ROOT_PASSWORD,
- database : process.env.DB_NAME
- }
- }
- },
- production: {
- migrateOnStart: false
- }
- }
- }
- ]
- }
- })
|