summaryrefslogtreecommitdiffstats
path: root/common/src/main/webapp/usage guide/appserver/node_modules/body-parser/index.js
diff options
context:
space:
mode:
authorSeshu-Kumar-M <seshu.kumar.m@huawei.com>2017-02-01 21:37:15 +0530
committerSeshu-Kumar-M <seshu.kumar.m@huawei.com>2017-02-01 21:37:15 +0530
commitf205e8d8493616238ca5372d3ea042bbb0472bd1 (patch)
tree920638c3f1f017fff01ec525189d00230e0f4438 /common/src/main/webapp/usage guide/appserver/node_modules/body-parser/index.js
parent6f01a8756fe38c0d6565c369005142adda4b9b57 (diff)
Sample code of Widgets
Code with the sample usage of the OPEN-O GUI Framework for widgets Issue-Id : CLIENT-11 Change-Id: If8c16829a048221e213d44c8e752bbd4a4622632 Signed-off-by: Seshu-Kumar-M <seshu.kumar.m@huawei.com>
Diffstat (limited to 'common/src/main/webapp/usage guide/appserver/node_modules/body-parser/index.js')
-rw-r--r--common/src/main/webapp/usage guide/appserver/node_modules/body-parser/index.js157
1 files changed, 157 insertions, 0 deletions
diff --git a/common/src/main/webapp/usage guide/appserver/node_modules/body-parser/index.js b/common/src/main/webapp/usage guide/appserver/node_modules/body-parser/index.js
new file mode 100644
index 00000000..93c3a1ff
--- /dev/null
+++ b/common/src/main/webapp/usage guide/appserver/node_modules/body-parser/index.js
@@ -0,0 +1,157 @@
+/*!
+ * body-parser
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+'use strict'
+
+/**
+ * Module dependencies.
+ * @private
+ */
+
+var deprecate = require('depd')('body-parser')
+
+/**
+ * Cache of loaded parsers.
+ * @private
+ */
+
+var parsers = Object.create(null)
+
+/**
+ * @typedef Parsers
+ * @type {function}
+ * @property {function} json
+ * @property {function} raw
+ * @property {function} text
+ * @property {function} urlencoded
+ */
+
+/**
+ * Module exports.
+ * @type {Parsers}
+ */
+
+exports = module.exports = deprecate.function(bodyParser,
+ 'bodyParser: use individual json/urlencoded middlewares')
+
+/**
+ * JSON parser.
+ * @public
+ */
+
+Object.defineProperty(exports, 'json', {
+ configurable: true,
+ enumerable: true,
+ get: createParserGetter('json')
+})
+
+/**
+ * Raw parser.
+ * @public
+ */
+
+Object.defineProperty(exports, 'raw', {
+ configurable: true,
+ enumerable: true,
+ get: createParserGetter('raw')
+})
+
+/**
+ * Text parser.
+ * @public
+ */
+
+Object.defineProperty(exports, 'text', {
+ configurable: true,
+ enumerable: true,
+ get: createParserGetter('text')
+})
+
+/**
+ * URL-encoded parser.
+ * @public
+ */
+
+Object.defineProperty(exports, 'urlencoded', {
+ configurable: true,
+ enumerable: true,
+ get: createParserGetter('urlencoded')
+})
+
+/**
+ * Create a middleware to parse json and urlencoded bodies.
+ *
+ * @param {object} [options]
+ * @return {function}
+ * @deprecated
+ * @public
+ */
+
+function bodyParser (options) {
+ var opts = {}
+
+ // exclude type option
+ if (options) {
+ for (var prop in options) {
+ if (prop !== 'type') {
+ opts[prop] = options[prop]
+ }
+ }
+ }
+
+ var _urlencoded = exports.urlencoded(opts)
+ var _json = exports.json(opts)
+
+ return function bodyParser (req, res, next) {
+ _json(req, res, function (err) {
+ if (err) return next(err)
+ _urlencoded(req, res, next)
+ })
+ }
+}
+
+/**
+ * Create a getter for loading a parser.
+ * @private
+ */
+
+function createParserGetter (name) {
+ return function get () {
+ return loadParser(name)
+ }
+}
+
+/**
+ * Load a parser module.
+ * @private
+ */
+
+function loadParser (parserName) {
+ var parser = parsers[parserName]
+
+ if (parser !== undefined) {
+ return parser
+ }
+
+ // this uses a switch for static require analysis
+ switch (parserName) {
+ case 'json':
+ parser = require('./lib/types/json')
+ break
+ case 'raw':
+ parser = require('./lib/types/raw')
+ break
+ case 'text':
+ parser = require('./lib/types/text')
+ break
+ case 'urlencoded':
+ parser = require('./lib/types/urlencoded')
+ break
+ }
+
+ // store to prevent invoking require()
+ return (parsers[parserName] = parser)
+}