mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 10:33:01 +00:00
frontend server utility improvement
This commit is contained in:
@@ -4,8 +4,8 @@ import authRegister from "./auth/register";
|
||||
import issueCreate from "./issue/create";
|
||||
import issueDelete from "./issue/delete";
|
||||
import issueUpdate from "./issue/update";
|
||||
import issuesInProject from "./issues/[projectKey]";
|
||||
import issues from "./issues/all";
|
||||
import issuesByProject from "./issues/by-project";
|
||||
import organisationAddMember from "./organisation/add-member";
|
||||
import organisationById from "./organisation/by-id";
|
||||
import organisationByUser from "./organisation/by-user";
|
||||
@@ -29,7 +29,7 @@ export const routes = {
|
||||
issueDelete,
|
||||
issueUpdate,
|
||||
|
||||
issuesInProject,
|
||||
issuesByProject,
|
||||
issues,
|
||||
|
||||
organisationCreate,
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import type { BunRequest } from "bun";
|
||||
import { getIssuesWithAssigneeByProject, getProjectByKey } from "../../db/queries";
|
||||
|
||||
export default async function issuesInProject(req: BunRequest<"/issues/:projectKey">) {
|
||||
const { projectKey } = req.params;
|
||||
|
||||
const project = await getProjectByKey(projectKey);
|
||||
if (!project) {
|
||||
return new Response(`project not found: provided ${projectKey}`, { status: 404 });
|
||||
}
|
||||
const issues = await getIssuesWithAssigneeByProject(project.id);
|
||||
|
||||
return Response.json(issues);
|
||||
}
|
||||
15
packages/backend/src/routes/issues/by-project.ts
Normal file
15
packages/backend/src/routes/issues/by-project.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { AuthedRequest } from "../../auth/middleware";
|
||||
import { getIssuesWithAssigneeByProject, getProjectByID } from "../../db/queries";
|
||||
|
||||
export default async function issuesByProject(req: AuthedRequest) {
|
||||
const url = new URL(req.url);
|
||||
const projectId = url.searchParams.get("projectId");
|
||||
|
||||
const project = await getProjectByID(Number(projectId));
|
||||
if (!project) {
|
||||
return new Response(`project not found: provided ${projectId}`, { status: 404 });
|
||||
}
|
||||
const issues = await getIssuesWithAssigneeByProject(project.id);
|
||||
|
||||
return Response.json(issues);
|
||||
}
|
||||
Reference in New Issue
Block a user