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.9KB

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