Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved express handler. createExpressHandler #50

Open
kennylavender opened this issue Apr 14, 2019 · 0 comments
Open

improved express handler. createExpressHandler #50

kennylavender opened this issue Apr 14, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@kennylavender
Copy link
Contributor

kennylavender commented Apr 14, 2019

See #37 for conversation.

Signature

createExpressHandler(disabledHandler: Function) => (enbaledHandler: Function) => ({ requiredFeature: String, features: [ ...Feature ]}) => void

The user can then use the more specific app.get, app.post etc. and they can still use app.use when their handlers do the method switching themselfs.

import { createExpressHandler } from '@parralleldrive/feature-toggles'

const notFoundHandler = (res, req, next) => {}

const todosHandler = (res, req, next) => {}

const features = []

app.get(
  '/todos',
  createExpressHandler(
    notFoundHandler,
    todosHandler,
    { requiredFeature: 'todos', features }
  )
)

function should be curried or auto-curried.

@kennylavender kennylavender added the enhancement New feature or request label Apr 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant