marked/api/dingus.js

18 lines
449 B
JavaScript
Raw Normal View History

2020-08-09 13:47:05 -04:00
const marked = require('../');
const version = require('../package.json').version;
2020-08-10 10:11:14 -04:00
const name = 'Marked';
2020-08-09 13:47:05 -04:00
module.exports = (req, res) => {
2020-08-09 14:16:16 -04:00
if (req.method !== 'GET') {
return res.status(405).json({
error: {
code: 'method_not_allowed',
message: 'Only GET requests are supported for this endpoint.'
}
});
}
const { text = '' } = req.query;
const html = marked(text);
2020-08-09 13:47:05 -04:00
res.json({ name, version, html });
2020-08-09 14:16:16 -04:00
};