Skip to content

improved express handler. createExpressHandlerΒ #50

@kennylavender

Description

@kennylavender

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions