Skip to content

Instantly share code, notes, and snippets.

@Shuumatsu
Last active March 27, 2017 06:29
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 Shuumatsu/79823fb6223c11dbeaec0b17cfdb43a4 to your computer and use it in GitHub Desktop.
Save Shuumatsu/79823fb6223c11dbeaec0b17cfdb43a4 to your computer and use it in GitHub Desktop.
fn = compose(this.middleware);
if (!this.listeners('error').length) this.on('error', this.onerror);
const handleRequest = (req, res) => {
res.statusCode = 404;
const ctx = this.createContext(req, res);
const onerror = err => ctx.onerror(err);
const handleResponse = () => respond(ctx);
onFinished(res, onerror);
fn(ctx).then(handleResponse).catch(onerror);
};
return handleRequest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment