Added different methods to get user websites and teams.

This commit is contained in:
Mike Cao 2023-07-27 11:43:45 -07:00
parent 5189486d6f
commit f4aa8f9661
5 changed files with 58 additions and 12 deletions

View file

@ -4,7 +4,8 @@ import { useAuth, useCors } from 'lib/middleware';
import { NextApiRequestQueryBody } from 'lib/types';
import { NextApiResponse } from 'next';
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
import { createWebsite, getUserWebsites } from 'queries';
import { createWebsite } from 'queries';
import userWebsites from 'pages/api/users/[id]/websites';
export interface WebsitesRequestBody {
name: string;
@ -24,9 +25,9 @@ export default async (
} = req.auth;
if (req.method === 'GET') {
const websites = await getUserWebsites(userId);
req.query.id = userId;
return ok(res, websites);
return userWebsites(req, res);
}
if (req.method === 'POST') {