Skip to content

requiring files with incorrect paths inside config/server.js fails silently #268

@davemo

Description

@davemo

When using config/server.js and the apiProxy feature to stub out API's it can be useful to put those stubs in a separate directory/file to avoid clogging up server.js. When a require statement fails to locate a path, due to a typo or non-existent file, api stubbing and proxying fails silently and express starts throwing 404's.

I'm thinking this may have something to do with watch_r being used to monitor the server.js file for changes and re-evaluate it but haven't dug into why this is.

We should see if we can make things explode loudly when requires fail in this manner.

ie:

var session = require('./stubs/PATH-with0-TYPO.js');

module.exports = {
    drawRoutes: function(app) {
        app.get('/api/session', function(req, res) {
            res.json(session);
        });
    }
};
curl -XGET http://localhost:8000/api/session
404 Not Found

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions