Skip to content

Commit

Permalink
Return only the json for the body of the response
Browse files Browse the repository at this point in the history
  • Loading branch information
nlisgo committed Feb 9, 2024
1 parent 87b7e4b commit 2e472c9
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,15 @@ app.post('/', async (req, res) => {

const versionResponders = {
'application/vnd.elife.encoda.v1.0.3+json': async () => {
res.json({
version: '1.0.3',
json: (await convert_1_0_3(xmlFile, undefined, parameters))?.replaceAll(tempOutput, replacementPath),
});
res.json(JSON.parse(((await convert_1_0_3(xmlFile, undefined, parameters)) ?? '{}').replaceAll(tempOutput, replacementPath)));
rmdirSync(tempOutput, { recursive: true });
},
'application/vnd.elife.encoda.v1.0.2+json': async () => {
res.json({
version: '1.0.2',
json: (await convert_1_0_2(xmlFile, undefined, parameters))?.replaceAll(tempOutput, replacementPath),
});
res.json(JSON.parse(((await convert_1_0_2(xmlFile, undefined, parameters)) ?? '{}').replaceAll(tempOutput, replacementPath)));
rmdirSync(tempOutput, { recursive: true });
},
'application/vnd.elife.encoda.v1.0.1+json': async () => {
res.json({
version: '1.0.1',
json: (await convert_1_0_1(xmlFile, undefined, parameters))?.replaceAll(tempOutput, replacementPath),
});
res.json(JSON.parse(((await convert_1_0_1(xmlFile, undefined, parameters)) ?? '{}').replaceAll(tempOutput, replacementPath)));
rmdirSync(tempOutput, { recursive: true });
},
default: async () => versionResponders['application/vnd.elife.encoda.v1.0.3+json'](),
Expand Down

0 comments on commit 2e472c9

Please sign in to comment.