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.
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2024-05-21 12:41:10 +00:00
|
|
|
import server from '@adonisjs/core/services/server';
|
|
|
|
import router from '@adonisjs/core/services/router';
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2024-05-21 12:41:10 +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([
|
2024-05-21 12:41:10 +00:00
|
|
|
() => 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([
|
2024-05-21 12:41:10 +00:00
|
|
|
() => 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('@eidellev/adonis-stardust/build/middleware/Stardust.js'),
|
|
|
|
]);
|
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({
|
2024-05-21 12:41:10 +00:00
|
|
|
guest: () => import('#middleware/guest_middleware'),
|
|
|
|
auth: () => import('#middleware/auth_middleware'),
|
|
|
|
is: () => import('#middleware/role_middleware'),
|
|
|
|
can: () => import('#middleware/can_middleware'),
|
|
|
|
});
|