2024-08-09 23:51:41 +02:00
|
|
|
/**
|
|
|
|
* HTTP kernel file
|
|
|
|
*
|
|
|
|
* The HTTP kernel file is used to register the middleware with the server or the router.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import router from "@adonisjs/core/services/router"
|
|
|
|
import server from "@adonisjs/core/services/server"
|
|
|
|
|
|
|
|
/**
|
2024-08-12 01:32:43 +02:00
|
|
|
* The error handler is used to convert an exception to a HTTP response.
|
2024-08-09 23:51:41 +02:00
|
|
|
*/
|
|
|
|
server.errorHandler(async () => {
|
2024-08-15 15:14:21 +02:00
|
|
|
return await import("#app/exceptions/handler.ts")
|
2024-08-09 23:51:41 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
/**
|
2024-08-12 01:32:43 +02:00
|
|
|
* The server middleware stack runs middleware on all the HTTP requests, even if there is no route registered for the requested URL.
|
2024-08-09 23:51:41 +02:00
|
|
|
*/
|
|
|
|
server.use([
|
|
|
|
async () => {
|
2024-08-15 15:14:21 +02:00
|
|
|
return await import("#app/middleware/container_bindings_middleware.ts")
|
2024-08-09 23:51:41 +02:00
|
|
|
},
|
|
|
|
async () => {
|
2024-08-15 15:14:21 +02:00
|
|
|
return await import("#app/middleware/force_json_response_middleware.ts")
|
2024-08-09 23:51:41 +02:00
|
|
|
},
|
|
|
|
async () => {
|
|
|
|
return await import("@adonisjs/cors/cors_middleware")
|
|
|
|
},
|
|
|
|
])
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The router middleware stack runs middleware on all the HTTP requests with a registered route.
|
|
|
|
*/
|
|
|
|
router.use([
|
|
|
|
async () => {
|
|
|
|
return await import("@adonisjs/core/bodyparser_middleware")
|
|
|
|
},
|
|
|
|
async () => {
|
|
|
|
return await import("@adonisjs/auth/initialize_auth_middleware")
|
|
|
|
},
|
|
|
|
])
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Named middleware collection must be explicitly assigned to the routes or the routes group.
|
|
|
|
*/
|
|
|
|
export const middleware = router.named({
|
2024-08-12 19:19:43 +02:00
|
|
|
appKeySecurity: async () => {
|
2024-08-15 15:14:21 +02:00
|
|
|
return await import("#app/middleware/app_key_security_middleware.ts")
|
2024-08-12 19:19:43 +02:00
|
|
|
},
|
2024-08-09 23:51:41 +02:00
|
|
|
auth: async () => {
|
2024-08-15 15:14:21 +02:00
|
|
|
return await import("#app/middleware/auth_middleware.ts")
|
2024-08-09 23:51:41 +02:00
|
|
|
},
|
|
|
|
})
|