aboutsummaryrefslogtreecommitdiff
path: root/packages/server/src/api/v1/repo/branches.ts
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-07-25 12:32:59 +0200
committerHampusM <hampus@hampusmat.com>2021-07-25 12:32:59 +0200
commitc63e558f402cfad914031a58fdcf3d8e0f3d125d (patch)
treebf080e4c23310f5a5a1d14f15bc3e575c0671625 /packages/server/src/api/v1/repo/branches.ts
parenta5afb39803e70a6117965760f50615aaba82f84a (diff)
Moved backend routes to a dedicated directory
Diffstat (limited to 'packages/server/src/api/v1/repo/branches.ts')
-rw-r--r--packages/server/src/api/v1/repo/branches.ts48
1 files changed, 0 insertions, 48 deletions
diff --git a/packages/server/src/api/v1/repo/branches.ts b/packages/server/src/api/v1/repo/branches.ts
deleted file mode 100644
index 4aa6665..0000000
--- a/packages/server/src/api/v1/repo/branches.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import { FastifyInstance, FastifyPluginOptions } from "fastify";
-import { Branch } from "../../../git/branch";
-import { Route } from "../../../types/fastify";
-import { BranchSummary as APIBranchSummary, Branch as APIBranch } from "shared_types";
-
-export default function(fastify: FastifyInstance, opts: FastifyPluginOptions, done: (err?: Error) => void): void {
- fastify.route<Route>({
- method: "GET",
- url: "/branches",
- handler: async(req, reply) => {
- const branches = await req.repository.branches();
-
- reply.send({
- data: branches.map(branch => {
- return <APIBranchSummary>{
- id: branch.id,
- name: branch.name
- };
- })
- });
- }
- });
-
- fastify.route<Route>({
- method: "GET",
- url: "/branches/:branch",
- handler: async(req, reply) => {
- const branch = await Branch.lookup(req.repository, req.params.branch);
-
- if(!branch) {
- reply.code(404).send({ error: "Branch not found!" });
- return;
- }
-
- const data: APIBranch = {
- id: branch.id,
- name: branch.name,
- latest_commit: await branch.latestCommit()
- };
-
- reply.send({
- data: data
- });
- }
- });
-
- done();
-} \ No newline at end of file