| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- 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: [
- /** 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: 3307,
- },
- },
- },
- production: {
- migrateOnStart: false,
- },
- },
- },
- ],
- },
- })
|