
* run `yarn lint --fix`
* Revert "Revert "add linting to ci""
This reverts commit 0bbbbee4be
.
* Fixed some errors
* remove unused code - not sure why this was here?
* assert env var
* more type fixes
* fix typings og gcal callback - needs testing
* rename `md5.ts` to `md5.js`
it is js.
* fix types
* fix types
* fix lint errors
* fix last lint error
Co-authored-by: Alex van Andel <me@alexvanandel.com>
25 lines
741 B
TypeScript
25 lines
741 B
TypeScript
import type { NextApiRequest, NextApiResponse } from "next";
|
|
import prisma from "../../../../lib/prisma";
|
|
import { getSession } from "next-auth/client";
|
|
|
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
const session = await getSession({ req: req });
|
|
if (!session) {
|
|
return res.status(401).json({ message: "Not authenticated" });
|
|
}
|
|
|
|
// DELETE /api/teams/{team}
|
|
if (req.method === "DELETE") {
|
|
await prisma.membership.delete({
|
|
where: {
|
|
userId_teamId: { userId: session.user.id, teamId: parseInt(req.query.team) },
|
|
},
|
|
});
|
|
await prisma.team.delete({
|
|
where: {
|
|
id: parseInt(req.query.team),
|
|
},
|
|
});
|
|
return res.status(204).send(null);
|
|
}
|
|
}
|