diff options
author | MCMXC <16797721+mcmxcdev@users.noreply.github.com> | 2024-02-11 19:15:20 +0530 |
---|---|---|
committer | Vijay A <vraravam@users.noreply.github.com> | 2024-02-17 21:55:26 +0530 |
commit | 83674017cf94d179f7d3c87c7e633f296e735ba1 (patch) | |
tree | b3eae213ee44d4f541c1a1d5ff6db77dcd5b9ad7 /start | |
parent | updates (diff) | |
download | ferdium-server-83674017cf94d179f7d3c87c7e633f296e735ba1.tar.gz ferdium-server-83674017cf94d179f7d3c87c7e633f296e735ba1.tar.zst ferdium-server-83674017cf94d179f7d3c87c7e633f296e735ba1.zip |
more updates
Diffstat (limited to 'start')
-rw-r--r-- | start/env.ts | 27 | ||||
-rw-r--r-- | start/kernel.ts | 55 |
2 files changed, 33 insertions, 49 deletions
diff --git a/start/env.ts b/start/env.ts index c51a472..5b40fd8 100644 --- a/start/env.ts +++ b/start/env.ts | |||
@@ -14,11 +14,30 @@ | |||
14 | import { Env } from '@adonisjs/core/env'; | 14 | import { Env } from '@adonisjs/core/env'; |
15 | 15 | ||
16 | export default await Env.create(new URL('../', import.meta.url), { | 16 | export default await Env.create(new URL('../', import.meta.url), { |
17 | HOST: Env.schema.string({ format: 'host' }), | 17 | NODE_ENV: Env.schema.enum(['development', 'production', 'test'] as const), |
18 | PORT: Env.schema.number(), | 18 | PORT: Env.schema.number(), |
19 | |||
20 | APP_KEY: Env.schema.string(), | 19 | APP_KEY: Env.schema.string(), |
21 | APP_NAME: Env.schema.string(), | 20 | HOST: Env.schema.string({ format: 'host' }), |
21 | LOG_LEVEL: Env.schema.string(), | ||
22 | 22 | ||
23 | NODE_ENV: Env.schema.enum(['development', 'production', 'test'] as const), | 23 | /* |
24 | |---------------------------------------------------------- | ||
25 | | Variables for configuring session package | ||
26 | |---------------------------------------------------------- | ||
27 | */ | ||
28 | SESSION_DRIVER: Env.schema.enum(['cookie', 'memory'] as const), | ||
29 | |||
30 | /* | ||
31 | |---------------------------------------------------------- | ||
32 | | Variables for configuring the mail package | ||
33 | |---------------------------------------------------------- | ||
34 | */ | ||
35 | // SMTP_HOST: Env.schema.string(), | ||
36 | // SMTP_PORT: Env.schema.string(), | ||
37 | // SES_ACCESS_KEY: Env.schema.string(), | ||
38 | // SES_ACCESS_SECRET: Env.schema.string(), | ||
39 | // SES_REGION: Env.schema.string(), | ||
40 | // MAILGUN_API_KEY: Env.schema.string(), | ||
41 | // MAILGUN_DOMAIN: Env.schema.string(), | ||
42 | // SPARKPOST_API_KEY: Env.schema.string(), | ||
24 | }); | 43 | }); |
diff --git a/start/kernel.ts b/start/kernel.ts index 0081844..86ec933 100644 --- a/start/kernel.ts +++ b/start/kernel.ts | |||
@@ -1,49 +1,14 @@ | |||
1 | /* | 1 | import server from '@adonisjs/core/services/server'; |
2 | |-------------------------------------------------------------------------- | 2 | import router from '@adonisjs/core/services/router'; |
3 | | Application middleware | ||
4 | |-------------------------------------------------------------------------- | ||
5 | | | ||
6 | | This file is used to define middleware for HTTP requests. You can register | ||
7 | | middleware as a `closure` or an IoC container binding. The bindings are | ||
8 | | preferred, since they keep this file clean. | ||
9 | | | ||
10 | */ | ||
11 | 3 | ||
12 | import { server } from '@adonisjs/core/services/server'; | 4 | server.use([ |
13 | 5 | () => import('@adonisjs/core/bodyparser_middleware'), | |
14 | /* | 6 | () => import('@adonisjs/shield/shield_middleware'), |
15 | |-------------------------------------------------------------------------- | ||
16 | | Global middleware | ||
17 | |-------------------------------------------------------------------------- | ||
18 | | | ||
19 | | An array of global middleware, that will be executed in the order they | ||
20 | | are defined for every HTTP requests. | ||
21 | | | ||
22 | */ | ||
23 | server.middleware.register([ | ||
24 | () => import('@ioc:Adonis/Core/BodyParser'), | ||
25 | () => import('@ioc:Adonis/Addons/Shield'), | ||
26 | ]); | 7 | ]); |
27 | 8 | ||
28 | /* | 9 | router.named({ |
29 | |-------------------------------------------------------------------------- | 10 | auth: () => import('#app/Middleware/Auth'), |
30 | | Named middleware | 11 | dashboard: () => import('#app/Middleware/Dashboard'), |
31 | |-------------------------------------------------------------------------- | 12 | guest: () => import('#app/Middleware/AllowGuestOnly'), |
32 | | | 13 | shield: () => import('@adonisjs/shield/shield_middleware'), |
33 | | Named middleware are defined as key-value pair. The value is the namespace | ||
34 | | or middleware function and key is the alias. Later you can use these | ||
35 | | alias on individual routes. For example: | ||
36 | | | ||
37 | | { auth: () => import('App/Middleware/Auth') } | ||
38 | | | ||
39 | | and then use it as follows | ||
40 | | | ||
41 | | Route.get('dashboard', 'UserController.dashboard').middleware('auth') | ||
42 | | | ||
43 | */ | ||
44 | server.middleware.registerNamed({ | ||
45 | auth: () => import('App/Middleware/Auth'), | ||
46 | dashboard: () => import('App/Middleware/Dashboard'), | ||
47 | guest: () => import('App/Middleware/AllowGuestOnly'), | ||
48 | shield: () => import('@ioc:Adonis/Addons/Shield'), | ||
49 | }); | 14 | }); |