mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 02:33:01 +00:00
Organisation and OrganisationMember routes
This commit is contained in:
23
packages/backend/src/routes/organisation/create.ts
Normal file
23
packages/backend/src/routes/organisation/create.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { BunRequest } from "bun";
|
||||
import { createOrganisation } from "../../db/queries";
|
||||
|
||||
// /organisation/create?name=Org%20Name&slug=org-name&description=Optional%20description
|
||||
export default async function organisationCreate(req: BunRequest) {
|
||||
const url = new URL(req.url);
|
||||
const name = url.searchParams.get("name");
|
||||
const slug = url.searchParams.get("slug");
|
||||
const description = url.searchParams.get("description") || undefined;
|
||||
|
||||
if (!name || !slug) {
|
||||
return new Response(`missing parameters: ${!name ? "name " : ""}${!slug ? "slug" : ""}`, {
|
||||
status: 400,
|
||||
});
|
||||
}
|
||||
|
||||
// Check if organisation with slug already exists
|
||||
// TODO: Add this check when we have a getOrganisationBySlug function
|
||||
|
||||
const organisation = await createOrganisation(name, slug, description);
|
||||
|
||||
return Response.json(organisation);
|
||||
}
|
||||
Reference in New Issue
Block a user