tethys.backend/start/kernel.ts

53 lines
1.8 KiB
TypeScript
Raw Normal View History

2023-03-03 15:54:28 +00:00
/*
|--------------------------------------------------------------------------
| Application middleware
|--------------------------------------------------------------------------
|
| This file is used to define middleware for HTTP requests. You can register
| middleware as a `closure` or an IoC container binding. The bindings are
| preferred, since they keep this file clean.
|
*/
import server from '@adonisjs/core/services/server';
import router from '@adonisjs/core/services/router';
2023-03-03 15:54:28 +00:00
server.errorHandler(() => import('#exceptions/handler'));
2023-03-03 15:54:28 +00:00
2024-03-14 19:25:27 +00:00
/**
* The server middleware stack runs middleware on all the HTTP
* requests, even if there is no route registered for
* the request URL.
*/
server.use([
() => import('#middleware/container_bindings_middleware'),
() => import('@adonisjs/static/static_middleware'),
// () => import('@adonisjs/cors/cors_middleware'),
() => import('@adonisjs/inertia/inertia_middleware'),
]);
2024-03-14 19:25:27 +00:00
/**
* The router middleware stack runs middleware on all the HTTP
* requests with a registered route.
*/
router.use([
() => import('@adonisjs/core/bodyparser_middleware'),
() => import('@adonisjs/session/session_middleware'),
() => import('@adonisjs/shield/shield_middleware'),
// () => import('@adonisjs/inertia/inertia_middleware'),
() => import('@adonisjs/auth/initialize_auth_middleware'),
() => import('#middleware/stardust_middleware'),
() => import('#middleware/normalize_newlines_middleware'),
]);
2024-03-14 19:25:27 +00:00
/**
* Named middleware collection must be explicitly assigned to
* the routes or the routes group.
*/
export const middleware = router.named({
guest: () => import('#middleware/guest_middleware'),
auth: () => import('#middleware/auth_middleware'),
is: () => import('#middleware/role_middleware'),
can: () => import('#middleware/can_middleware'),
});