Initial commit

Created from https://vercel.com/new
This commit is contained in:
WaylonWalker 2021-12-08 18:25:42 +00:00
commit 4047a7ec23
378 changed files with 29334 additions and 0 deletions

23
pages/api/websites.js Normal file
View file

@ -0,0 +1,23 @@
import { getUserWebsites } from 'lib/queries';
import { useAuth } from 'lib/middleware';
import { ok, methodNotAllowed, unauthorized } from 'lib/response';
export default async (req, res) => {
await useAuth(req, res);
const { user_id: current_user_id, is_admin } = req.auth;
const { user_id } = req.query;
const userId = +user_id;
if (req.method === 'GET') {
if (userId && userId !== current_user_id && !is_admin) {
return unauthorized(res);
}
const websites = await getUserWebsites(userId || current_user_id);
return ok(res, websites);
}
return methodNotAllowed(res);
};