dingus.js 511 B

12345678910111213141516171819
  1. import { marked } from '../lib/marked.esm.js';
  2. import pkg from '../package.json' with { type: 'json' };
  3. const version = pkg.version;
  4. const name = 'Marked';
  5. export default function dingus(req, res) {
  6. if (req.method !== 'GET') {
  7. return res.status(405).json({
  8. error: {
  9. code: 'method_not_allowed',
  10. message: 'Only GET requests are supported for this endpoint.',
  11. },
  12. });
  13. }
  14. const { text = '' } = req.query;
  15. const html = marked(text);
  16. res.json({ name, version, html });
  17. }