marked/api/dingus.js

20 lines
511 B
JavaScript
Raw Normal View History

2024-05-05 19:10:57 -06:00
import { marked } from '../lib/marked.esm.js';
import pkg from '../package.json' with { type: 'json' };
const version = pkg.version;
2020-08-10 10:11:14 -04:00
const name = 'Marked';
2020-08-09 13:47:05 -04:00
2022-10-30 20:26:36 -05:00
export default function dingus(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.',
},
2020-08-09 14:16:16 -04:00
});
}
const { text = '' } = req.query;
const html = marked(text);
2020-08-09 13:47:05 -04:00
res.json({ name, version, html });
2022-10-30 20:26:36 -05:00
}