Skip to content

Commit 342863c

Browse files
committed
chore: Prepared ep_markdown for express 5
1 parent 7b02d50 commit 342863c

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

ep_markdown/express.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,25 @@
33
const exportMarkdown = require('./exportMarkdown');
44

55
exports.expressCreateServer = (hookName, {app}) => {
6-
app.get('/p/:padId/:revNum?/export/markdown', (req, res, next) => {
7-
(async () => {
6+
app.get('/p/:padId/export/markdown', async (req: any, res: any, next: any) => {
7+
try {
8+
const {padId} = req.params;
9+
res.attachment(`${padId}.md`);
10+
res.contentType('plain/text');
11+
res.send(await exportMarkdown.getPadMarkdownDocument(padId));
12+
} catch (err) {
13+
next(err || new Error(err));
14+
}
15+
});
16+
17+
app.get('/p/:padId/:revNum/export/markdown', async (req: any, res: any, next: any) => {
18+
try {
819
const {padId, revNum} = req.params;
920
res.attachment(`${padId}.md`);
1021
res.contentType('plain/text');
1122
res.send(await exportMarkdown.getPadMarkdownDocument(padId, revNum));
12-
})().catch((err) => next(err || new Error(err)));
23+
} catch (err) {
24+
next(err || new Error(err));
25+
}
1326
});
1427
};

0 commit comments

Comments
 (0)