app.ts 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /**
  2. * Config source: https://git.io/JfefZ
  3. *
  4. * Feel free to let us know via PR, if you find something broken in this config
  5. * file.
  6. */
  7. import proxyAddr from 'proxy-addr'
  8. import Env from '@ioc:Adonis/Core/Env'
  9. import type { ServerConfig } from '@ioc:Adonis/Core/Server'
  10. import type { LoggerConfig } from '@ioc:Adonis/Core/Logger'
  11. import type { ProfilerConfig } from '@ioc:Adonis/Core/Profiler'
  12. import type { ValidatorConfig } from '@ioc:Adonis/Core/Validator'
  13. /*
  14. |--------------------------------------------------------------------------
  15. | Application secret key
  16. |--------------------------------------------------------------------------
  17. |
  18. | The secret to encrypt and sign different values in your application.
  19. | Make sure to keep the `APP_KEY` as an environment variable and secure.
  20. |
  21. | Note: Changing the application key for an existing app will make all
  22. | the cookies invalid and also the existing encrypted data will not
  23. | be decrypted.
  24. |
  25. */
  26. export const appKey: string = Env.get('APP_KEY')
  27. /*
  28. |--------------------------------------------------------------------------
  29. | Http server configuration
  30. |--------------------------------------------------------------------------
  31. |
  32. | The configuration for the HTTP(s) server. Make sure to go through all
  33. | the config properties to make keep server secure.
  34. |
  35. */
  36. export const http: ServerConfig = {
  37. /*
  38. |--------------------------------------------------------------------------
  39. | Allow method spoofing
  40. |--------------------------------------------------------------------------
  41. |
  42. | Method spoofing enables defining custom HTTP methods using a query string
  43. | `_method`. This is usually required when you are making traditional
  44. | form requests and wants to use HTTP verbs like `PUT`, `DELETE` and
  45. | so on.
  46. |
  47. */
  48. allowMethodSpoofing: false,
  49. /*
  50. |--------------------------------------------------------------------------
  51. | Subdomain offset
  52. |--------------------------------------------------------------------------
  53. */
  54. subdomainOffset: 2,
  55. /*
  56. |--------------------------------------------------------------------------
  57. | Request Ids
  58. |--------------------------------------------------------------------------
  59. |
  60. | Setting this value to `true` will generate a unique request id for each
  61. | HTTP request and set it as `x-request-id` header.
  62. |
  63. */
  64. generateRequestId: false,
  65. /*
  66. |--------------------------------------------------------------------------
  67. | Trusting proxy servers
  68. |--------------------------------------------------------------------------
  69. |
  70. | Define the proxy servers that AdonisJs must trust for reading `X-Forwarded`
  71. | headers.
  72. |
  73. */
  74. trustProxy: proxyAddr.compile('loopback'),
  75. /*
  76. |--------------------------------------------------------------------------
  77. | Generating Etag
  78. |--------------------------------------------------------------------------
  79. |
  80. | Whether or not to generate an etag for every response.
  81. |
  82. */
  83. etag: false,
  84. /*
  85. |--------------------------------------------------------------------------
  86. | JSONP Callback
  87. |--------------------------------------------------------------------------
  88. */
  89. jsonpCallbackName: 'callback',
  90. /*
  91. |--------------------------------------------------------------------------
  92. | Cookie settings
  93. |--------------------------------------------------------------------------
  94. */
  95. cookie: {
  96. domain: '',
  97. path: '/',
  98. maxAge: '2h',
  99. httpOnly: true,
  100. secure: false,
  101. sameSite: false
  102. },
  103. /*
  104. |--------------------------------------------------------------------------
  105. | Force Content Negotiation
  106. |--------------------------------------------------------------------------
  107. |
  108. | The internals of the framework relies on the content negotiation to
  109. | detect the best possible response type for a given HTTP request.
  110. |
  111. | However, it is a very common these days that API servers always wants to
  112. | make response in JSON regardless of the existence of the `Accept` header.
  113. |
  114. | By setting `forceContentNegotiationTo = 'application/json'`, you negotiate
  115. | with the server in advance to always return JSON without relying on the
  116. | client to set the header explicitly.
  117. |
  118. */
  119. forceContentNegotiationTo: 'application/json'
  120. }
  121. /*
  122. |--------------------------------------------------------------------------
  123. | Logger
  124. |--------------------------------------------------------------------------
  125. */
  126. export const logger: LoggerConfig = {
  127. /*
  128. |--------------------------------------------------------------------------
  129. | Application name
  130. |--------------------------------------------------------------------------
  131. |
  132. | The name of the application you want to add to the log. It is recommended
  133. | to always have app name in every log line.
  134. |
  135. | The `APP_NAME` environment variable is automatically set by AdonisJS by
  136. | reading the `name` property from the `package.json` file.
  137. |
  138. */
  139. name: Env.get('APP_NAME'),
  140. /*
  141. |--------------------------------------------------------------------------
  142. | Toggle logger
  143. |--------------------------------------------------------------------------
  144. |
  145. | Enable or disable logger application wide
  146. |
  147. */
  148. enabled: true,
  149. /*
  150. |--------------------------------------------------------------------------
  151. | Logging level
  152. |--------------------------------------------------------------------------
  153. |
  154. | The level from which you want the logger to flush logs. It is recommended
  155. | to make use of the environment variable, so that you can define log levels
  156. | at deployment level and not code level.
  157. |
  158. */
  159. level: Env.get('LOG_LEVEL', 'info'),
  160. /*
  161. |--------------------------------------------------------------------------
  162. | Pretty print
  163. |--------------------------------------------------------------------------
  164. |
  165. | It is highly advised NOT to use `prettyPrint` in production, since it
  166. | can have huge impact on performance.
  167. |
  168. */
  169. prettyPrint: Env.get('NODE_ENV') === 'development'
  170. }
  171. /*
  172. |--------------------------------------------------------------------------
  173. | Profiler
  174. |--------------------------------------------------------------------------
  175. */
  176. export const profiler: ProfilerConfig = {
  177. /*
  178. |--------------------------------------------------------------------------
  179. | Toggle profiler
  180. |--------------------------------------------------------------------------
  181. |
  182. | Enable or disable profiler
  183. |
  184. */
  185. enabled: true,
  186. /*
  187. |--------------------------------------------------------------------------
  188. | Blacklist actions/row labels
  189. |--------------------------------------------------------------------------
  190. |
  191. | Define an array of actions or row labels that you want to disable from
  192. | getting profiled.
  193. |
  194. */
  195. blacklist: [],
  196. /*
  197. |--------------------------------------------------------------------------
  198. | Whitelist actions/row labels
  199. |--------------------------------------------------------------------------
  200. |
  201. | Define an array of actions or row labels that you want to whitelist for
  202. | the profiler. When whitelist is defined, then `blacklist` is ignored.
  203. |
  204. */
  205. whitelist: []
  206. }
  207. /*
  208. |--------------------------------------------------------------------------
  209. | Validator
  210. |--------------------------------------------------------------------------
  211. |
  212. | Configure the global configuration for the validator. Here's the reference
  213. | to the default config https://git.io/JT0WE
  214. |
  215. */
  216. export const validator: ValidatorConfig = {}