mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 10:33:01 +00:00
Project.blob -> Project.key
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
import type { BunRequest } from "bun";
|
||||
import { createIssue, getProjectByID, getProjectByBlob } from "../../db/queries";
|
||||
import { createIssue, getProjectByID, getProjectByKey } from "../../db/queries";
|
||||
|
||||
// /issue/create?projectId=1&title=Testing&description=Description
|
||||
// OR
|
||||
// /issue/create?projectBlob=projectBlob&title=Testing&description=Description
|
||||
// /issue/create?projectKey=projectKey&title=Testing&description=Description
|
||||
export default async function issueCreate(req: BunRequest) {
|
||||
const url = new URL(req.url);
|
||||
const projectId = url.searchParams.get("projectId");
|
||||
const projectBlob = url.searchParams.get("projectBlob");
|
||||
const projectKey = url.searchParams.get("projectKey");
|
||||
|
||||
let project = null;
|
||||
if (projectId) {
|
||||
project = await getProjectByID(Number(projectId));
|
||||
} else if (projectBlob) {
|
||||
project = await getProjectByBlob(projectBlob);
|
||||
} else if (projectKey) {
|
||||
project = await getProjectByKey(projectKey);
|
||||
} else {
|
||||
return new Response("missing project blob or project id", { status: 400 });
|
||||
return new Response("missing project key or project id", { status: 400 });
|
||||
}
|
||||
if (!project) {
|
||||
return new Response(`project not found: provided ${projectId ?? projectBlob}`, { status: 404 });
|
||||
return new Response(`project not found: provided ${projectId ?? projectKey}`, { status: 404 });
|
||||
}
|
||||
|
||||
const title = url.searchParams.get("title") || "Untitled Issue";
|
||||
|
||||
Reference in New Issue
Block a user