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

Suggestion for how baby-loris-api should be included #6

Closed
dodev opened this issue Jul 31, 2014 · 0 comments
Closed

Suggestion for how baby-loris-api should be included #6

dodev opened this issue Jul 31, 2014 · 0 comments

Comments

@dodev
Copy link
Contributor

dodev commented Jul 31, 2014

Express 4.x provides a new instance Route which can have a middleware stack of it's own. I suggest using baby-loris-api like so:

var express = require('express');
var bodyParser = require('body-parser');
var apiMiddleware = require('baby-loris-api/lib/middleware');

var apiRouter = express.Router();
apiRouter
    .use(bodyParser.urlencoded({extended: false}))
    .use('/:method?', apiMiddleware('/home/dodev/source/metro/api/**/*.api.js'));

var app = express();
app
    .use('/api', apiRouter);

That way the middleware for the api won't be executed for the main part of the application.

@dodev dodev changed the title Suggestion for baby-loris-api should be included Suggestion for how baby-loris-api should be included Jul 31, 2014
tarmolov added a commit that referenced this issue Aug 16, 2014
tarmolov added a commit that referenced this issue Aug 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants