From b62887c8359c09a0c97696023a402232d2b7bf91 Mon Sep 17 00:00:00 2001 From: Kajlid <104261817+Kajlid@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:35:43 +0200 Subject: [PATCH] feat: Added new endpointGET/sessions/:sessionId/vmap to routes.js --- api/routes.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/api/routes.js b/api/routes.js index afcb6a2..05648f1 100644 --- a/api/routes.js +++ b/api/routes.js @@ -969,6 +969,39 @@ module.exports = (fastify, opt, next) => { } ); + fastify.get( + "/sessions/:sessionId/vmap", + { + schema: schemas["GET/sessions/:sessionId/vmap"], + tags: ["sessions/:sessionId"], + }, + async (req, reply) => { + const sessionId = req.params.sessionId; + try { + // Check if session exists. + const session = await DBAdapter.getSession(sessionId); + if (!session) { + reply.code(404).send({ + message: `Session with ID: '${sessionId}' was not found`, + }); + } else { + vmap_xml = session.getVmapXml(); + reply.headers({ + "Content-Type": "application/xml;charset=UTF-8", + }); + reply.code(200).send(vmap_xml); + } + } catch (exc) { + console.error(exc); + logger.error(exc, { + label: req.headers["host"], + sessionId: sessionId, + }); + reply.code(500).send({ message: exc.message }); + } + } + ); + // Users - routes fastify.get( "/users/:userId",