refactor: ♻️ remove code duplication

This commit is contained in:
Julien Oculi 2024-06-13 18:40:49 +02:00
parent 7ea95c67c4
commit ca482e8956

View file

@ -10,12 +10,10 @@ export async function handler(request: Request, ctx: FreshContext) {
response.headers.set('Service-Worker-Allowed', '/')
}
const cookies = getCookies(request.headers)
// Start session
if (SessionStore.getSession(cookies['_SESSION'] ?? '') === undefined) {
if (SessionStore.getFromRequest(request) === undefined) {
// Clear outdated cookies
for (const cookie in cookies) {
for (const cookie in getCookies(request.headers)) {
setCookie(response.headers, {
name: cookie,
value: '',