You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

28 lines
658 B
TypeScript

import type { APIContext } from 'astro'
import { eq } from 'drizzle-orm'
import { db } from '@/db'
import { sessions } from '@/db/schema'
export async function GET({ cookies }: APIContext) {
const sessionId = cookies.get('app_auth_token')?.value
if (!sessionId) {
return new Response(null, {
status: 302,
headers: {
Location: '/',
},
})
}
await db.delete(sessions).where(eq(sessions.id, sessionId))
cookies.delete('app_auth_token', { path: '/' })
return new Response(null, {
status: 302,
headers: {
Location: '/',
},
})
}