aboutsummaryrefslogtreecommitdiff
path: root/packages/server/src/routes/api/v1/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/server/src/routes/api/v1/index.ts')
-rw-r--r--packages/server/src/routes/api/v1/index.ts9
1 files changed, 7 insertions, 2 deletions
diff --git a/packages/server/src/routes/api/v1/index.ts b/packages/server/src/routes/api/v1/index.ts
index fb9cd8a..4b63435 100644
--- a/packages/server/src/routes/api/v1/index.ts
+++ b/packages/server/src/routes/api/v1/index.ts
@@ -8,13 +8,13 @@ import { ServerError } from "../../../git/error";
function setHandlers(fastify: FastifyInstance): void {
fastify.setErrorHandler((err, req, reply) => {
- console.log(err);
-
if(err.validation) {
reply.code(400).send({ error: `${err.validation[0].dataPath} ${err.validation[0].message}` });
return;
}
+ console.log(err);
+
reply.code(500).send({ error: "Internal server error!" });
});
fastify.setNotFoundHandler((req, reply) => {
@@ -49,6 +49,11 @@ function reposEndpoints(fastify: FastifyInstance, opts: FastifyPluginOptions, do
fastify.route<Route>({
method: "GET",
url: "/repos/:repo",
+ schema: {
+ params: {
+ repo: { type: "string" }
+ }
+ },
handler: async(req, reply) => {
if(!verifyRepoName(req.params.repo)) {
reply.code(400).send({ error: "Bad request" });