Node Express Kraken routing windows

232 views Asked by At

Hi I am using kraken with express on node app. I am facing problem on windows. I have a route eg 'register/:appname?' and appname is a optional param. Since kraken (as I understand well) foces directory structure for this controller it should look like this: controllers->register->:appname? am I right? If yes, this is an issue on windows because we cannot create folders with "?"

2

There are 2 answers

0
aredridel On

try controllers\register.js, with something like this:

module.exports = function (router) {
    router.get('/:appname?', function (req, res) {
    });
}

Or controllers\index.js with this:

module.exports = function (router) {
    router.get('/register/:appname?', function (req, res) {
    });
};
0
HeadCode On

Parameters in the URL are not part of the directory structure. Taking from Aredridel's example above you would do something like this:

module.exports = function (router) {
    router.get('/register/:appname?', function (req, res) {
        var app_name = req.params.appname ? req.params.appname: '';
    });
};