UNPKG

laas-admin-api

Version:

LaaS admin api server.

39 lines (33 loc) 839 B
(function () { 'use strict'; exports.create = create; /** * Create documentation for the application. * * @param {Object} raml * @param {Function} done * @return {Function} */ function create (raml, done) { var raml2html = require('raml2html'); var config = raml2html.getDefaultConfig(true); return raml2html.render(raml, config, function (html) { return done(null, html); }, done); } exports.serve = serve; /** * Serve html to a http request. * * @param {String} html * @return {Function} */ function serve (html) { var contentLength = Buffer.byteLength(html); return function (req, res) { res.setHeader('Content-Type', 'text/html; charset=utf-8'); res.setHeader('Content-Length', contentLength); res.end(html); }; } })();