From d1a1b7dc947063aef5f8375a6a1e03246b272c84 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 18 Aug 2021 17:29:55 +0200 Subject: Implemented caching for certain API endpoints, Added documentation & made backend-fixes --- packages/server/src/routes/repo.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'packages/server/src/routes/repo.ts') diff --git a/packages/server/src/routes/repo.ts b/packages/server/src/routes/repo.ts index bb70c68..1088e6b 100644 --- a/packages/server/src/routes/repo.ts +++ b/packages/server/src/routes/repo.ts @@ -1,11 +1,11 @@ import { Repository } from "../git/repository"; -import { CoolFastifyRequest, Route } from "../types/fastify"; +import { CoolFastifyRequest, Route, FastifyPluginOptions } from "../types/fastify"; import { Tag } from "../git/tag"; -import { FastifyInstance, FastifyPluginOptions } from "fastify"; +import { FastifyPluginCallback } from "fastify"; import { verifyRepoName } from "../routes/api/util"; import { ServerError } from "../git/error"; -export default function(fastify: FastifyInstance, opts: FastifyPluginOptions, done: (err?: Error) => void): void { +const repo: FastifyPluginCallback = (fastify, opts, done): void => { fastify.addHook("onRequest", async(req: CoolFastifyRequest, reply) => { if(!verifyRepoName(req.params.repo)) { reply.code(400).send("Bad request"); @@ -86,4 +86,6 @@ export default function(fastify: FastifyInstance, opts: FastifyPluginOptions, do }); done(); -} \ No newline at end of file +}; + +export default repo; \ No newline at end of file -- cgit v1.2.3-18-g5258