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