選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

manifest.js 2.9KB

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,
  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. port: 3307,
  81. },
  82. },
  83. },
  84. production: {
  85. migrateOnStart: false,
  86. },
  87. },
  88. },
  89. ],
  90. },
  91. })