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.

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