umami/pages/api/share/[id].js
Brian Cao 78338205a3
Feat/um 62 prisma property names (#1562)
* checkpoint

* fix pg schema

* fix mysql schema

* change property names
2022-10-10 13:42:18 -07:00

23 lines
557 B
JavaScript

import { getWebsiteByShareId } from 'queries';
import { ok, notFound, methodNotAllowed, createToken } from 'next-basics';
import { secret } from 'lib/crypto';
export default async (req, res) => {
const { id } = req.query;
if (req.method === 'GET') {
const website = await getWebsiteByShareId(id);
if (website) {
const websiteId = website.websiteId;
const token = createToken({ websiteId: websiteId }, secret());
return ok(res, { websiteId, token });
}
return notFound(res);
}
return methodNotAllowed(res);
};