diff options
author | HampusM <hampus@hampusmat.com> | 2021-08-15 15:29:53 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2021-08-15 15:29:53 +0200 |
commit | dfd299d4697a629f09ef20fc05c6d9e474bd5475 (patch) | |
tree | 5b47b64afc379101187acec7c0f95baf7b1dba04 /packages/server/src/routes/api/v1/repo/index.ts | |
parent | 9736749a779661a95211a91200617a03a1b9a702 (diff) |
Improved route parameter validation
Diffstat (limited to 'packages/server/src/routes/api/v1/repo/index.ts')
-rw-r--r-- | packages/server/src/routes/api/v1/repo/index.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/packages/server/src/routes/api/v1/repo/index.ts b/packages/server/src/routes/api/v1/repo/index.ts index 059a9d4..4cd6c51 100644 --- a/packages/server/src/routes/api/v1/repo/index.ts +++ b/packages/server/src/routes/api/v1/repo/index.ts @@ -103,6 +103,11 @@ export default function(fastify: FastifyInstance, opts: FastifyPluginOptions, do fastify.route<Route>({ method: "GET", url: "/tree/history", + schema: { + querystring: { + path: { type: "string" } + } + }, handler: async(req, reply) => { const tree = await req.repository.tree().catch((err: ServerError) => err); @@ -111,11 +116,6 @@ export default function(fastify: FastifyInstance, opts: FastifyPluginOptions, do return; } - if(Object.keys(req.query).length === 0) { - reply.code(400).send({ error: "Missing query parameter 'path'!" }); - return; - } - const tree_path = req.query.path; const tree_entry = await tree.find(tree_path).catch((err: ServerError) => err); |