Skip to content

Instantly share code, notes, and snippets.

@ajcrites
Created April 4, 2018 19:34
Show Gist options
  • Save ajcrites/4709e4781f482d9ffc92fd734a2a6871 to your computer and use it in GitHub Desktop.
Save ajcrites/4709e4781f482d9ffc92fd734a2a6871 to your computer and use it in GitHub Desktop.
module.exports = (req, res, next) => {
if (!req || !req.length) {
res.status(404);
}
next();
};

Try running via npx json-server --watch db.json --middlewares 404onempty.js

{
"users": [
{ "id": 1, "username": "ajcrites", "password": "foo" }
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment