| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- const Dotenv = require('dotenv').config({path: './server/.env'})
- // 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` })
- // 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: [
- /** 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,
- },
- },
- },
- ],
- },
- })
|