umami/pages/api/me/websites.ts

20 lines
529 B
TypeScript
Raw Normal View History

2023-02-08 01:29:25 +01:00
import { useAuth, useCors } from 'lib/middleware';
import { NextApiRequestQueryBody } from 'lib/types';
import { NextApiResponse } from 'next';
import { methodNotAllowed } from 'next-basics';
import userWebsites from 'pages/api/users/[id]/websites';
2023-02-08 01:29:25 +01:00
2023-05-23 00:38:03 +02:00
export default async (req: NextApiRequestQueryBody, res: NextApiResponse) => {
2023-02-08 01:29:25 +01:00
await useCors(req, res);
await useAuth(req, res);
if (req.method === 'GET') {
req.query.id = req.auth.user.id;
2023-02-08 01:29:25 +01:00
return userWebsites(req, res);
2023-02-08 01:29:25 +01:00
}
return methodNotAllowed(res);
};