aboutsummaryrefslogtreecommitdiff
path: root/packages/server/src/routes
diff options
context:
space:
mode:
Diffstat (limited to 'packages/server/src/routes')
-rw-r--r--packages/server/src/routes/api/v1/index.ts6
-rw-r--r--packages/server/src/routes/api/v1/repo/index.ts22
-rw-r--r--packages/server/src/routes/repo.ts10
3 files changed, 19 insertions, 19 deletions
diff --git a/packages/server/src/routes/api/v1/index.ts b/packages/server/src/routes/api/v1/index.ts
index 1adb3cb..fa7d8ab 100644
--- a/packages/server/src/routes/api/v1/index.ts
+++ b/packages/server/src/routes/api/v1/index.ts
@@ -4,7 +4,7 @@ import { Route } from "../../../types/fastify";
import repo from "./repo";
import { verifyRepoName } from "../util";
import { Info as APIInfo, RepositorySummary as APIRepositorySummary, Repository as APIRepository } from "api";
-import { BaseError } from "../../../git/error";
+import { ServerError } from "../../../git/error";
function setHandlers(fastify: FastifyInstance): void {
fastify.setErrorHandler((err, req, reply) => {
@@ -49,9 +49,9 @@ function reposEndpoints(fastify: FastifyInstance, opts: FastifyPluginOptions, do
return;
}
- const repository: Repository | BaseError = await Repository.open(opts.config.settings.git_dir, req.params.repo).catch(err => err);
+ const repository = await Repository.open(opts.config.settings.git_dir, req.params.repo).catch((err: ServerError) => err);
- if(repository instanceof BaseError) {
+ if(repository instanceof ServerError) {
reply.code(repository.code).send({ error: repository.message });
return;
}
diff --git a/packages/server/src/routes/api/v1/repo/index.ts b/packages/server/src/routes/api/v1/repo/index.ts
index bcd2e5c..059a9d4 100644
--- a/packages/server/src/routes/api/v1/repo/index.ts
+++ b/packages/server/src/routes/api/v1/repo/index.ts
@@ -8,7 +8,7 @@ import branches from "./branches";
import log from "./log";
import { verifyRepoName } from "../../util";
import { Tree as APITree, Tag as APITag, TreeEntry as APITreeEntry } from "api";
-import { BaseError } from "../../../../git/error";
+import { ServerError } from "../../../../git/error";
import { commitMap } from "./map";
declare module "fastify" {
@@ -19,9 +19,9 @@ declare module "fastify" {
function addHooks(fastify: FastifyInstance, opts: FastifyPluginOptions): void {
fastify.addHook("preHandler", async(req: CoolFastifyRequest, reply) => {
- const repository = await Repository.open(opts.config.settings.git_dir, req.params.repo, req.query.branch).catch((err: BaseError) => err);
+ const repository = await Repository.open(opts.config.settings.git_dir, req.params.repo, req.query.branch).catch((err: ServerError) => err);
- if(repository instanceof BaseError) {
+ if(repository instanceof ServerError) {
reply.code(repository.code).send({ error: repository.message });
return;
}
@@ -67,9 +67,9 @@ export default function(fastify: FastifyInstance, opts: FastifyPluginOptions, do
method: "GET",
url: "/tree",
handler: async(req, reply) => {
- const tree = await req.repository.tree().catch((err: BaseError) => err);
+ const tree = await req.repository.tree().catch((err: ServerError) => err);
- if(tree instanceof BaseError) {
+ if(tree instanceof ServerError) {
reply.code(tree.code).send({ error: tree.message });
return;
}
@@ -81,9 +81,9 @@ export default function(fastify: FastifyInstance, opts: FastifyPluginOptions, do
let data: APITree;
if(tree_path) {
- const tree_path_entry = await tree.find(tree_path).catch((err: BaseError) => err);
+ const tree_path_entry = await tree.find(tree_path).catch((err: ServerError) => err);
- if(tree_path_entry instanceof BaseError) {
+ if(tree_path_entry instanceof ServerError) {
reply.code(tree_path_entry.code).send({ error: tree_path_entry.message });
return;
}
@@ -104,9 +104,9 @@ export default function(fastify: FastifyInstance, opts: FastifyPluginOptions, do
method: "GET",
url: "/tree/history",
handler: async(req, reply) => {
- const tree = await req.repository.tree().catch((err: BaseError) => err);
+ const tree = await req.repository.tree().catch((err: ServerError) => err);
- if(tree instanceof BaseError) {
+ if(tree instanceof ServerError) {
reply.code(tree.code).send({ error: tree.message });
return;
}
@@ -118,9 +118,9 @@ export default function(fastify: FastifyInstance, opts: FastifyPluginOptions, do
const tree_path = req.query.path;
- const tree_entry = await tree.find(tree_path).catch((err: BaseError) => err);
+ const tree_entry = await tree.find(tree_path).catch((err: ServerError) => err);
- if(tree_entry instanceof BaseError) {
+ if(tree_entry instanceof ServerError) {
reply.code(tree_entry.code).send({ error: tree_entry.message });
return;
}
diff --git a/packages/server/src/routes/repo.ts b/packages/server/src/routes/repo.ts
index 43d89d2..32ac9c4 100644
--- a/packages/server/src/routes/repo.ts
+++ b/packages/server/src/routes/repo.ts
@@ -3,7 +3,7 @@ import { CoolFastifyRequest, Route } from "../types/fastify";
import { Tag } from "../git/tag";
import { FastifyInstance, FastifyPluginOptions } from "fastify";
import { verifyRepoName } from "../routes/api/util";
-import { BaseError } from "../git/error";
+import { ServerError } from "../git/error";
export default function(fastify: FastifyInstance, opts: FastifyPluginOptions, done: (err?: Error) => void): void {
fastify.addHook("onRequest", async(req: CoolFastifyRequest, reply) => {
@@ -62,16 +62,16 @@ export default function(fastify: FastifyInstance, opts: FastifyPluginOptions, do
method: "GET",
url: "/refs/tags/:tag",
handler: async(req, reply) => {
- const repository = await Repository.open(opts.config.settings.git_dir, req.params.repo).catch((err: BaseError) => err);
+ const repository = await Repository.open(opts.config.settings.git_dir, req.params.repo).catch((err: ServerError) => err);
- if(repository instanceof BaseError) {
+ if(repository instanceof ServerError) {
reply.code(repository.code).send(repository.message);
return;
}
- const tag = await Tag.lookup(repository, req.params.tag).catch((err: BaseError) => err);
+ const tag = await Tag.lookup(repository, req.params.tag).catch((err: ServerError) => err);
- if(tag instanceof BaseError) {
+ if(tag instanceof ServerError) {
reply.code(tag.code).send(tag.message);
return;
}