Skip to content

Instantly share code, notes, and snippets.

@jcenturion
Last active September 12, 2017 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcenturion/6ca70a7bb74748d3e3083de5f8a147ae to your computer and use it in GitHub Desktop.
Save jcenturion/6ca70a7bb74748d3e3083de5f8a147ae to your computer and use it in GitHub Desktop.
const yaml = require('js-yaml');
module.exports = (options, cb) => {
return cb(null, (ctx, req, res) => {
if (req.method !== 'GET') {
res.writeHead(405);
return res.end();
}
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify(yaml.load(options.script)));
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment