diff options
author | 2023-10-13 14:12:03 +0200 | |
---|---|---|
committer | 2023-10-13 13:12:03 +0100 | |
commit | e503468660a13760010a94ecda5f0625c6f47f87 (patch) | |
tree | fa532f54fc5f091de08d55405ec6339bd2440a02 /config/app.ts | |
parent | 1.3.16 [skip ci] (diff) | |
download | ferdium-server-e503468660a13760010a94ecda5f0625c6f47f87.tar.gz ferdium-server-e503468660a13760010a94ecda5f0625c6f47f87.tar.zst ferdium-server-e503468660a13760010a94ecda5f0625c6f47f87.zip |
Server re-build with latest AdonisJS framework & Typescript (#47)
* chore: setup first basis structure
* chore: ensure styling is loaded correctly
* chore: comply to new routing syntax by replace . with / in routes/resource locations
* chore: add login controller
* chore: correctly use views with slash instead of dot
* chore: working login + tests
* chore: clean up tests
* chore: add password-forgot endpoint and matching test
* chore: add delete page test
* chore: add logout test
* chore: add reset-password route and tests
* chore: remove obsolete comment
* chore: add account-page and tests
* chore: add data page & first step of the test
* chore: add transfer/import data feature and tests
* chore: add export and basic test
* chore: add all static api routes with tests
* Regenerate 'pnpm-lock.json' and fix bad merge conflict
WIP:
- Tests have been commented out since they dont work
- Server doesn't start
* easier dev and test runs
* - remove --require-pragma from reformat-files so formatting works properly
- run pnpm reformat-files over codebase
- remove .json files from .eslintignore
- add invalid.json file to .eslintignore
- configure prettier properly in eslint config
- add type jsdoc to prettier config
- run adonis generate:manifest command to regenerate ace-manifest.json
- specify volta in package.json
- introduce typecheck npm script
- remove unused .mjs extension from npm scripts
- install missing type definition dependencies
- add pnpm.allowedDeprecatedVersions to package.json
- fix invalid extends in tsconfig.json causing TS issues throughout codebase
- remove @ts-ignore throughout codebase which is not relevant anymore
- enable some of the tsconfig options
- remove outdated eslint-disable from codebase
- change deprecated faker.company.companyName() to faker.company.name()
- fix TS issues inside transfer.spec.ts
* - update to latest node and pnpm versions
- upgrade all non-major dependencies to latest
- install missing @types/luxon dependency
- add cuid to pnpm.allowedDeprecatedVersions
- add esModuleInterop config option to tsconfig
- migrate more deprecated faker methods to new ones
- add more temporary ts-ignore to code
* - update eslint config
- remove trailingComma: all since default in prettier v3
- add typecheck command to prepare-code npm script
- upgrade various dependencies to latest major version
- update tsconfig to include only useful config options
- disable some lint issues and fix others
* - add test command to prepare-code
- disable strictPropertyInitialization flag in tsconfig which creates issues with adonis models
- update precommit hook to excute pnpm prepare-code
- remove ts-ignore statements from all models
* fix node and pnpm dependency update
* add cross env (so that we can develop on windows)
* add signup endpoint (TODO: JWT auth)
* Add login endpoint
* Add me and updateMe endpoints
* Add service endpoint
* refactor: change endpoints to use jwt
* add recipes endpoint
* add workspaces endpoint
* fix web controllors for login and post import
* Update node deps
* Change auth middleware (for web) and exempt api from CSRF
* Add import endpoint (franz import)
* Fix export/import logic
* Fix service and workspace data in user/data
* Fix partial lint
* chore: workaround lint issues
* fix: migration naming had two .
* Sync back node with recipes repo
* Temporarily ignore typescript
* Fix adonisrc to handle public folder static assets
* Fix issue with production database
* add Legacy Password Provider
* Fix lint errors
* Fix issue on login errors frontend
* add Legacy Password Provider
* Fix issue with customIcons
* Fix issue with auth tokens
* Update 'node' to '18.18.0'
* make docker work
* improve docker entrypoint (test api performance)
* Add migration database script
* NODE_ENV on recipes
* prefer @ts-expect-error over @ts-ignore
* small fixes
* Update 'pnpm' to '8.7.6'
* fix error catch
* Automatically generate JWT Public and Private keys
* Use custom Adonis5-jwt
* Update code to use secret (old way, no breaking changes)
* Normalize appKey
* Trick to make JWT tokens on client work with new version
* Fix error with new JWT logic
* Change migration and how we store JWT
* Fix 500 response code (needs to be 401)
* Improve logic and fix bugs
* Fix build and entrypoint logic
* Catch error if appKey changes
* Add newToken logic
* Fix lint (ignore any errors)
* Add build for PRs
* pnpm reformat-files result
* Fix some tests
* Fix reset password not working (test failing)
* Restore csrfTokens (disabled by accident)
* Fix pnpm start command with .env
* Disable failing tests on the transfer endpoint (TODO)
* Add tests to PR build
* Fix build
* Remove unnecessary assertStatus
* Add typecheck
* hash password on UserFactory (fix build)
* Add JWT_USE_PEM true by default (increase security)
* fix name of github action
---------
Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Co-authored-by: Balaji Vijayakumar <kuttibalaji.v6@gmail.com>
Co-authored-by: MCMXC <16797721+mcmxcdev@users.noreply.github.com>
Co-authored-by: André Oliveira <oliveira.andrerodrigues95@gmail.com>
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 = {}; | ||