Aconex / drakov

Mock Server that implements the API Blueprint specification
MIT License
481 stars 115 forks source link

Different behaviour while used as an expressjs middleware #137

Open evanslify opened 8 years ago

evanslify commented 8 years ago

The code I'm using is from the documentation:

// api.js
var express = require('express');
var drakov = require('drakov')
var drakovMiddleware = require('drakov').middleware;
var port = process.env.PORT || 3000;
var argv = {
    sourceFiles: './api.md',
    serverPort: port,
    staticPaths: [
        'static/',
    ],
    stealthmode: false,
    delay: 0,
    drakovHeader: true,
    public: true,
    disableCORS: true
};
var app = express();
drakovMiddleware.init(app, argv, function(err, middlewareFunction) {
    if (err) {
        throw err;
    }
    app.use(middlewareFunction);
    app.listen(argv.serverPort);

});

If I run the script from commandline node api.js, no route would work but the static hosted one.
But, if I am using drakov -f api.md -p 3000 from CLI, all routes would work as expected.

yakovkhalinsky commented 8 years ago

Thanks for reporting @evanslify when I get a chance (possibly later this week) I will investigate