-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathexpress.ts
More file actions
27 lines (24 loc) · 819 Bytes
/
express.ts
File metadata and controls
27 lines (24 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';
const exportMarkdown = require('./exportMarkdown');
exports.expressCreateServer = (hookName, {app}) => {
app.get('/p/:padId/export/markdown', async (req: any, res: any, next: any) => {
try {
const {padId} = req.params;
res.attachment(`${padId}.md`);
res.contentType('plain/text');
res.send(await exportMarkdown.getPadMarkdownDocument(padId));
} catch (err) {
next(err || new Error(err));
}
});
app.get('/p/:padId/:revNum/export/markdown', async (req: any, res: any, next: any) => {
try {
const {padId, revNum} = req.params;
res.attachment(`${padId}.md`);
res.contentType('plain/text');
res.send(await exportMarkdown.getPadMarkdownDocument(padId, revNum));
} catch (err) {
next(err || new Error(err));
}
});
};