Skip to content

Commit

Permalink
Merge pull request #84 from Eyevinn/get-session-vmap-xml
Browse files Browse the repository at this point in the history
Get session vmap xml through new endpoint
  • Loading branch information
Nfrederiksen authored Jun 12, 2024
2 parents 878d75b + 5fe486f commit 53957b5
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions api/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,24 @@ const schemas = {
404: BadRequestSchema("Session with ID: 'xxx-xxx-xxx-xxx' was not found"),
},
},
"GET/sessions/:sessionId/vmap": {
description: "Gets the VMAP XML created for a specific session",
tags: ["sessions"],
params: {
sessionId: {
type: "string",
description: "The ID for the session. ",
},
},
response: {
200: {
description: "VMAP XML",
type: "string",
},

404: BadRequestSchema("Session with ID: 'xxx-xxx-xxx-xxx' was not found"),
},
},
"DELETE/sessions/:sessionId": {
description: "Deletes the given session",
tags: ["sessions"],
Expand Down Expand Up @@ -969,6 +987,38 @@ module.exports = (fastify, opt, next) => {
}
);

fastify.get(
"/sessions/:sessionId/vmap",
{
schema: schemas["GET/sessions/:sessionId/vmap"],
},
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 53957b5

Please sign in to comment.