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.
28 lines
658 B
TypeScript
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: '/',
|
|
},
|
|
})
|
|
}
|