Skip to content
Snippets Groups Projects
Commit 57144313 authored by Paolo.Brasolin's avatar Paolo.Brasolin
Browse files

feat: #be minimal implementation of all endpoints

parent bc827c16
No related branches found
No related tags found
No related merge requests found
......@@ -172,7 +172,14 @@ const apiPlugin: FastifyPluginCallback = (fastify, options, next) => {
200: ClueSchema,
},
},
handler: async (request, reply) => {},
handler: async (request, reply) => {
const clues = await connection
.table("clues")
.insert(request.body)
.returning<ClueType[]>("*");
reply.code(200).send(clues[0]);
},
});
fastify.route<{
......@@ -189,7 +196,19 @@ const apiPlugin: FastifyPluginCallback = (fastify, options, next) => {
200: ClueSchema,
},
},
handler: async (request, reply) => {},
handler: async (request, reply) => {
const clue = await connection<ClueType>("clues")
.where("id", request.params.id)
.first();
if (clue === undefined) {
reply.code(404).send();
} else {
const clues = await connection<ClueType>("clues")
.update(request.body)
.returning("*");
reply.code(200).send(clues[0]);
}
},
});
fastify.route<{
......@@ -206,7 +225,14 @@ const apiPlugin: FastifyPluginCallback = (fastify, options, next) => {
200: ShotSchema,
},
},
handler: async (request, reply) => {},
handler: async (request, reply) => {
const shots = await connection
.table("shots")
.insert(request.body)
.returning<ShotType[]>("*");
reply.code(200).send(shots[0]);
},
});
next();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment