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.

manifest.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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,
  57. Vision,
  58. {
  59. plugin: HapiSwagger,
  60. options: {
  61. info: { title: 'Test API Documentation' },
  62. },
  63. },
  64. /** Model and knex integration */
  65. {
  66. plugin: Schwifty,
  67. options: {
  68. $filter: 'NODE_ENV',
  69. $default: {},
  70. $base: {
  71. migrateOnStart: true,
  72. knex: {
  73. client: process.env.DB_TYPE,
  74. useNullAsDefault: true,
  75. connection: {
  76. host: process.env.DB_HOST,
  77. user: process.env.DB_USER,
  78. password: process.env.DB_ROOT_PASSWORD,
  79. database: process.env.DB_NAME,
  80. },
  81. },
  82. },
  83. production: {
  84. migrateOnStart: false,
  85. },
  86. },
  87. },
  88. ],
  89. },
  90. })