From 851d6f6b70d0d821d56fc99b4c0506918705a2e9 Mon Sep 17 00:00:00 2001 From: Hage Yaapa Date: Sun, 31 May 2015 17:25:45 +0530 Subject: [PATCH] use middleware.json --- example-2.0/server/config.json | 1 + example-2.0/server/middleware.json | 28 ++++++++++++++++++++++++++++ example-2.0/server/server.js | 23 ----------------------- 3 files changed, 29 insertions(+), 23 deletions(-) create mode 100644 example-2.0/server/middleware.json diff --git a/example-2.0/server/config.json b/example-2.0/server/config.json index 22152ca..c589cb4 100644 --- a/example-2.0/server/config.json +++ b/example-2.0/server/config.json @@ -1,4 +1,5 @@ { + "legacyExplorer": false, "restApiRoot": "/api", "host": "0.0.0.0", "port": 3000, diff --git a/example-2.0/server/middleware.json b/example-2.0/server/middleware.json new file mode 100644 index 0000000..5a93e0f --- /dev/null +++ b/example-2.0/server/middleware.json @@ -0,0 +1,28 @@ +{ + "initial:before": { + "loopback#favicon": {}, + "loopback#compress": {} + }, + "initial": { + "compression": {} + }, + "session": { + }, + "auth": { + }, + "parse": { + }, + "routes": { + }, + "files": { + "loopback#static": { + "params": "$!../client" + } + }, + "final": { + "loopback#urlNotFound": {} + }, + "final:after": { + "errorhandler": {} + } +} diff --git a/example-2.0/server/server.js b/example-2.0/server/server.js index 7578866..53ba98e 100644 --- a/example-2.0/server/server.js +++ b/example-2.0/server/server.js @@ -3,32 +3,9 @@ var boot = require('loopback-boot'); var app = module.exports = loopback(); -// Set up the /favicon.ico -app.use(loopback.favicon()); - -// request pre-processing middleware -app.use(loopback.compress()); - -// -- Add your pre-processing middleware here -- - // boot scripts mount components like REST API boot(app, __dirname); -// -- Mount static files here-- -// All static middleware should be registered at the end, as all requests -// passing the static middleware are hitting the file system -// Example: -var path = require('path'); -app.use(loopback.static(path.resolve(__dirname, '../client'))); - -// Requests that get this far won't be handled -// by any middleware. Convert them into a 404 error -// that will be handled later down the chain. -app.use(loopback.urlNotFound()); - -// The ultimate error handler. -app.use(loopback.errorHandler()); - app.start = function() { // start the web server return app.listen(function() {