Use portal for modals. Prisma disconnect after query.

This commit is contained in:
Mike Cao 2020-08-18 23:35:26 -07:00
parent 774a7dfdbc
commit d4ca02f110
5 changed files with 14 additions and 12 deletions

View file

@ -33,8 +33,11 @@ if (process.env.NODE_ENV === 'production') {
export default prisma;
export async function runQuery(query) {
return query.catch(e => {
console.error(e);
throw e;
});
return query
.catch(e => {
console.error(e);
})
.finally(() => {
prisma.$disconnect();
});
}

View file

@ -10,12 +10,13 @@ export async function verifySession(req) {
}
const { website: website_uuid, hostname, screen, language, session } = payload;
const token = await parseToken(session);
if (!isValidId(website_uuid)) {
throw new Error(`Invalid website: ${website_uuid}`);
}
const token = await parseToken(session);
if (!token || token.website_uuid !== website_uuid) {
const { userAgent, browser, os, ip, country, device } = await getClientInfo(req, payload);