Files
pfadi-bussle/pages/api/logout.ts
2021-06-16 23:36:28 +02:00

17 lines
412 B
TypeScript

import withSession from '../../lib/session'
async function loginHandler(req: any, res: any): Promise<void> {
const { method } = req
switch (method) {
case 'POST':
req.session.destroy()
res.json({ message: 'Logged out' })
break
default:
res.setHeader('Allow', ['POST'])
res.status(405).end(`Method ${method} Not Allowed`)
}
}
export default withSession(loginHandler)