Skip to content

Instantly share code, notes, and snippets.

@hnry
Created August 18, 2016 15:33
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 hnry/2031dedf2b3121eb398df882ff7d0609 to your computer and use it in GitHub Desktop.
Save hnry/2031dedf2b3121eb398df882ff7d0609 to your computer and use it in GitHub Desktop.
const {response} = require("spirit").node
(handler) => {
return async (request) => {
const userExists = await calltoDB(request.user)
if (!userExists) return response("you have to login!")
return handler(request)
}
}
// manual way, mostly equivalent to the above without using response()
(handler) => {
return async (request) => {
const userExists = await calltoDB(request.user)
if (!userExists) return { status: 200, headers: {}, body: "you have to login!" }
return handler(request)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment