#!/usr/bin/env node /* eslint-env es6 */ /* eslint-disable no-console */ 'use strict'; const md = require('../')('commonmark'); const app = require('express')(); const version = require('../package.json').version; const banner = `
markdown-it responder for Babelmark2
Usage: /?text=...
`; app.set('port', (process.env.PORT || 5000)); app.get('/', function (req, res) { if (typeof req.query.text === 'string') { res.json({ name: 'markdown-it', html: md.render(req.query.text.slice(0, 1000)), version }); return; } res.setHeader('Content-Type', 'text/html'); res.send(banner); }); app.listen(app.get('port'), function () { console.log(`Node app is running on port ${app.get('port')}`); });