Move middleware sources to `server/middleware`

The new location allows developer to use the following identifiers
when loading the middleware using the new declarative style:

    app.middlewareFromConfig(
      require('loopback/server/middleware/rest'),
      { phase: 'routes' });

    app.middlewareFromConfig(
      require('loopback/server/middleware/url-not-found'),
      { phase: 'final' });
This commit is contained in:
Miroslav Bajtoš 2014-11-12 12:36:16 +01:00
parent 4474f8b029
commit 7fc66a182e
8 changed files with 13 additions and 6 deletions

View File

@ -36,6 +36,9 @@ module.exports = function(grunt) {
common: { common: {
src: ['common/**/*.js'] src: ['common/**/*.js']
}, },
server: {
src: ['server/**/*.js']
}
// TODO tests don't pass yet // TODO tests don't pass yet
// test: { // test: {
// src: ['test/**/*.js'] // src: ['test/**/*.js']
@ -44,7 +47,8 @@ module.exports = function(grunt) {
jscs: { jscs: {
gruntfile: 'Gruntfile.js', gruntfile: 'Gruntfile.js',
lib: ['lib/**/*.js'], lib: ['lib/**/*.js'],
common: ['common/**/*.js'] common: ['common/**/*.js'],
server: ['server/**/*.js']
// TODO(bajtos) - test/**/*.js // TODO(bajtos) - test/**/*.js
}, },
watch: { watch: {

View File

@ -120,13 +120,16 @@ if (loopback.isServer) {
if (loopback.isServer) { if (loopback.isServer) {
fs fs
.readdirSync(path.join(__dirname, 'middleware')) .readdirSync(path.join(__dirname, '..', 'server', 'middleware'))
.filter(function(file) { .filter(function(file) {
return file.match(/\.js$/); return file.match(/\.js$/);
}) })
.forEach(function(m) { .forEach(function(m) {
loopback[m.replace(/\.js$/, '')] = require('./middleware/' + m); loopback[m.replace(/\.js$/, '')] = require('../server/middleware/' + m);
}); });
loopback.urlNotFound = loopback['url-not-found'];
delete loopback['url-not-found'];
} }
/* /*

View File

@ -1,4 +1,4 @@
var loopback = require('../loopback'); var loopback = require('../../lib/loopback');
var juggler = require('loopback-datasource-juggler'); var juggler = require('loopback-datasource-juggler');
var remoting = require('strong-remoting'); var remoting = require('strong-remoting');
var cls = require('continuation-local-storage'); var cls = require('continuation-local-storage');

View File

@ -2,7 +2,7 @@
* Module dependencies. * Module dependencies.
*/ */
var loopback = require('../loopback'); var loopback = require('../../lib/loopback');
var async = require('async'); var async = require('async');
/*! /*!

View File

@ -2,7 +2,7 @@
* Module dependencies. * Module dependencies.
*/ */
var loopback = require('../loopback'); var loopback = require('../../lib/loopback');
var assert = require('assert'); var assert = require('assert');
/*! /*!