Skip to content

Commit

Permalink
feat: Added new endpointGET/sessions/:sessionId/vmap to routes.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Kajlid committed Jun 4, 2024
1 parent 878d75b commit b62887c
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions api/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit b62887c

Please sign in to comment.