aboutsummaryrefslogtreecommitdiffstats
path: root/start
diff options
context:
space:
mode:
authorLibravatar MCMXC <16797721+mcmxcdev@users.noreply.github.com>2024-02-11 19:15:20 +0530
committerLibravatar Vijay A <vraravam@users.noreply.github.com>2024-02-13 06:59:44 +0530
commit8fec21d6bccfa778c14c1714d6444312e36fc3f1 (patch)
treecab910ad5048eece2d229648f2c17000ac86a44d /start
parentupdates (diff)
downloadferdium-server-8fec21d6bccfa778c14c1714d6444312e36fc3f1.tar.gz
ferdium-server-8fec21d6bccfa778c14c1714d6444312e36fc3f1.tar.zst
ferdium-server-8fec21d6bccfa778c14c1714d6444312e36fc3f1.zip
Diffstat (limited to 'start')
-rw-r--r--start/env.ts27
-rw-r--r--start/kernel.ts55
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 @@
14import { Env } from '@adonisjs/core/env'; 14import { Env } from '@adonisjs/core/env';
15 15
16export default await Env.create(new URL('../', import.meta.url), { 16export 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/* 1import server from '@adonisjs/core/services/server';
2|-------------------------------------------------------------------------- 2import 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
12import { server } from '@adonisjs/core/services/server'; 4server.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*/
23server.middleware.register([
24 () => import('@ioc:Adonis/Core/BodyParser'),
25 () => import('@ioc:Adonis/Addons/Shield'),
26]); 7]);
27 8
28/* 9router.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*/
44server.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});