Skip to content

Commit

Permalink
feat: MXL
Browse files Browse the repository at this point in the history
  • Loading branch information
sealsrock12 committed Dec 15, 2020
1 parent 7221aa7 commit 4b6db03
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/musicxml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,22 @@ export default (async (req, res) => {
}
}

// Do the actual conversion.
const mxml = await (score.saveXml());
// Conversion and send it off.
if (req.url.startsWith("/mmxl")) {
const mxml = await (score.saveMxl());

// Send it off.
res.setHeader("Content-Disposition", `attachement; filename=${await score.titleFilenameSafe()}_${req.params.eid || "FULLSCORE"}.musicxml`);
res.contentType("application/xml");
res.send(mxml);
// Send it off.
res.setHeader("Content-Disposition", `attachement; filename=${await score.titleFilenameSafe()}_${req.params.eid || "FULLSCORE"}.mxl`);
res.contentType("application/vnd.recordare.musicxml");
res.send(Buffer.from(mxml));
} else {
const mxml = await (score.saveXml());

// Send it off.
res.setHeader("Content-Disposition", `attachement; filename=${await score.titleFilenameSafe()}_${req.params.eid || "FULLSCORE"}.musicxml`);
res.contentType("application/xml");
res.send(mxml);
}

score.destroy();
}) as RequestHandler;
3 changes: 3 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ app.post("/midi/:eid", midi);
app.post("/mxml", mxml);
app.post("/mxml/:eid", mxml);

app.post("/mmxl", mxml);
app.post("/mmxl/:eid", mxml);

// Listen.
function listen() {
server.listen(3000, () => {
Expand Down

0 comments on commit 4b6db03

Please sign in to comment.