From 3cdbd274d2d472210cd7b783a40434c6ca21b482 Mon Sep 17 00:00:00 2001 From: crandmck Date: Thu, 6 Nov 2014 14:07:34 -0800 Subject: [PATCH] Add API doc for context middleware - see #337 --- docs.json | 1 + lib/middleware/context.js | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs.json b/docs.json index 478a791d..66031308 100644 --- a/docs.json +++ b/docs.json @@ -9,6 +9,7 @@ "lib/model.js", "lib/persisted-model.js", { "title": "Middleware", "depth": 2 }, + "lib/middleware/context.js", "lib/middleware/rest.js", "lib/middleware/static.js", "lib/middleware/status.js", diff --git a/lib/middleware/context.js b/lib/middleware/context.js index 275a78d9..7b21561d 100644 --- a/lib/middleware/context.js +++ b/lib/middleware/context.js @@ -25,6 +25,20 @@ function createContext(scope) { return ns; } +/** + * Context middleware. + * ```js + * var app = loopback(); + * app.use(loopback.context(options); + * app.use(loopback.rest()); + * app.listen(); + * ``` + * @options {Object} [options] Options for context + * @property {String} name Context scope name. + * @property {Boolean} enableHttpContext Whether HTTP context is enabled. Default is false. + * @header loopback.context([options]) + */ + function context(options) { options = options || {}; var scope = options.name || name; @@ -62,7 +76,7 @@ function ChainedContext(child, parent) { this.parent = parent; } -/** +/*! * Get the value by name from the context. If it doesn't exist in the child * context, try the parent one * @param {String} name Name of the context property