window.utility2.stateInit({"utility2":{"assetsDict":{"/assets.example.html":"\n\n
\n\n\n\nswgg\n\n\n\n\n\n\n\n\n\n\nthe greatest app in the world!
\ndownload standalone app
\n
\n\n\n\n\n
\n
\n
\n\n\n\n
\n swgg\n \n \n \n \n
\n
\n
\n \n
\n\n
\n
\n\n\n
\n\n\n\n\n\n\n\n\n\n\n\n\n","/assets.example.js":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/*\nexample.js\n\nthis script will run a web-demo of swgg\n\ninstruction\n 1. save this script as example.js\n 2. run the shell command:\n $ npm install swgg && PORT=8081 node example.js\n 3. open a browser to http://127.0.0.1:8081 and play with the web-demo\n 4. edit this script to suit your needs\n*/\n\n\n\n/* istanbul instrument in package swgg */\n/* jslint-utility2 */\n/*jslint\n bitwise: true,\n browser: true,\n maxerr: 4,\n maxlen: 100,\n node: true,\n nomen: true,\n regexp: true,\n stupid: true\n*/\n(function () {\n 'use strict';\n var local;\n\n\n\n // run shared js-env code - init-before\n (function () {\n // init local\n local = {};\n // init isBrowser\n local.isBrowser = typeof window === \"object\" &&\n typeof window.XMLHttpRequest === \"function\" &&\n window.document &&\n typeof window.document.querySelectorAll === \"function\";\n // init global\n local.global = local.isBrowser\n ? window\n : global;\n // re-init local\n local = local.global.utility2_rollup || (local.isBrowser\n ? local.global.utility2_swgg\n : global.utility2_moduleExports);\n // init exports\n local.global.local = local;\n // init assets\n local.assetsDict['/assets.swgg.swagger.json'] =\n local.assetsDict['/assets.swgg.swagger.petstore.json'];\n // load db\n local.db.dbLoad(function () {\n console.error('db loaded from ' + local.storageDir);\n });\n }());\n\n\n\n // run shared js-env code - function\n (function () {\n local.middlewareCrudCustom = function (request, response, nextMiddleware) {\n /*\n * this function will run the middleware that will run custom-crud-operations\n */\n var crud, options, result;\n options = {};\n local.onNext(options, function (error, data) {\n switch (options.modeNext) {\n case 1:\n crud = request.swgg.crud;\n switch (crud.crudType[0]) {\n // coverage-hack - test error handling-behavior\n case 'crudErrorPre':\n options.onNext(local.errorDefault);\n return;\n case 'getInventory':\n crud.dbTable.crudGetManyByQuery({\n query: {},\n projection: ['status']\n }, options.onNext);\n break;\n default:\n options.modeNext = Infinity;\n options.onNext();\n }\n break;\n case 2:\n switch (crud.crudType[0]) {\n case 'getInventory':\n result = {};\n data.forEach(function (element) {\n result[element.status] = result[element.status] || 0;\n result[element.status] += 1;\n });\n options.onNext(null, result);\n break;\n }\n break;\n case 3:\n local.swgg.serverRespondJsonapi(request, response, error, data);\n break;\n default:\n nextMiddleware(error, data);\n }\n });\n options.modeNext = 0;\n options.onNext();\n };\n\n local.middlewareInitCustom = function (request, response, nextMiddleware) {\n /*\n * this function will run the middleware that will custom-init the request and response\n */\n // enable cors\n // https://en.wikipedia.org/wiki/Cross-origin_resource_sharing\n response.setHeader(\n 'Access-Control-Allow-Methods',\n 'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'\n );\n response.setHeader('Access-Control-Allow-Origin', '*');\n // init content-type\n response.setHeader('Content-Type', 'application/json; charset=UTF-8');\n // ignore .map files\n if (request.urlParsed.pathname.slice(-4) === '.map') {\n local.serverRespondDefault(request, response, 404);\n return;\n }\n nextMiddleware();\n };\n }());\n\n\n\n // run shared js-env code - init-after\n (function () {\n // init assets\n /* jslint-ignore-begin */\n local.assetsDict['/assets.index.template.html'] = local.assetsDict['/assets.swgg.html']\n .replace((/\\n<\\/script>\\n/), '\\\n\\n\\\n\\n\\\n\\n\\\n{{env.npm_package_description}}
\\n\\\ndownload standalone app
\\n\\\n
\\n\\\n\\n\\\n\\n\\\n\\n\\\n\\n\\\n
\\n\\\n
\\n\\\n
\\n\\\n\\n\\\n')\n .replace('assets.swgg.swagger.json', 'assets.swgg.swagger.server.json')\n .replace((/\\n\\n\\\n{{#unless isRollup}}\\n\\\nutility2-comment -->\\n\\\n\\n\\\n\\n\\\n\\n\\\n\\n\\\n\\n\\\n\\n\\\n\\n\\\n\\n\\\n