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

New API considerations #2

Open
DesignByOnyx opened this issue Mar 24, 2017 · 0 comments
Open

New API considerations #2

DesignByOnyx opened this issue Mar 24, 2017 · 0 comments

Comments

@DesignByOnyx
Copy link
Owner

DesignByOnyx commented Mar 24, 2017

I am not very pleased with the current API and would love suggestions.

Option 1:
Decorate the app object with conditional sugar. This is kind of controversial, but it reads well:

const app = express();
conditional.decorate(app);
	
app
  .if(() => true)
	.use(middleware1, middleware2, ...)
  .elseif(() = true)
  	.use(middleware3, middleware4, ...)
  .else()
  	.use(middleware5)
  .endif()
  .use(someOtherMiddleware);

Option 2:
Create an expressive API, similar to above. I'm already leaning towards this.

const app = express();
	
app.use(conditional
    .if(() => true, [ 
        middleware 
    ]).esleif(() => true, [ 
        middleware 
    ]).else([ 
        middleware 
    ])
);

I am open to anything. Please provide full examples if you can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant