Skip to content

strongloop-community/loopback-example-middleware

Repository files navigation

loopback-example-middleware

$ git clone [email protected]:strongloop/loopback-example-middleware.git
$ cd loopback-example-middleware
$ npm install
$ node .

How do you serve static content via static middleware?

  1. Add static middleware to the files property in middleware.json
  2. Delete server/boot/root.js.
  3. Create client/index.html
  4. Start the server via node . and browse to localhost:3000. You should see hello world being served.

How do you create a custom error message for all errors?

  1. Create a single function that all errors are passed to.
  2. Set app.get('remoting').errorHandler to call a custom error handler.
  3. Create a custom error middleware to handle errors not thrown by the loopback.rest() middleware.

Note: you must register your custom error handler in the middleware.json config file.


More LoopBack examples