2024-06-11 17:02:00 +02:00
|
|
|
import { FreshContext } from '$fresh/server.ts'
|
2024-07-11 12:22:22 +02:00
|
|
|
import { useCache } from ':src/cache/middleware.ts'
|
2024-07-09 11:00:35 +02:00
|
|
|
import { useCsp } from ':src/csp/middleware.ts'
|
2024-07-09 11:12:58 +02:00
|
|
|
import { useSecurityHeaders } from ':src/security_headers/middleware.ts'
|
2024-07-09 11:15:48 +02:00
|
|
|
import { useServiceworker } from ':src/serviceworker/middleware.ts'
|
2024-07-09 11:07:23 +02:00
|
|
|
import { useSession } from ':src/session/middleware.ts'
|
2024-07-09 11:12:58 +02:00
|
|
|
import { SessionStore } from ':src/session/mod.ts'
|
2024-06-11 17:02:00 +02:00
|
|
|
|
|
|
|
export async function handler(request: Request, ctx: FreshContext) {
|
2024-06-13 23:50:32 +02:00
|
|
|
// Update fresh context state with session
|
|
|
|
ctx.state = { ...ctx.state, session: SessionStore.getFromRequest(request) }
|
|
|
|
|
2024-07-04 12:44:34 +02:00
|
|
|
// Get response
|
2024-06-11 17:02:00 +02:00
|
|
|
const response = await ctx.next()
|
2024-07-04 12:44:34 +02:00
|
|
|
|
2024-07-09 11:12:58 +02:00
|
|
|
// Use custom middleware hooks
|
|
|
|
useSecurityHeaders(request, response, ctx)
|
2024-07-09 11:00:35 +02:00
|
|
|
await useCsp(request, response, ctx)
|
2024-07-09 11:07:23 +02:00
|
|
|
useSession(request, response, ctx)
|
2024-07-11 12:22:22 +02:00
|
|
|
useServiceworker(request, response, ctx)
|
|
|
|
useCache(request, response, ctx)
|
2024-06-13 12:20:47 +02:00
|
|
|
|
2024-06-11 17:02:00 +02:00
|
|
|
return response
|
|
|
|
}
|