Commit Graph

1419 Commits

Author SHA1 Message Date
Rand McKinney 2522b3f15e Update favicon.js
Add basic JSdoc
2014-11-24 15:08:21 -08:00
Rand McKinney 761a819673 Update docs.json
Fix path to middleware functions.
2014-11-24 14:17:39 -08:00
Rob Halff 36e1f6840c fix jscs errors 2014-11-21 03:35:36 +01:00
Rob Halff 38757c1c88 enable jshint for tests 2014-11-21 02:57:22 +01:00
Rob Halff e8215bf954 permit some globals 2014-11-21 02:56:48 +01:00
Rob Halff a722f8c4cf 'done' is not defined 2014-11-21 02:52:11 +01:00
Rob Halff 4ee7b5f440 'memory' is already defined 2014-11-21 02:47:47 +01:00
Rob Halff 918497c365 singlequote, semicolon & /*jshint -W030 */ 2014-11-21 02:46:21 +01:00
Raymond Feng 800ce7f363 Merge tag 'v2.8.0'
2.8.0

 * Expose more loopback middleware for require (Raymond Feng)

 * Scope app middleware to a list of paths (Miroslav Bajtoš)

 * Update CONTRIBUTING.md (Alex Voitau)

 * Fix the model name for hasMany/through relation (Raymond Feng)

 * Fixing the model attach (wfgomes)

 * Minor: update jsdoc for PersistedModel.updateAll (Alex Voitau)

 * AccessToken: optional `options` in findForRequest (Miroslav Bajtoš)

 * server-app: improve jsdoc comments (Miroslav Bajtoš)

 * server-app: middleware API improvements (Miroslav Bajtoš)

 * typo of port server (wfgomes)

 * Move middleware sources to `server/middleware` (Miroslav Bajtoš)

 * app.middleware: verify serial exec of handlers (Miroslav Bajtoš)

 * Simplify `app.defineMiddlewarePhases` (Miroslav Bajtoš)

 * Make sure loopback has all properties from express (Raymond Feng)

 * Implement `app.defineMiddlewarePhases` (Miroslav Bajtoš)

 * Implement app.middlewareFromConfig (Miroslav Bajtoš)

 * middleware/token: store the token in current ctx (Miroslav Bajtoš)

 * Fix `loopback.getCurrentContext` (Miroslav Bajtoš)

 * Update chai to ^1.10.0 (Miroslav Bajtoš)

 * package: fix deps (Miroslav Bajtoš)

 * Middleware phases - initial implementation (Miroslav Bajtoš)

 * Allows ACLs/settings in model config (Raymond Feng)

 * Remove context middleware per Ritchie (Rand McKinney)

 * Add API doc for context middleware - see #337 (crandmck)

 * Update persisted-model.js (Rand McKinney)

 * rest middleware: clean up context config (Miroslav Bajtoš)

 * Move `context` example to a standalone app (Miroslav Bajtoš)

 * Enable the context middleware from loopback.rest (Raymond Feng)

 * Add context propagation middleware (Raymond Feng)

 * Changes to JSdoc comments (Rand McKinney)

 * Reorder classes alphabetically in each section (Rand McKinney)

 * common: coding style cleanup (Miroslav Bajtoš)

 * Coding style cleanup (Gruntfile, lib) (Miroslav Bajtoš)

 * Enable jscs for `lib`, fix style violations (Rob Halff)

 * Add access-context.js to API doc (Rand McKinney)

 * Remove doc for debug function (Rand McKinney)

 * Update registry.js (Rand McKinney)

 * Fix the jsdoc for User.login (Raymond Feng)

 * Deleted instantiation of new Change model. This PR removes the instantiation of a new change model as models return from Change.find are already instances of Change. This solves the duplicate Id issue #649 (Berkeley Martinez)

 * Expose path to the built-in favicon file (Miroslav Bajtoš)

 * Add API docs for `loopback.static`. (Miroslav Bajtoš)

 * Add test for `remoting.rest.supportedTypes` (Miroslav Bajtoš)

 * Revert "rest handler options" (Miroslav Bajtoš)

 * REST handler options. (Guilherme Cirne)

 * The elapsed time in milliseconds can be 0 (less than 1 ms) (Raymond Feng)
2014-11-19 11:38:59 -08:00
Raymond Feng 5526402e1c Merge branch 'release/2.8.0' into production 2014-11-19 11:38:58 -08:00
Raymond Feng 503d0144cf v2.8.0 2014-11-19 11:38:56 -08:00
Raymond Feng 62637e87d5 Merge pull request #834 from strongloop/feature/expose-loopback-middleware
Expose more loopback middleware for require
2014-11-19 11:32:57 -08:00
Raymond Feng a9b4df1f2d Expose more loopback middleware for require 2014-11-19 11:32:22 -08:00
Miroslav Bajtoš 1c1e64c09e Merge pull request #837 from strongloop/feature/scope-middleware-to-path
#794 - Scope app middleware to a list of paths
2014-11-19 19:21:34 +01:00
Miroslav Bajtoš c411fb3e40 Merge pull request #813 from strongloop/fix/AccessToken.findForRequest
AccessToken: optional `options` in findForRequest
2014-11-19 19:18:42 +01:00
Miroslav Bajtoš 2baa4b03a3 Scope app middleware to a list of paths
Add a new argument to `app.middleware` allowing developers
to restrict the middleware to a list of paths or regular expresions.

Modify `app.middlewareFromConfig` to pass `config.paths` as the second
arg of `app.middleware`.

Examples:

    // A string path (interpreted via path-to-regexp)
    app.middleware('auth', '/admin', ldapAuth);

    // A regular expression
    app.middleware('initial', /^\/~(admin|root)/, rejectWith404);

    // A list of scopes
    app.middleware('routes', ['/api', /^\/assets/.*\.json$/], foo);

    // From config
    app.middlewareFromConfig(
      handlerFactory,
      {
        phase: 'initial',
        paths: ['/scope', /^\/(a|b)/]
      });
2014-11-19 15:42:54 +01:00
Raymond Feng 768dc4a7b0 Merge pull request #822 from wfgomes/patch-2
Fixing the model attach
2014-11-18 11:08:02 -08:00
Raymond Feng bd12335542 Merge pull request #814 from strongloop/feature/fix-issue-811
Fix the model name for hasMany/through relation
2014-11-18 10:26:54 -08:00
Miroslav Bajtoš 7581ccf260 Merge pull request #796 from strongloop/feature/cleanup-middleware-config-opts
Cleanup middleware config opts
2014-11-18 19:10:07 +01:00
Raymond Feng 7a877e91fe Merge pull request #819 from BuddyHOPP/fix/jsdoc_update
Minor: update jsdoc for PersistedModel.updateAll
2014-11-17 14:04:42 -08:00
Raymond Feng d25c561b6a Merge pull request #826 from BuddyHOPP/master
Update CONTRIBUTING.md
2014-11-17 13:43:24 -08:00
Alex Voitau f17dd149d9 Update CONTRIBUTING.md 2014-11-17 12:33:06 -08:00
Raymond Feng 4c7c8901ff Fix the model name for hasMany/through relation 2014-11-17 09:44:20 -08:00
wfgomes e8cb132ed6 Fixing the model attach 2014-11-17 00:00:54 -03:00
Alex Voitau 6f1b5f61ed Minor: update jsdoc for PersistedModel.updateAll 2014-11-14 20:06:08 -08:00
Miroslav Bajtoš b2d9f662e5 Merge pull request #792 from strongloop/feature/allow-serial-phase
app.middleware: verify serial exec of handlers
2014-11-14 18:37:28 +01:00
Miroslav Bajtoš a603ffa0f5 AccessToken: optional `options` in findForRequest
Fix `AccessToken.findForRequest` to correctly handle the case when
the options argument was omitted:

    AccessToken.findForRequest(req, cb);
2014-11-14 10:42:21 +01:00
Miroslav Bajtoš 330292c7f2 server-app: improve jsdoc comments 2014-11-14 09:52:59 +01:00
Miroslav Bajtoš 7647339675 server-app: middleware API improvements
- Rename `config.config` to `config.params`
 - Modify methods to return `this` (fluent API)
2014-11-14 09:52:26 +01:00
Raymond Feng b0fc88b333 Merge pull request #795 from wfgomes/patch-1
typo of port server
2014-11-13 09:28:52 -08:00
Miroslav Bajtoš 22827b6538 Merge pull request #790 from strongloop/feature/merge-phases
Simplify `app.defineMiddlewarePhases`
2014-11-13 09:09:28 +01:00
Miroslav Bajtoš d4ec1abde0 Merge pull request #793 from strongloop/feature/move-middleware-to-conventional-location
Move middleware sources to `server/middleware`
2014-11-13 09:07:15 +01:00
wfgomes c30b18f9a5 typo of port server
typo of the console.log port server
2014-11-12 22:08:08 -03:00
Miroslav Bajtoš 7fc66a182e 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' });
2014-11-12 12:44:34 +01:00
Miroslav Bajtoš aa92412db3 app.middleware: verify serial exec of handlers
Add a test verifying that middleware handlers are executed serially.
2014-11-12 10:09:20 +01:00
Miroslav Bajtoš ae7d99682b Simplify `app.defineMiddlewarePhases`
Refactor the implementation to use the new method `phaseList.zipMerge`.

This is commit is changing the behaviour in the case when
the first new phase does not exist in the current list.

Before the change, all new phases were added just before the "routes"
phase.

After this change, new phases are added to the head of the list,
until an existing phase is encountered, at which point the regular
merge algorithm kicks in.

Example:

    app.defineMiddlewarePhases(['first', 'routes', 'subapps']);

Before the change: code throws an error - 'routes' already exists.

After the change: phases are merged with the following result:

    'first', 'initial', ..., 'routes', 'subapps', ...
2014-11-12 08:59:56 +01:00
Miroslav Bajtoš 4474f8b029 Merge pull request #786 from strongloop/feature/define-middleware-phases
Implement `app.defineMiddlewarePhases`
2014-11-12 08:16:49 +01:00
Raymond Feng bc9076595c Merge pull request #788 from strongloop/feature/fix-loopback-express
Make sure loopback has all properties from express
2014-11-11 15:50:57 -08:00
Raymond Feng f803ecec55 Make sure loopback has all properties from express 2014-11-11 11:27:39 -08:00
Miroslav Bajtoš 98d439050a Implement `app.defineMiddlewarePhases`
Implement method for registering (new) middleware phases.

 - If all names are new, then the phases are added just before
   the "routes" phase.

  - Otherwise the provided list of names is merged with the existing
   phases in such way that the order of phases is preserved.

Example

    // built-in phases:
    // initial, session, auth, parse, routes, files, final

    app.defineMiddlewarePhases('custom');
    // new list of phases
    //   initial, session, auth, parse,
    //   custom,
    //   routes, files, final

    app.defineMiddlewarePhases([
      'initial', 'postinit', 'preauth', 'routes', 'subapps'
    ]);
    // new list of phases
    //   initial,
    //   postinit, preauth,
    //   session, auth, parse, custom,
    //   routes,
    //   subapps,
    //   files, final
2014-11-11 19:45:37 +01:00
Miroslav Bajtoš beb55ee9f4 Merge pull request #787 from strongloop/feature/app-middleware-v2
Implement app.middlewareFromConfig
2014-11-11 19:41:46 +01:00
Miroslav Bajtoš 46726f969e Merge pull request #775 from strongloop/feature/save-token-in-context
middleware/token: store the token in current ctx
2014-11-11 18:48:37 +01:00
Miroslav Bajtoš 5578d59631 Implement app.middlewareFromConfig
Implement a function registering a middleware using a factory function
and a JSON config.

Example:

    app.middlewareFromConfig(compression, {
      enabled: true,
      phase: 'initial',
      config: {
        threshold: 128
      }
    });
2014-11-11 18:00:19 +01:00
Miroslav Bajtoš 038c6a454e middleware/token: store the token in current ctx 2014-11-11 11:04:41 +01:00
Miroslav Bajtoš 8f5aea3e3b Fix `loopback.getCurrentContext`
- ensure the method is always defined

 - return `null` when the context is not active
   (we are not inside a request-handling chain)
2014-11-11 11:04:41 +01:00
Miroslav Bajtoš c29ace3404 Update chai to ^1.10.0 2014-11-11 11:04:40 +01:00
Miroslav Bajtoš 6aef836372 Merge pull request #785 from strongloop/fix/phase-dep
package: fix deps
2014-11-11 08:50:12 +01:00
Miroslav Bajtoš a22474d454 package: fix deps
Move loopback-phase from "devDependencies" to "dependencies".
2014-11-11 08:41:51 +01:00
Miroslav Bajtoš 1795eed3c6 Merge pull request #767 from strongloop/feature/app-middleware
Middleware phases - initial implementation
2014-11-10 19:57:45 +01:00
Miroslav Bajtoš 4e1433b519 Middleware phases - initial implementation
Modify the app and router implementation, so that the middleware is
executed in order defined by phases.

Predefined phases:

    'initial', 'session', 'auth', 'parse', 'routes', 'files', 'final'

Methods defined via `app.use`, `app.route` and friends are executed
as the first thing in 'routes' phase.

API usage:

    app.middleware('initial', compression());
    app.middleware('initial:before', serveFavicon());
    app.middleware('files:after', loopback.urlNotFound());
    app.middleware('final:after', errorHandler());

Middleware flavours:

    // regular handler
    function handler(req, res, next) {
      // do stuff
      next();
    }

    // error handler
    function errorHandler(err, req, res, next) {
      // handle error and/or call next
      next(err);
    }
2014-11-10 19:50:58 +01:00