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