You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. const Dotenv = require('dotenv').config({path: './server/.env'})
  2. // const Dotenv = require('dotenv')
  3. const Confidence = require('@hapipal/confidence')
  4. const Inert = require('@hapi/inert')
  5. const Vision = require('@hapi/vision')
  6. const Schwifty = require('@hapipal/schwifty')
  7. const HapiSwagger = require('hapi-swagger')
  8. /** Pull .env into process.env */
  9. // Dotenv.config({ path: `${__dirname}/../.env` })
  10. // Dotenv.config({ path: `${__dirname}/../.env` })
  11. /** Glue manifest as a confidence store */
  12. module.exports = new Confidence.Store({
  13. server: {
  14. host: process.env.API_HOST,
  15. port: {
  16. $filter: 'NODE_ENV',
  17. $default: {
  18. $param: 'API_PORT',
  19. $coerce: 'number',
  20. $default: process.env.API_PORT,
  21. },
  22. test: { $value: undefined }, // Let the server find an open port
  23. },
  24. debug: {
  25. $filter: 'NODE_ENV',
  26. $default: {
  27. log: ['error', 'start'],
  28. request: ['error'],
  29. },
  30. production: {
  31. request: ['implementation'],
  32. },
  33. },
  34. },
  35. register: {
  36. plugins: [
  37. /** Main app */
  38. {
  39. plugin: '../lib',
  40. routes: {
  41. prefix: '/api',
  42. },
  43. options: {
  44. jwtKey: {
  45. $filter: 'NODE_ENV',
  46. $default: {
  47. $param: 'APP_SECRET',
  48. $default: 'app-secret',
  49. },
  50. // Use .env file in production
  51. production: {
  52. $param: 'APP_SECRET',
  53. },
  54. },
  55. },
  56. },
  57. /** Documentaion plugins */
  58. Inert,
  59. Vision,
  60. {
  61. plugin: HapiSwagger,
  62. options: {
  63. info: { title: 'Test API Documentation' },
  64. },
  65. },
  66. /** Model and knex integration */
  67. {
  68. plugin: Schwifty,
  69. options: {
  70. $filter: 'NODE_ENV',
  71. $default: {},
  72. $base: {
  73. migrateOnStart: true,
  74. knex: {
  75. client: process.env.DB_TYPE,
  76. useNullAsDefault: true,
  77. connection: {
  78. host: process.env.DB_HOST,
  79. user: process.env.DB_USER,
  80. password: process.env.DB_ROOT_PASSWORD,
  81. database: process.env.DB_NAME,
  82. port: process.env.DB_PORT,
  83. },
  84. },
  85. },
  86. production: {
  87. migrateOnStart: false,
  88. },
  89. },
  90. },
  91. ],
  92. },
  93. })