|
|
|
@ -488,6 +488,54 @@ fastify.get(
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/* Update the work title by its ID */
|
|
|
|
|
fastify.put(
|
|
|
|
|
"/works/:id/title",
|
|
|
|
|
{
|
|
|
|
|
schema: {
|
|
|
|
|
params: Type.Object({
|
|
|
|
|
id: Type.Number({
|
|
|
|
|
minimum: 0,
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
body: Type.Object({
|
|
|
|
|
newTitle: Type.String(),
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
async (request, reply) => {
|
|
|
|
|
const { id } = request.params;
|
|
|
|
|
const { newTitle } = request.body;
|
|
|
|
|
db.updateWorkTitle(database, id, newTitle);
|
|
|
|
|
reply.send({ success: true });
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/* Update the work content by its ID */
|
|
|
|
|
fastify.put(
|
|
|
|
|
"/works/:id/content",
|
|
|
|
|
{
|
|
|
|
|
schema: {
|
|
|
|
|
params: Type.Object({
|
|
|
|
|
id: Type.Number({
|
|
|
|
|
minimum: 0,
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
body: Type.Object({
|
|
|
|
|
newContent: Type.String(),
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
async (request, reply) => {
|
|
|
|
|
const { id } = request.params;
|
|
|
|
|
const { newContent } = request.body;
|
|
|
|
|
db.updateWorkContent(database, id, newContent);
|
|
|
|
|
reply.send({ success: true });
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Forward output est une fonction asynchrone qui permet de récupérer les messages envoyés par le container et de les renvoyer au client */
|
|
|
|
|
async function forwardOutput() {
|
|
|
|
|
for await (const [buff] of receiver) {
|
|
|
|
|