2022-11-08 01:22:49 +01:00
|
|
|
import { methodNotAllowed, ok } from 'next-basics';
|
|
|
|
import { useAuth } from 'lib/middleware';
|
|
|
|
import redis from 'lib/redis';
|
|
|
|
import { getAuthToken } from 'lib/auth';
|
2022-11-15 22:21:14 +01:00
|
|
|
import { NextApiRequest, NextApiResponse } from 'next';
|
2022-11-08 01:22:49 +01:00
|
|
|
|
2022-11-15 22:21:14 +01:00
|
|
|
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
2022-11-08 01:22:49 +01:00
|
|
|
await useAuth(req, res);
|
|
|
|
|
|
|
|
if (req.method === 'POST') {
|
|
|
|
if (redis.enabled) {
|
2022-11-09 07:58:52 +01:00
|
|
|
await redis.del(getAuthToken(req));
|
2022-11-08 01:22:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ok(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
return methodNotAllowed(res);
|
|
|
|
};
|