| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- const Dotenv = require('dotenv').config({path: './server/.env'})
- 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')
-
-
- /** 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: [
- /** Main app */
- {
- plugin: '../lib',
- routes: {
- prefix: '/api',
- },
- options: {
- jwtKey: {
- $filter: 'NODE_ENV',
- $default: {
- $param: 'APP_SECRET',
- $default: 'app-secret',
- },
- // Use .env file in production
- production: {
- $param: 'APP_SECRET',
- },
- },
- },
- },
-
- /** Documentaion plugins */
- Inert,
- Vision,
- {
- plugin: HapiSwagger,
- options: {
- info: { title: 'Test API Documentation' },
- },
- },
- /** Model and knex integration */
- {
- 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,
- port: process.env.DB_PORT,
- },
- },
- },
- production: {
- migrateOnStart: false,
- },
- },
- },
- ],
- },
- })
|