gina 0.1.1-alpha.98 → 0.1.2-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README-4Contributors.md +30 -0
- package/README.md +125 -39
- package/bin/cli +130 -41
- package/bin/cli-debug +46 -15
- package/bin/cmd +63 -41
- package/bin/gina +57 -49
- package/framework/{v0.1.1-alpha.98/lib/inherits → v0.1.2-alpha.1}/LICENSE +1 -1
- package/framework/v0.1.2-alpha.1/VERSION +1 -0
- package/framework/{v0.1.1-alpha.98/core/asset/js/plugin/readme.md → v0.1.2-alpha.1/core/asset/plugin/README.md} +34 -12
- package/framework/v0.1.2-alpha.1/core/asset/plugin/dist/vendor/gina/css/gina.min.css +1 -0
- package/framework/v0.1.2-alpha.1/core/asset/plugin/dist/vendor/gina/css/gina.min.css.map +1 -0
- package/framework/v0.1.2-alpha.1/core/asset/plugin/dist/vendor/gina/html/toolbar.html +251 -0
- package/framework/{v0.1.1-alpha.98/core/asset/js/plugin/dist → v0.1.2-alpha.1/core/asset/plugin/dist/vendor/gina/js}/gina.js +4588 -3416
- package/framework/v0.1.2-alpha.1/core/asset/plugin/dist/vendor/gina/js/gina.min.js +765 -0
- package/framework/v0.1.2-alpha.1/core/asset/plugin/dist/vendor/gina/js/gina.min.js.map +8 -0
- package/framework/v0.1.2-alpha.1/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js +7 -0
- package/framework/v0.1.2-alpha.1/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js.map +8 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/config.js +315 -131
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/connectors/couchbase/index.js +460 -274
- package/framework/v0.1.2-alpha.1/core/connectors/couchbase/lib/connector.js +22 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/connectors/couchbase/lib/connector.v2.js +51 -51
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/connectors/couchbase/lib/connector.v3.js +51 -51
- package/framework/v0.1.2-alpha.1/core/connectors/couchbase/lib/connector.v4.js +384 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/connectors/couchbase/lib/n1ql.js +3 -2
- package/framework/v0.1.2-alpha.1/core/connectors/couchbase/lib/session-store.js +22 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/connectors/couchbase/lib/session-store.v3.js +12 -12
- package/framework/v0.1.2-alpha.1/core/connectors/couchbase/lib/session-store.v4.js +361 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/controller/controller.js +1351 -902
- package/framework/v0.1.2-alpha.1/core/controller/index.js +23 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/dev/index.js +1 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/dev/lib/class.js +1 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/dev/lib/factory.js +2 -2
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/gna.js +48 -24
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/locales/README.md +5 -0
- package/framework/v0.1.2-alpha.1/core/locales/dist/region/en.json +5727 -0
- package/framework/v0.1.2-alpha.1/core/locales/dist/region/fr.json +11452 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/locales/index.js +2 -2
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/locales/src/make.js +39 -41
- package/framework/v0.1.2-alpha.1/core/locales/src/resources/region.mapping.json +43 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/model/entity.js +87 -67
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/model/index.js +16 -16
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/model/template/entityFactory.js +1 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/model/template/index.js +17 -15
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/plugins/index.js +1 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/plugins/lib/file/package.json +1 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/plugins/lib/intl/package.json +1 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/plugins/lib/intl/src/main.js +5 -5
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/plugins/lib/storage/package.json +1 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/plugins/lib/storage/src/main.js +6 -5
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/plugins/lib/validator/package.json +1 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/plugins/lib/validator/src/form-validator.js +404 -300
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/plugins/lib/validator/src/main.js +1384 -1314
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/router.js +221 -122
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/server.express.js +69 -65
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/server.isaac.js +274 -180
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/server.js +710 -615
- package/framework/v0.1.2-alpha.1/core/template/boilerplate/bundle/config/settings.json +12 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/boilerplate/bundle/config/settings.server.json +4 -4
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/boilerplate/bundle/config/templates.json +4 -4
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/boilerplate/bundle/controllers/controller.content.js +1 -1
- package/framework/v0.1.2-alpha.1/core/template/boilerplate/bundle/controllers/setup.js +111 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/boilerplate/bundle/index.js +13 -1
- package/framework/v0.1.2-alpha.1/core/template/boilerplate/bundle_templates/html/content/homepage.html +8 -0
- package/framework/v0.1.2-alpha.1/core/template/boilerplate/bundle_templates/html/includes/error-msg-noscript.html +11 -0
- package/framework/v0.1.2-alpha.1/core/template/boilerplate/bundle_templates/html/includes/error-msg-outdated-browser.html +8 -0
- package/framework/{v0.1.1-alpha.98/core/template/boilerplate/bundle_templates/html/layout → v0.1.2-alpha.1/core/template/boilerplate/bundle_templates/html/layouts}/main.html +10 -3
- package/framework/v0.1.2-alpha.1/core/template/command/gina.bat.tpl +8 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/command/gina.tpl +4 -4
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/conf/env.json +12 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/conf/manifest.json +2 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/conf/package.json +2 -2
- package/framework/v0.1.2-alpha.1/core/template/conf/statics.json +12 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/conf/templates.json +9 -9
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/helpers/console.js +3 -3
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/helpers/context.js +233 -75
- package/framework/v0.1.2-alpha.1/helpers/data/LICENSE +9 -0
- package/framework/v0.1.2-alpha.1/helpers/data/README.md +12 -0
- package/framework/v0.1.2-alpha.1/helpers/data/package.json +20 -0
- package/framework/v0.1.2-alpha.1/helpers/data/src/main.js +295 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/helpers/dateFormat.js +9 -7
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/helpers/index.js +13 -8
- package/framework/v0.1.2-alpha.1/helpers/json/LICENSE +9 -0
- package/framework/v0.1.2-alpha.1/helpers/json/README.md +12 -0
- package/framework/{v0.1.1-alpha.98/helpers/plugins → v0.1.2-alpha.1/helpers/json}/package.json +2 -2
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/helpers/json/src/main.js +33 -28
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/helpers/path.js +97 -22
- package/framework/{v0.1.1-alpha.98/helpers/json → v0.1.2-alpha.1/helpers/plugins}/package.json +2 -2
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/helpers/plugins/src/api-error.js +23 -23
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/helpers/plugins/src/main.js +3 -3
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/helpers/prototypes.js +46 -38
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/helpers/text.js +2 -2
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/archiver/package.json +1 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/archiver/src/dep/jszip.min.js +3 -3
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/archiver/src/main.js +183 -168
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/aliases.json +4 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/bundle/add.js +84 -28
- package/framework/v0.1.2-alpha.1/lib/cmd/bundle/arguments.json +8 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/bundle/help.txt +4 -2
- package/framework/v0.1.2-alpha.1/lib/cmd/bundle/list.js +175 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/bundle/remove.js +39 -27
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/bundle/restart.js +14 -8
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/bundle/start.js +283 -49
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/bundle/stop.js +93 -74
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/env/add.js +87 -49
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/env/list.js +26 -4
- package/framework/{v0.1.1-alpha.98/lib/cmd/scope → v0.1.2-alpha.1/lib/cmd/env}/remove.js +29 -24
- package/framework/v0.1.2-alpha.1/lib/cmd/env/use.js +106 -0
- package/framework/v0.1.2-alpha.1/lib/cmd/framework/build.js +93 -0
- package/framework/v0.1.2-alpha.1/lib/cmd/framework/init.js +932 -0
- package/framework/v0.1.2-alpha.1/lib/cmd/framework/link-node-modules.js +123 -0
- package/framework/v0.1.2-alpha.1/lib/cmd/framework/link.js +132 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/framework/open.js +25 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/framework/restart.js +78 -26
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/framework/set.js +120 -40
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/framework/start.js +49 -20
- package/framework/v0.1.2-alpha.1/lib/cmd/framework/status.js +144 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/framework/stop.js +64 -31
- package/framework/v0.1.2-alpha.1/lib/cmd/framework/tail.js +303 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/framework/version.js +19 -4
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/helper.js +357 -53
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/index.js +23 -23
- package/framework/v0.1.2-alpha.1/lib/cmd/port/inc/scan.js +142 -0
- package/framework/v0.1.2-alpha.1/lib/cmd/port/list.js +464 -0
- package/framework/v0.1.2-alpha.1/lib/cmd/port/reset.js +417 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/project/add.js +344 -157
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/project/arguments.json +2 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/project/build.js +28 -28
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/project/help.txt +7 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/project/list.js +22 -2
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/project/remove.js +19 -17
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/project/rename.js +11 -11
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/protocol/set.js +260 -211
- package/framework/v0.1.2-alpha.1/lib/cmd/scope/add.js +129 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/scope/help.txt +4 -4
- package/framework/{v0.1.1-alpha.98/lib/cmd/env/use.js → v0.1.2-alpha.1/lib/cmd/scope/link-production.js} +22 -21
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/scope/list.js +34 -11
- package/framework/v0.1.2-alpha.1/lib/cmd/scope/remove.js +122 -0
- package/framework/v0.1.2-alpha.1/lib/cmd/scope/use.js +68 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/view/add.js +35 -10
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/collection/package.json +1 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/collection/src/main.js +247 -244
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/config.js +33 -31
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cron/package.json +1 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cron/src/main.js +16 -11
- package/framework/v0.1.2-alpha.1/lib/domain/LICENSE +9 -0
- package/framework/v0.1.2-alpha.1/lib/domain/README.md +46 -0
- package/framework/v0.1.2-alpha.1/lib/domain/dist/public_suffix_list.dat +14186 -0
- package/framework/v0.1.2-alpha.1/lib/domain/package.json +20 -0
- package/framework/v0.1.2-alpha.1/lib/domain/src/main.js +442 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/generator/index.js +5 -5
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/index.js +3 -2
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1/lib/inherits}/LICENSE +1 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/inherits/README.md +2 -2
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/inherits/package.json +3 -4
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/inherits/src/main.js +3 -3
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/logger/package.json +2 -2
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/logger/src/containers/default/index.js +15 -2
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/logger/src/containers/file/index.js +109 -14
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/logger/src/containers/mq/index.js +12 -3
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/logger/src/containers/mq/listener.js +29 -21
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/logger/src/containers/mq/speaker.js +33 -4
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/logger/src/helper.js +22 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/logger/src/main.js +36 -9
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/math/index.js +9 -9
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/merge/README.md +2 -2
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/merge/package.json +1 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/merge/src/main.js +118 -91
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/model.js +10 -10
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/proc.js +92 -49
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/routing/package.json +1 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/routing/src/main.js +377 -420
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/session-store.js +13 -7
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/shell.js +3 -3
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/swig-filters/package.json +1 -1
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/swig-filters/src/main.js +140 -119
- package/framework/v0.1.2-alpha.1/lib/url/README.md +0 -0
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/validator.js +2 -2
- package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/package.json +1 -1
- package/package.json +10 -10
- package/resources/home/main.json +39 -5
- package/resources/home/settings.json +8 -0
- package/resources/package.json.template +1 -1
- package/script/lib.js +0 -0
- package/script/post_install.js +180 -90
- package/script/pre_install.js +97 -13
- package/services/.gna/67fdf1b224a2ed5597e63d4b64283834468e05e3.txt +0 -0
- package/services/.gna/arch +1 -0
- package/services/.gna/locals.json +14 -0
- package/services/.gna/platform +1 -0
- package/services/configure +6 -0
- package/services/env.json +18 -0
- package/services/manifest.json +30 -0
- package/services/package.json +11 -0
- package/services/src/proxy/config/app.json +6 -0
- package/services/src/proxy/config/routing.json +11 -0
- package/services/src/proxy/config/settings.json +9 -0
- package/services/src/proxy/config/settings.server.json +31 -0
- package/services/src/proxy/config/statics.json +3 -0
- package/services/src/proxy/controllers/controller.content.js +58 -0
- package/services/src/proxy/controllers/controller.js +30 -0
- package/{framework/v0.1.1-alpha.98/core/template/boilerplate/bundle → services/src/proxy}/controllers/setup.js +14 -14
- package/services/src/proxy/index.js +31 -0
- package/services/src/proxy/lib/domain/README.md +48 -0
- package/services/src/proxy/lib/domain/src/config/public_suffix_list.dat +14186 -0
- package/services/src/toolbar/config/app.json +6 -0
- package/services/src/toolbar/config/routing.json +11 -0
- package/{framework/v0.1.1-alpha.98/core/template/boilerplate/bundle → services/src/toolbar}/config/settings.json +0 -0
- package/services/src/toolbar/config/settings.server.json +30 -0
- package/services/src/toolbar/controllers/controller.content.js +39 -0
- package/services/src/toolbar/controllers/controller.js +30 -0
- package/services/src/toolbar/controllers/setup.js +111 -0
- package/services/src/toolbar/index.js +43 -0
- package/utils/helper.js +25 -156
- package/utils/prototypes.js +9 -9
- package/utils/prototypes.json_clone.js +70 -37
- package/framework/v0.1.1-alpha.98/VERSION +0 -1
- package/framework/v0.1.1-alpha.98/core/asset/js/plugin/dist/gina.js.map +0 -56
- package/framework/v0.1.1-alpha.98/core/asset/js/plugin/dist/gina.min.css +0 -1
- package/framework/v0.1.1-alpha.98/core/asset/js/plugin/dist/gina.min.css.map +0 -1
- package/framework/v0.1.1-alpha.98/core/asset/js/plugin/dist/gina.min.js +0 -736
- package/framework/v0.1.1-alpha.98/core/asset/js/plugin/dist/gina.min.js.map +0 -56
- package/framework/v0.1.1-alpha.98/core/asset/js/plugin/dist/gina.onload.min.js +0 -5
- package/framework/v0.1.1-alpha.98/core/asset/js/plugin/dist/gina.onload.min.js.map +0 -8
- package/framework/v0.1.1-alpha.98/core/connectors/couchbase/lib/connector.js +0 -20
- package/framework/v0.1.1-alpha.98/core/connectors/couchbase/lib/session-store.js +0 -21
- package/framework/v0.1.1-alpha.98/core/controller/index.js +0 -27
- package/framework/v0.1.1-alpha.98/core/locales/dist/region/en.json +0 -9492
- package/framework/v0.1.1-alpha.98/core/locales/dist/region/fr.json +0 -9492
- package/framework/v0.1.1-alpha.98/core/locales/src/resources/region.mapping.json +0 -28
- package/framework/v0.1.1-alpha.98/core/template/boilerplate/bundle_templates/html/homepage.html +0 -4
- package/framework/v0.1.1-alpha.98/core/template/conf/statics.json +0 -10
- package/framework/v0.1.1-alpha.98/lib/cmd/bundle/arguments.json +0 -4
- package/framework/v0.1.1-alpha.98/lib/cmd/bundle/list.js +0 -129
- package/framework/v0.1.1-alpha.98/lib/cmd/env/remove.js +0 -150
- package/framework/v0.1.1-alpha.98/lib/cmd/framework/init.js +0 -541
- package/framework/v0.1.1-alpha.98/lib/cmd/framework/status.js +0 -72
- package/framework/v0.1.1-alpha.98/lib/cmd/framework/tail.js +0 -184
- package/framework/v0.1.1-alpha.98/lib/cmd/port/inc/scan.js +0 -108
- package/framework/v0.1.1-alpha.98/lib/cmd/port/list.js +0 -176
- package/framework/v0.1.1-alpha.98/lib/cmd/scope/set.js +0 -57
- package/framework/v0.1.1-alpha.98/lib/cmd/scope/unset.js +0 -44
- package/framework/v0.1.1-alpha.98/lib/cmd/scope/use.js +0 -79
- package/script/post_publish.js +0 -185
- package/script/prepare_version.js +0 -552
- /package/{framework/v0.1.1-alpha.98/core/template/command/gina.bat.tpl → bin/gina.bat} +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/AUTHORS +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/asset/html/nolayout.html +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/asset/html/static.html +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/asset/img/android-chrome-192x192.png +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/asset/img/android-chrome-512x512.png +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/asset/img/apple-touch-icon.png +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/asset/img/favicon-16x16.png +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/asset/img/favicon-32x32.png +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/asset/img/favicon.ico +0 -0
- /package/framework/{v0.1.1-alpha.98/core/asset/js → v0.1.2-alpha.1/core/asset}/plugin/uuid.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/connectors/couchbase/lib/session-store.v2.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/controller/controller.framework.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/deps/busboy/.travis.yml +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/deps/busboy/LICENSE +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/deps/busboy/README.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/deps/busboy/deps/encoding/encoding-indexes.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/deps/busboy/deps/encoding/encoding.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/deps/busboy/lib/main.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/deps/busboy/lib/types/multipart.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/deps/busboy/lib/types/urlencoded.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/deps/busboy/lib/utils.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/deps/busboy/package.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/deps/swig-client/swig-2.0.0.min.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/dev/lib/tools.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/locales/currency.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/locales/dist/language/en.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/locales/dist/language/fr.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/locales/src/resources/currency.csv +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/locales/src/resources/region.csv +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/mime.types +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/plugins/README.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/plugins/lib/file/README.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/plugins/lib/file/build.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/plugins/lib/intl/README.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/plugins/lib/intl/build.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/plugins/lib/storage/README.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/plugins/lib/storage/build.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/plugins/lib/validator/README.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/plugins/lib/validator/build.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/status.codes +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/boilerplate/bundle/config/app.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/boilerplate/bundle/config/routing.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/boilerplate/bundle/controllers/controller.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/boilerplate/bundle_namespace/controllers/controller.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/boilerplate/bundle_public/css/default.css +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/boilerplate/bundle_public/css/vendor/readme.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/boilerplate/bundle_public/favicon.ico +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/boilerplate/bundle_public/js/vendor/readme.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/boilerplate/bundle_public/readme.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/boilerplate/bundle_templates/handlers/main.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/conf/settings.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/error/client/json/401.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/error/client/json/403.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/error/client/json/404.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/error/server/html/50x.html +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/error/server/json/500.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/error/server/json/503.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/core/template/extensions/logger/config.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/helpers/plugins/README.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/helpers/task.js +0 -0
- /package/framework/{v0.1.1-alpha.98/helpers/json → v0.1.2-alpha.1/lib/archiver}/README.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/archiver/build.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/bundle/copy.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/bundle/cp.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/bundle/help.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/bundle/rename.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/bundle/rm.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/bundle/status.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/env/get.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/env/help.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/env/help.txt +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/env/link-dev.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/env/rm.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/env/set.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/env/unset.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/framework/dot.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/framework/get.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/framework/help.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/framework/help.txt +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/framework/msg.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/framework/update.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/gina-dev.1.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/gina-framework.1.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/gina.1.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/msg.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/port/help.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/port/help.txt +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/port/set.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/project/help.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/project/import.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/project/move.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/project/restart.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/project/rm.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/project/start.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/project/status.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/project/stop.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/protocol/help.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/protocol/help.txt +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/protocol/list.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/scope/help.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/scope/link-local.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cmd/scope/rm.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/collection/README.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/collection/build.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/cron/README.md +0 -0
- /package/framework/{v0.1.1-alpha.98/lib/archiver/README.md → v0.1.2-alpha.1/lib/domain/exemples/backend.js} +0 -0
- /package/framework/{v0.1.1-alpha.98/lib/routing/README.md → v0.1.2-alpha.1/lib/domain/exemples/frontend.html} +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/inherits/example/inheriting_eventemitter.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/inherits/example/protected_inheritance.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/inherits/example/simple_inheritance.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/inherits/example/super_attribute_overridden_by_child_on_init.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/logger/README.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/logger/src/containers/file/lib/logrotator/README.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/logger/src/containers/file/lib/logrotator/index.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/merge/example/merge.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/merge/example/merge_2_literal objects.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/merge/example/merge_and_preserve_first.js +0 -0
- /package/framework/{v0.1.1-alpha.98/lib/swig-filters → v0.1.2-alpha.1/lib/routing}/README.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/routing/build.json +0 -0
- /package/framework/{v0.1.1-alpha.98/lib/url → v0.1.2-alpha.1/lib/swig-filters}/README.md +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/url/index.js +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/url/mocks.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/url/routing.json +0 -0
- /package/framework/{v0.1.1-alpha.98 → v0.1.2-alpha.1}/lib/url/test.js +0 -0
|
@@ -15,7 +15,7 @@ const swig = require( _(GINA_FRAMEWORK_DIR +'/node_modules/swig', true)
|
|
|
15
15
|
var Config = require('./config');
|
|
16
16
|
var Router = require('./router');
|
|
17
17
|
var lib = require('./../lib');
|
|
18
|
-
var
|
|
18
|
+
var routingLib = lib.routing;
|
|
19
19
|
var inherits = lib.inherits;
|
|
20
20
|
var merge = lib.merge;
|
|
21
21
|
var Proc = lib.Proc;
|
|
@@ -55,10 +55,7 @@ function Server(options) {
|
|
|
55
55
|
|
|
56
56
|
var filters = SwigFilters({
|
|
57
57
|
options : conf,
|
|
58
|
-
isProxyHost : getContext('isProxyHost')
|
|
59
|
-
// throwError : self.throwError,
|
|
60
|
-
// req : local.req,
|
|
61
|
-
// res : local.res
|
|
58
|
+
isProxyHost : getContext('isProxyHost')
|
|
62
59
|
});
|
|
63
60
|
|
|
64
61
|
try {
|
|
@@ -91,8 +88,9 @@ function Server(options) {
|
|
|
91
88
|
//Starting app.
|
|
92
89
|
self.appName = options.bundle;
|
|
93
90
|
self.env = options.env;
|
|
91
|
+
self.scope = options.scope;
|
|
94
92
|
self.version = options.version;
|
|
95
|
-
local.router = new Router(self.env);
|
|
93
|
+
local.router = new Router(self.env, self.scope);
|
|
96
94
|
|
|
97
95
|
//True => multiple bundles sharing the same server (port).
|
|
98
96
|
self.isStandalone = options.isStandalone;
|
|
@@ -109,10 +107,10 @@ function Server(options) {
|
|
|
109
107
|
self.conf[self.appName][self.env].executionPath = options.conf[self.appName][self.env].executionPath = self.executionPath;
|
|
110
108
|
} else {
|
|
111
109
|
|
|
112
|
-
//console.
|
|
110
|
+
//console.debug("Running mode not handled yet..", self.appName, " VS ", self.bundles);
|
|
113
111
|
//Load all conf for the related apps & env.
|
|
114
112
|
var apps = self.bundles;
|
|
115
|
-
for (
|
|
113
|
+
for (let i=0; i<apps.length; ++i) {
|
|
116
114
|
self.conf[apps[i]] = {};
|
|
117
115
|
self.conf[apps[i]][self.env] = options.conf[apps[i]][self.env];
|
|
118
116
|
self.conf[apps[i]][self.env].bundlesPath = options.conf[apps[i]][self.env].bundlesPath;
|
|
@@ -141,7 +139,8 @@ function Server(options) {
|
|
|
141
139
|
|
|
142
140
|
serverOpt = merge({
|
|
143
141
|
bundle : self.appName,
|
|
144
|
-
env : self.env
|
|
142
|
+
env : self.env,
|
|
143
|
+
scope : self.scope
|
|
145
144
|
},
|
|
146
145
|
serverOpt,
|
|
147
146
|
{
|
|
@@ -155,11 +154,12 @@ function Server(options) {
|
|
|
155
154
|
console.debug('[ BUNDLE ][ server ][ init ] Initializing [ '+ self.appName +' ] server with `'+ serverOpt.engine +'`engine');
|
|
156
155
|
|
|
157
156
|
// controlling one last time protocol & ports
|
|
158
|
-
var ctx
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
157
|
+
var ctx = getContext('gina')
|
|
158
|
+
, projectConf = ctx.project
|
|
159
|
+
// TODO - check if the user prefered protocol is register in projectConf
|
|
160
|
+
, protocols = projectConf.protocols
|
|
161
|
+
, portsReverse = ctx.portsReverse
|
|
162
|
+
;
|
|
163
163
|
|
|
164
164
|
// locking port & protocol so it can't be changed by the user's settings
|
|
165
165
|
self.conf[self.appName][self.env].server.protocol = serverOpt.protocol;
|
|
@@ -194,15 +194,28 @@ function Server(options) {
|
|
|
194
194
|
self.emit('configured', false, engine.instance, engine.middleware, self.conf[self.appName][self.env]);
|
|
195
195
|
|
|
196
196
|
} catch (err) {
|
|
197
|
-
|
|
198
197
|
console.emerg('[ BUNDLE ] [ '+ self.appName +' ] ServerEngine ' + err.stack)
|
|
199
198
|
process.exit(1)
|
|
200
199
|
}
|
|
201
200
|
}
|
|
202
|
-
|
|
201
|
+
/**
|
|
202
|
+
* Check if env is running cacheless
|
|
203
|
+
* */
|
|
203
204
|
this.isCacheless = function() {
|
|
204
205
|
return (/^true$/i.test(process.env.NODE_ENV_IS_DEV)) ? true : false
|
|
205
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Check if the project scope is set for local
|
|
209
|
+
* */
|
|
210
|
+
this.isLocalScope = function() {
|
|
211
|
+
return (/^true$/i.test(process.env.NODE_SCOPE_IS_LOCAL)) ? true : false;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Check if the project scope is set for production
|
|
215
|
+
* */
|
|
216
|
+
this.isProductionScope = function() {
|
|
217
|
+
return (/^true$/i.test(process.env.NODE_SCOPE_IS_PRODUCTION)) ? true : false;
|
|
218
|
+
}
|
|
206
219
|
|
|
207
220
|
this.onConfigured = function(callback) {
|
|
208
221
|
self.once('configured', function(err, instance, middleware, conf) {
|
|
@@ -221,19 +234,63 @@ function Server(options) {
|
|
|
221
234
|
method: 'GET',
|
|
222
235
|
// rejectUnauthorized: true,
|
|
223
236
|
port: port || 443,
|
|
237
|
+
path: "/_gina/health/check",
|
|
224
238
|
ca: fs.readFileSync(self.conf[self.appName][self.env].content.settings.server.credentials.ca),
|
|
225
239
|
agent: new https.Agent({
|
|
226
240
|
maxCachedSessions: 0
|
|
227
241
|
})
|
|
228
242
|
});
|
|
229
243
|
} catch (err) {
|
|
230
|
-
|
|
231
|
-
|
|
244
|
+
if (!sslDetails) {
|
|
245
|
+
throw new Error('DNS issue ? Did you check your `/etc/hosts` or your DNS configuration ?\n'+ err.stack);
|
|
246
|
+
}
|
|
247
|
+
throw new Error(sslDetails +'\n'+ err.stack);
|
|
232
248
|
}
|
|
233
249
|
|
|
234
250
|
|
|
235
251
|
const failed = !sslDetails.valid;
|
|
236
252
|
const humanView = JSON.stringify(sslDetails, null, ' ');
|
|
253
|
+
|
|
254
|
+
// Wildcard exception - See https://github.com/dyaa/ssl-checker/issues/381
|
|
255
|
+
// Date of the test: 2022-12-18T00:00:00.000Z
|
|
256
|
+
// container-87546.dev.sample.app -> not valid when it should return true.
|
|
257
|
+
// {
|
|
258
|
+
// "daysRemaining": 290,
|
|
259
|
+
// "valid": false,
|
|
260
|
+
// "validFrom": "2022-10-03T00:00:00.000Z",
|
|
261
|
+
// "validTo": "2023-10-03T23:59:59.000Z",
|
|
262
|
+
// "validFor": [
|
|
263
|
+
// "*.sample.app",
|
|
264
|
+
// "sample.app"
|
|
265
|
+
// ]
|
|
266
|
+
// }
|
|
267
|
+
|
|
268
|
+
const isHandleByWildcardCert = function(endpoint, hv) {
|
|
269
|
+
var isAllowed = false;
|
|
270
|
+
const start = new Date(hv.validFrom).format('longIsoDateTime');
|
|
271
|
+
const end = new Date(hv.validTo).format('longIsoDateTime');
|
|
272
|
+
const today = new Date().format('longIsoDateTime');
|
|
273
|
+
const allowed = hv.validFor;
|
|
274
|
+
|
|
275
|
+
for (let i=0, len=allowed.length; i<len; ++i ) {
|
|
276
|
+
// skip if not a wildcard
|
|
277
|
+
if ( ! /^[*]\./.test(allowed[i]) ) continue;
|
|
278
|
+
|
|
279
|
+
let re = new RegExp( allowed[i].replace(/^[*]/, '')+'$' );
|
|
280
|
+
if ( ! re.test(endpoint) ) continue;
|
|
281
|
+
|
|
282
|
+
if ( today >= start && today < end) {
|
|
283
|
+
isAllowed = true;
|
|
284
|
+
break
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return isAllowed;
|
|
288
|
+
}
|
|
289
|
+
if ( failed && Array.isArray(sslDetails.validFor) && isHandleByWildcardCert(endpoint, sslDetails) ) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
|
|
237
294
|
if (failed) {
|
|
238
295
|
if (sslDetails.daysRemaining > -1) {
|
|
239
296
|
console.emerg(`[Certificate] ${endpoint} : It is like there is a problem with your CA certificate${'\n'} ${humanView}`);
|
|
@@ -257,7 +314,7 @@ function Server(options) {
|
|
|
257
314
|
router.setServerInstance(instance);
|
|
258
315
|
}
|
|
259
316
|
|
|
260
|
-
onRequest()
|
|
317
|
+
return onRequest()
|
|
261
318
|
}
|
|
262
319
|
|
|
263
320
|
|
|
@@ -276,7 +333,8 @@ function Server(options) {
|
|
|
276
333
|
, reverseRouting = {}
|
|
277
334
|
, cacheless = config.isCacheless()
|
|
278
335
|
, env = self.env
|
|
279
|
-
,
|
|
336
|
+
, scope = self.scope
|
|
337
|
+
, apps = conf.allBundles // conf.bundles
|
|
280
338
|
, filename = ''
|
|
281
339
|
, appName = ''
|
|
282
340
|
, tmp = {}
|
|
@@ -290,22 +348,23 @@ function Server(options) {
|
|
|
290
348
|
, webrootAutoredirect = null
|
|
291
349
|
, localWroot = null
|
|
292
350
|
, originalRules = []
|
|
293
|
-
, oRuleCount = 0
|
|
351
|
+
, oRuleCount = 0
|
|
352
|
+
;
|
|
294
353
|
|
|
295
354
|
//Standalone or shared instance mode. It doesn't matter.
|
|
296
355
|
for (; i<apps.length; ++i) {
|
|
297
|
-
config.setServerCoreConf(apps[i],
|
|
356
|
+
config.setServerCoreConf(apps[i], env, scope, serverCoreConf);
|
|
298
357
|
|
|
299
|
-
var appPath = _(conf.envConf[apps[i]][
|
|
358
|
+
var appPath = _(conf.envConf[apps[i]][env].bundlesPath+ '/' + apps[i]);
|
|
300
359
|
appName = apps[i];
|
|
301
360
|
|
|
302
361
|
//Specific case.
|
|
303
362
|
if (!self.isStandalone && i == 0) appName = apps[i];
|
|
304
363
|
|
|
305
364
|
try {
|
|
306
|
-
main = _(appPath + '/config/' + conf.envConf[apps[i]][
|
|
365
|
+
main = _(appPath + '/config/' + conf.envConf[apps[i]][env].configFiles.routing);
|
|
307
366
|
filename = main;//by default
|
|
308
|
-
filename = conf.envConf[apps[i]][
|
|
367
|
+
filename = conf.envConf[apps[i]][env].configFiles.routing.replace(/.json/, '.' +env + '.json');
|
|
309
368
|
filename = _(appPath + '/config/' + filename);
|
|
310
369
|
//Can't do a thing without.
|
|
311
370
|
if ( !fs.existsSync(filename) ) {
|
|
@@ -331,12 +390,12 @@ function Server(options) {
|
|
|
331
390
|
|
|
332
391
|
try {
|
|
333
392
|
|
|
334
|
-
wroot = conf.envConf[apps[i]][
|
|
335
|
-
webrootAutoredirect = conf.envConf[apps[i]][
|
|
393
|
+
wroot = conf.envConf[apps[i]][env].server.webroot;
|
|
394
|
+
webrootAutoredirect = conf.envConf[apps[i]][env].server.webrootAutoredirect;
|
|
336
395
|
// renaming rule for standalone setup
|
|
337
396
|
if ( self.isStandalone && apps[i] != self.appName && wroot == '/') {
|
|
338
397
|
wroot = '/'+ apps[i];
|
|
339
|
-
conf.envConf[apps[i]][
|
|
398
|
+
conf.envConf[apps[i]][env].server.webroot = wroot
|
|
340
399
|
}
|
|
341
400
|
|
|
342
401
|
if (wroot.length >1) {
|
|
@@ -367,9 +426,11 @@ function Server(options) {
|
|
|
367
426
|
if (typeof(tmp[rule].url) != 'object') {
|
|
368
427
|
if (tmp[rule].url.length > 1 && tmp[rule].url.substr(0,1) != '/') {
|
|
369
428
|
tmp[rule].url = '/'+tmp[rule].url
|
|
370
|
-
}
|
|
429
|
+
}
|
|
430
|
+
/** else if (tmp[rule].url.length > 1 && conf.envConf[apps[i]][env].server.webroot.substr(conf.envConf[apps[i]][env].server.webroot.length-1,1) == '/') {
|
|
371
431
|
tmp[rule].url = tmp[rule].url.substr(1)
|
|
372
|
-
}*/
|
|
432
|
+
}*/
|
|
433
|
+
else {
|
|
373
434
|
if (wroot.substr(wroot.length-1,1) == '/') {
|
|
374
435
|
wroot = wroot.substr(wroot.length-1,1).replace('/', '')
|
|
375
436
|
}
|
|
@@ -381,11 +442,11 @@ function Server(options) {
|
|
|
381
442
|
originalRules[oRuleCount] = ( self.isStandalone && tmp[rule] && apps[i] != self.appName) ? apps[i] + '-' + rule : rule;
|
|
382
443
|
++oRuleCount;
|
|
383
444
|
|
|
384
|
-
localWroot = conf.envConf[tmp[rule].bundle][
|
|
445
|
+
localWroot = conf.envConf[tmp[rule].bundle][env].server.webroot;
|
|
385
446
|
// standalone setup
|
|
386
447
|
if ( self.isStandalone && tmp[rule].bundle != self.appName && localWroot == '/') {
|
|
387
448
|
localWroot = '/'+ routing[rule].bundle;
|
|
388
|
-
conf.envConf[tmp[rule].bundle][
|
|
449
|
+
conf.envConf[tmp[rule].bundle][env].server.webroot = localWroot
|
|
389
450
|
}
|
|
390
451
|
if (localWroot.substr(localWroot.length-1,1) == '/') {
|
|
391
452
|
localWroot = localWroot.substr(localWroot.length-1,1).replace('/', '')
|
|
@@ -420,7 +481,7 @@ function Server(options) {
|
|
|
420
481
|
// This is only an issue when it comes to the frontend dev
|
|
421
482
|
// views.routeNameAsFilenameEnabled is set to true by default
|
|
422
483
|
// IF [ false ] the action is used as filename
|
|
423
|
-
if ( !conf.envConf[apps[i]][
|
|
484
|
+
if ( !conf.envConf[apps[i]][env].content.templates['_common'].routeNameAsFilenameEnabled && tmp[rule].param.bundle != 'framework') {
|
|
424
485
|
var tmpRouting = [];
|
|
425
486
|
for (var r = 0, len = tmp[rule].param.file.length; r < len; ++r) {
|
|
426
487
|
if (/[A-Z]/.test(tmp[rule].param.file.charAt(r))) {
|
|
@@ -431,6 +492,7 @@ function Server(options) {
|
|
|
431
492
|
++r
|
|
432
493
|
}
|
|
433
494
|
}
|
|
495
|
+
tmpRouting = null;
|
|
434
496
|
}
|
|
435
497
|
}
|
|
436
498
|
|
|
@@ -455,7 +517,9 @@ function Server(options) {
|
|
|
455
517
|
routing = merge(routing, ((self.isStandalone && apps[i] != self.appName ) ? standaloneTmp : tmp), true);
|
|
456
518
|
// originalRule is used to facilitate cross bundles (hypertext)linking
|
|
457
519
|
for (let r = 0, len = originalRules.length; r < len; r++) { // for each rule ( originalRules[r] )
|
|
458
|
-
routing[originalRules[r]].originalRule = (routing[originalRules[r]].bundle === self.appName )
|
|
520
|
+
routing[originalRules[r]].originalRule = (routing[originalRules[r]].bundle === self.appName )
|
|
521
|
+
? config.getOriginalRule(originalRules[r], routing)
|
|
522
|
+
: config.getOriginalRule(routing[originalRules[r]].bundle +'-'+ originalRules[r], routing)
|
|
459
523
|
}
|
|
460
524
|
|
|
461
525
|
// reverse routing
|
|
@@ -469,8 +533,8 @@ function Server(options) {
|
|
|
469
533
|
}
|
|
470
534
|
}
|
|
471
535
|
|
|
472
|
-
config.setRouting(apps[i],
|
|
473
|
-
config.setReverseRouting(apps[i],
|
|
536
|
+
config.setRouting(apps[i], env, scope, routing);
|
|
537
|
+
config.setReverseRouting(apps[i], env, scope, reverseRouting);
|
|
474
538
|
|
|
475
539
|
if (apps[i] == self.appName) {
|
|
476
540
|
self.routing = routing;
|
|
@@ -484,7 +548,9 @@ function Server(options) {
|
|
|
484
548
|
}
|
|
485
549
|
|
|
486
550
|
var hasViews = function(bundle) {
|
|
487
|
-
var _hasViews
|
|
551
|
+
var _hasViews = false
|
|
552
|
+
, conf = new Config().getInstance(bundle)
|
|
553
|
+
;
|
|
488
554
|
if (typeof(local.hasViews[bundle]) != 'undefined') {
|
|
489
555
|
_hasViews = local.hasViews[bundle];
|
|
490
556
|
} else {
|
|
@@ -495,149 +561,6 @@ function Server(options) {
|
|
|
495
561
|
return _hasViews
|
|
496
562
|
}
|
|
497
563
|
|
|
498
|
-
var parseCollection = function (collection, obj) {
|
|
499
|
-
|
|
500
|
-
for(var i = 0, len = collection.length; i<len; ++i) {
|
|
501
|
-
obj[i] = parseObject(collection[i], obj);
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
return obj
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
var parseObject = function (tmp, obj) {
|
|
508
|
-
var el = []
|
|
509
|
-
, key = null
|
|
510
|
-
;
|
|
511
|
-
|
|
512
|
-
for (var o in tmp) {
|
|
513
|
-
|
|
514
|
-
el[0] = o;
|
|
515
|
-
el[1] = tmp[o];
|
|
516
|
-
|
|
517
|
-
if ( /^(.*)\[(.*)\]/.test(el[0]) ) { // some[field] ?
|
|
518
|
-
key = el[0].replace(/\]/g, '').split(/\[/g);
|
|
519
|
-
obj = parseLocalObj(obj, key, 0, el[1])
|
|
520
|
-
} else {
|
|
521
|
-
obj[ el[0] ] = el[1]
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
return obj
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
var parseBody = function(body) {
|
|
529
|
-
var obj = null, tmp = null, arr = null;
|
|
530
|
-
if ( /^(\{|\[|\%7B|\%5B)/.test(body) ) {
|
|
531
|
-
try {
|
|
532
|
-
obj = {};
|
|
533
|
-
|
|
534
|
-
if ( /^(\%7B|\%5B)/.test(body) ) {
|
|
535
|
-
tmp = JSON.parse(decodeURIComponent(body))
|
|
536
|
-
} else {
|
|
537
|
-
tmp = JSON.parse(body)
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
if ( Array.isArray(tmp) ) {
|
|
541
|
-
obj = parseCollection(tmp, obj)
|
|
542
|
-
} else {
|
|
543
|
-
obj = parseObject(tmp, obj)
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
return obj
|
|
547
|
-
} catch (err) {
|
|
548
|
-
console.error('[365] could not parse body:\n' + body)
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
} else {
|
|
552
|
-
obj = {};
|
|
553
|
-
arr = body.split(/&/g);
|
|
554
|
-
if ( /(\"false\"|\"true\"|\"on\")/.test(body) )
|
|
555
|
-
body = body.replace(/\"false\"/g, false).replace(/\"true\"/g, true).replace(/\"on\"/g, true);
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
var el = {}
|
|
559
|
-
, value = null
|
|
560
|
-
, key = null;
|
|
561
|
-
|
|
562
|
-
for (var i = 0, len = arr.length; i < len; ++i) {
|
|
563
|
-
if (!arr[i]) continue;
|
|
564
|
-
|
|
565
|
-
arr[i] = decodeURIComponent(arr[i]);
|
|
566
|
-
|
|
567
|
-
if ( /^\{/.test(arr[i]) || /\=\{/.test(arr[i]) || /\=\[/.test(arr[i]) ) {
|
|
568
|
-
//if ( /^\{/.test(arr[i]) ) { // is a json string
|
|
569
|
-
try {
|
|
570
|
-
if (/^\{/.test(arr[i])) {
|
|
571
|
-
obj = JSON.parse(arr[i]);
|
|
572
|
-
break;
|
|
573
|
-
} else {
|
|
574
|
-
el = arr[i].match(/\=(.*)/);
|
|
575
|
-
el[0] = arr[i].split(/\=/)[0];
|
|
576
|
-
obj[ el[0] ] = JSON.parse( el[1] );
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
} catch (err) {
|
|
581
|
-
console.error('[parseBody#1] could not parse body:\n' + arr[i])
|
|
582
|
-
}
|
|
583
|
-
} else {
|
|
584
|
-
el = arr[i].split(/=/);
|
|
585
|
-
if ( /\{\}\"\:/.test(el[1]) ) { //might be a json
|
|
586
|
-
try {
|
|
587
|
-
el[1] = JSON.parse(el[1])
|
|
588
|
-
} catch (err) {
|
|
589
|
-
console.error('[parseBody#2] could not parse body:\n' + el[1])
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
if ( typeof(el[1]) == 'string' && !/\[object /.test(el[1])) {
|
|
594
|
-
key = null;
|
|
595
|
-
el[0] = decodeURIComponent(el[0]);
|
|
596
|
-
el[1] = decodeURIComponent(el[1]);
|
|
597
|
-
|
|
598
|
-
if ( /^(.*)\[(.*)\]/.test(el[0]) ) { // some[field] ?
|
|
599
|
-
key = el[0].replace(/\]/g, '').split(/\[/g);
|
|
600
|
-
obj = parseLocalObj(obj, key, 0, el[1])
|
|
601
|
-
} else {
|
|
602
|
-
obj[ el[0] ] = el[1]
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
return obj
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
var parseLocalObj = function(obj, key, k, value) {
|
|
615
|
-
|
|
616
|
-
if ( typeof(obj[ key[k] ]) == 'undefined' ) {
|
|
617
|
-
obj[ key[k] ] = {};
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
for (var prop in obj) {
|
|
621
|
-
|
|
622
|
-
if (k == key.length-1) {
|
|
623
|
-
|
|
624
|
-
if (prop == key[k]) {
|
|
625
|
-
obj[prop] = ( typeof(value) != 'undefined' ) ? value : '';
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
} else if ( key.indexOf(prop) > -1 ) {
|
|
629
|
-
++k;
|
|
630
|
-
if ( !obj[prop][ key[k] ] )
|
|
631
|
-
obj[prop][ key[k] ] = {};
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
parseLocalObj(obj[prop], key, k, value)
|
|
635
|
-
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
return obj;
|
|
640
|
-
}
|
|
641
564
|
|
|
642
565
|
var getAssetFilenameFromUrl = function(bundleConf, url) {
|
|
643
566
|
|
|
@@ -887,13 +810,13 @@ function Server(options) {
|
|
|
887
810
|
|
|
888
811
|
// parsing css files
|
|
889
812
|
i = 0, len = cssFiles.length;
|
|
890
|
-
var cssContent
|
|
891
|
-
, hasUrls
|
|
892
|
-
, definition
|
|
893
|
-
, defName
|
|
894
|
-
, d
|
|
895
|
-
, dLen
|
|
896
|
-
, cssMatched
|
|
813
|
+
var cssContent = null
|
|
814
|
+
, hasUrls = null
|
|
815
|
+
, definition = null
|
|
816
|
+
, defName = null
|
|
817
|
+
, d = null
|
|
818
|
+
, dLen = null
|
|
819
|
+
, cssMatched = null
|
|
897
820
|
;
|
|
898
821
|
var cssArr = null, classNames = null, assetsInClassFound = {};
|
|
899
822
|
for (; i < len; ++i) {
|
|
@@ -1053,7 +976,7 @@ function Server(options) {
|
|
|
1053
976
|
, conf = self.conf[self.appName][self.env]
|
|
1054
977
|
;
|
|
1055
978
|
|
|
1056
|
-
if ( typeof(responseHeaders) == 'undefined' ||
|
|
979
|
+
if ( typeof(responseHeaders) == 'undefined' || !responseHeaders) {
|
|
1057
980
|
responseHeaders = {};
|
|
1058
981
|
}
|
|
1059
982
|
|
|
@@ -1061,7 +984,7 @@ function Server(options) {
|
|
|
1061
984
|
resHeaders = JSON.clone(conf.server.response.header);
|
|
1062
985
|
if ( typeof(request.routing) == 'undefined' ) {
|
|
1063
986
|
request.routing = {
|
|
1064
|
-
'url': request.url,
|
|
987
|
+
'url' : request.url,
|
|
1065
988
|
'method': request.method
|
|
1066
989
|
}
|
|
1067
990
|
}
|
|
@@ -1071,18 +994,17 @@ function Server(options) {
|
|
|
1071
994
|
// Should not override main server.response.header.methods
|
|
1072
995
|
resHeaders['access-control-allow-methods'] = request.routing.method.replace(/(\,\s+|\,)/g, ', ').toUpperCase();
|
|
1073
996
|
|
|
1074
|
-
|
|
1075
997
|
if ( typeof(request.headers.origin) != 'undefined' ) {
|
|
1076
998
|
authority = request.headers.origin;
|
|
1077
999
|
} else if (request.headers.referer) {
|
|
1078
|
-
referer = request.headers.referer.match(
|
|
1079
|
-
referer =
|
|
1000
|
+
referer = request.headers.referer.match(/^[https://|http://][a-z0-9-_.:/]+\//)[0];
|
|
1001
|
+
referer = referer.substring(0, referer.length-1);
|
|
1080
1002
|
}
|
|
1081
1003
|
|
|
1082
1004
|
// access-control-allow-origin settings
|
|
1083
1005
|
if ( resHeaders.count() > 0 ) {
|
|
1006
|
+
|
|
1084
1007
|
// authority by default if no Access Control Allow Origin set
|
|
1085
|
-
//authority = ( typeof(referer) != 'undefined') ? conf.server.scheme +'://'+ request.headers.referer.match(/:\/\/(.[^\/]+)(.*)/)[1] : (request.headers[':scheme'] +'://'+request.headers[':authority'] || conf.server.scheme +'://'+request.headers.host || null);
|
|
1086
1008
|
if (!authority) {
|
|
1087
1009
|
if (!referer) {
|
|
1088
1010
|
if ( /http\/2/.test(conf.server.protocol) ) {
|
|
@@ -1106,58 +1028,80 @@ function Server(options) {
|
|
|
1106
1028
|
re = new RegExp(authority);
|
|
1107
1029
|
allowedOrigin = ( typeof(conf.server.response.header['access-control-allow-origin']) != 'undefined' && conf.server.response.header['access-control-allow-origin'] != '' ) ? conf.server.response.header['access-control-allow-origin'] : authority;
|
|
1108
1030
|
var found = null, origin = null, origins = null; // to handles multiple origins
|
|
1031
|
+
|
|
1109
1032
|
var originHostReplacement = function(name) {
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
, arr = null
|
|
1114
|
-
, domain = null
|
|
1115
|
-
;
|
|
1116
|
-
var env = conf.env; // current env by default
|
|
1117
|
-
if ( /\//.test(name[1]) ) {
|
|
1118
|
-
arr = name[1].split(/\//);
|
|
1119
|
-
project = arr[0];
|
|
1120
|
-
env = (arr[1]) ? arr[1] : env;
|
|
1033
|
+
var matched = name.match(/{([-_A-z]+?@[-_A-z]+?)}/g);
|
|
1034
|
+
if (!matched || !Array.isArray(matched) || Array.isArray(matched) && matched.length == 0 ) {
|
|
1035
|
+
return name
|
|
1121
1036
|
}
|
|
1122
1037
|
|
|
1123
|
-
|
|
1124
|
-
|
|
1038
|
+
var env = self.conf.env
|
|
1039
|
+
, scope = self.conf.scope
|
|
1040
|
+
;
|
|
1041
|
+
|
|
1042
|
+
for (let i=0, len=matched.length; i<len; ++i) {
|
|
1043
|
+
let oldHost = matched[i];
|
|
1044
|
+
let newHost = matched[i].replace(/\{|\}|\s+/g, '');
|
|
1045
|
+
newHost = newHost.split(/\@/);
|
|
1046
|
+
let bundle = newHost[0]
|
|
1047
|
+
, project = newHost[1]
|
|
1048
|
+
, arr = null
|
|
1049
|
+
, hostname = null
|
|
1050
|
+
, scheme = null
|
|
1051
|
+
;
|
|
1052
|
+
if ( /\//.test(newHost[1]) ) {
|
|
1053
|
+
arr = newHost[1].split(/\//);
|
|
1054
|
+
project = arr[0];
|
|
1055
|
+
env = (arr[1]) ? arr[1] : env;
|
|
1056
|
+
}
|
|
1057
|
+
scheme = self.conf[bundle][env].server.scheme;
|
|
1058
|
+
hostname = ( !self.conf[bundle][env].hostname ) ? self.conf[bundle][env].server.scheme + '://' + self.conf[bundle][env].host + ':' + self.conf[bundle][env].server.port : self.conf[bundle][env].hostname;
|
|
1059
|
+
name = name.replace(oldHost, hostname);
|
|
1060
|
+
}
|
|
1061
|
+
matched = null;
|
|
1062
|
+
env = null;
|
|
1125
1063
|
|
|
1126
|
-
return
|
|
1064
|
+
return name;
|
|
1127
1065
|
}
|
|
1128
1066
|
|
|
1129
|
-
var headerValue = null;
|
|
1130
|
-
for (
|
|
1131
|
-
if (
|
|
1067
|
+
var headerValue = null, re = new RegExp('\{\s*(.*)\s*\}', 'g');
|
|
1068
|
+
for (let h in resHeaders) {
|
|
1069
|
+
if (
|
|
1070
|
+
!response.headersSent
|
|
1071
|
+
) {
|
|
1132
1072
|
// handles multiple origins
|
|
1133
1073
|
if ( /access\-control\-allow\-origin/i.test(h) ) { // re.test(resHeaders[h]
|
|
1134
1074
|
if (sameOrigin) {
|
|
1135
1075
|
origin = sameOrigin
|
|
1136
1076
|
} else {
|
|
1137
1077
|
if ( /\,/.test(allowedOrigin) ) {
|
|
1138
|
-
origins = allowedOrigin.replace(/\s+/g, '').replace(
|
|
1078
|
+
origins = allowedOrigin.replace(/\s+/g, '').replace(re, originHostReplacement).split(/\,/g);
|
|
1139
1079
|
|
|
1140
1080
|
found = ( origins.indexOf(authority) > -1 ) ? origins[origins.indexOf(authority)] : false;
|
|
1141
1081
|
if ( found != false ) {
|
|
1142
1082
|
origin = found
|
|
1143
1083
|
}
|
|
1144
1084
|
} else {
|
|
1145
|
-
origin = allowedOrigin
|
|
1085
|
+
origin = allowedOrigin.replace(/\s+/g, '').replace(re, originHostReplacement);
|
|
1146
1086
|
}
|
|
1147
1087
|
}
|
|
1148
1088
|
|
|
1149
1089
|
if (origin || sameOrigin) {
|
|
1150
|
-
if (!origin && sameOrigin)
|
|
1090
|
+
if (!origin && sameOrigin) {
|
|
1151
1091
|
origin = sameOrigin;
|
|
1092
|
+
}
|
|
1152
1093
|
|
|
1153
|
-
|
|
1154
|
-
|
|
1094
|
+
try {
|
|
1095
|
+
response.setHeader(h, origin);
|
|
1096
|
+
} catch (headerError) {
|
|
1097
|
+
console.error(headerError)
|
|
1098
|
+
}
|
|
1155
1099
|
}
|
|
1156
1100
|
sameOrigin = false;
|
|
1157
1101
|
} else {
|
|
1158
1102
|
headerValue = resHeaders[h];
|
|
1159
1103
|
try {
|
|
1160
|
-
response.setHeader(h, headerValue)
|
|
1104
|
+
response.setHeader(h, headerValue);
|
|
1161
1105
|
} catch (headerError) {
|
|
1162
1106
|
console.error(headerError)
|
|
1163
1107
|
}
|
|
@@ -1178,22 +1122,16 @@ function Server(options) {
|
|
|
1178
1122
|
}
|
|
1179
1123
|
|
|
1180
1124
|
this.onHttp2Stream = function(stream, headers, response) {
|
|
1125
|
+
var header = null
|
|
1126
|
+
, isWebroot = false
|
|
1127
|
+
, pathname = null
|
|
1128
|
+
, asset = null
|
|
1129
|
+
, assets = this._options.template.assets
|
|
1130
|
+
, conf = this._options.conf
|
|
1131
|
+
, cacheless = conf.cacheless
|
|
1132
|
+
;
|
|
1181
1133
|
|
|
1182
|
-
if (!stream.pushAllowed) {
|
|
1183
|
-
//header = merge({ ':status': 200 }, response.getHeaders());
|
|
1184
|
-
stream.respond({ ':status': 200 });
|
|
1185
|
-
stream.end();
|
|
1186
|
-
return;
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
if (stream.headersSent) return;
|
|
1190
1134
|
|
|
1191
|
-
if ( !this._options.template ) {
|
|
1192
|
-
throwError({stream: stream}, 500, 'Internal server error\n' + headers[':path'] + '\nNo template found');
|
|
1193
|
-
return;
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
var header = null, isWebroot = false, pathname = null;
|
|
1197
1135
|
if (
|
|
1198
1136
|
headers[':path'] == '/'
|
|
1199
1137
|
|| headers[':path'] == this._options.conf.server.webroot
|
|
@@ -1205,24 +1143,100 @@ function Server(options) {
|
|
|
1205
1143
|
|| headers[':path'] == this._options.conf.server.webroot
|
|
1206
1144
|
&& this._options.conf.server.webrootAutoredirect
|
|
1207
1145
|
) {
|
|
1146
|
+
isWebroot = true
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1208
1149
|
|
|
1209
|
-
|
|
1210
|
-
':status': 301
|
|
1211
|
-
};
|
|
1150
|
+
var url = (isWebroot) ? this._referrer : headers[':path'];
|
|
1212
1151
|
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1152
|
+
var hanlersPath = conf.handlersPath
|
|
1153
|
+
, isHandler = (
|
|
1154
|
+
typeof(assets[ url ]) != 'undefined'
|
|
1155
|
+
&& typeof(assets[ url ].filename) != 'undefined'
|
|
1156
|
+
&& new RegExp('^'+ hanlersPath).test(assets[ url ].filename)
|
|
1157
|
+
) ? true: false
|
|
1158
|
+
;
|
|
1159
|
+
|
|
1160
|
+
if (!stream.pushAllowed) {
|
|
1161
|
+
asset = {
|
|
1162
|
+
url : url,
|
|
1163
|
+
filename : assets[ url ].filename,
|
|
1164
|
+
file : null,
|
|
1165
|
+
isAvailable : assets[ url ].isAvailable,
|
|
1166
|
+
mime : assets[ url ].mime,
|
|
1167
|
+
encoding : conf.encoding,
|
|
1168
|
+
isBinary : assets[ url ].isBinary,
|
|
1169
|
+
isHandler : assets[ url ].isHandler
|
|
1170
|
+
};
|
|
1171
|
+
header = merge({ ':status': 200 }, response.getHeaders());
|
|
1172
|
+
header['content-type'] = ( !/charset/.test(asset.mime ) ) ? asset.mime + '; charset='+ asset.encoding : asset.mime;
|
|
1173
|
+
header = completeHeaders(header, local.request, response);
|
|
1174
|
+
if (asset.isBinary || asset.isHandler ) {
|
|
1175
|
+
|
|
1176
|
+
|
|
1177
|
+
if (asset.isHandler) {
|
|
1178
|
+
// adding handler `gina.ready(...)` wrapper
|
|
1179
|
+
var file = null;
|
|
1180
|
+
if ( !fs.existsSync(asset.filename) ) {
|
|
1181
|
+
throwError({stream: stream}, 404, 'Page not found: \n' + headers[':path']);
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
if (!assets[ url ].file) {
|
|
1186
|
+
file = fs.readFileSync(asset.filename, asset.encoding).toString();
|
|
1187
|
+
file = '(gina.ready(function onGinaReady($){\n'+ file + '\n},window["originalContext"]));';
|
|
1188
|
+
this._options.template.assets[ headers[':path'] ].file = file;
|
|
1189
|
+
} else {
|
|
1190
|
+
file = assets[ url ].file;
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
// header['content-length'] = fs.statSync(file).size;
|
|
1194
|
+
stream.respond(header);
|
|
1195
|
+
stream.end(file);
|
|
1196
|
+
|
|
1197
|
+
return;
|
|
1217
1198
|
}
|
|
1218
|
-
header['location'] = this._options.conf.server.webroot;
|
|
1219
1199
|
|
|
1200
|
+
header['content-length'] = fs.statSync(asset.filename).size;
|
|
1201
|
+
stream.respondWithFile(
|
|
1202
|
+
asset.filename
|
|
1203
|
+
, header
|
|
1204
|
+
//, { onError }
|
|
1205
|
+
);
|
|
1206
|
+
} else {
|
|
1220
1207
|
stream.respond(header);
|
|
1221
1208
|
stream.end();
|
|
1222
|
-
return;
|
|
1223
|
-
} else {
|
|
1224
|
-
isWebroot = true;
|
|
1225
1209
|
}
|
|
1210
|
+
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
if (stream.headersSent) return;
|
|
1215
|
+
|
|
1216
|
+
if ( !this._options.template ) {
|
|
1217
|
+
throwError({stream: stream}, 500, 'Internal server error\n' + headers[':path'] + '\nNo template found');
|
|
1218
|
+
return;
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
if (
|
|
1222
|
+
// headers[':path'] == '/'
|
|
1223
|
+
// || headers[':path'] == this._options.conf.server.webroot
|
|
1224
|
+
/^true$/i.test(isWebroot)
|
|
1225
|
+
) {
|
|
1226
|
+
header = {
|
|
1227
|
+
':status': 301
|
|
1228
|
+
};
|
|
1229
|
+
|
|
1230
|
+
if (cacheless) {
|
|
1231
|
+
header['cache-control'] = 'no-cache, no-store, must-revalidate';
|
|
1232
|
+
header['pragma'] = 'no-cache';
|
|
1233
|
+
header['expires'] = '0';
|
|
1234
|
+
}
|
|
1235
|
+
header['location'] = this._options.conf.server.webroot;
|
|
1236
|
+
|
|
1237
|
+
stream.respond(header);
|
|
1238
|
+
stream.end();
|
|
1239
|
+
return;
|
|
1226
1240
|
}
|
|
1227
1241
|
|
|
1228
1242
|
if (
|
|
@@ -1235,25 +1249,20 @@ function Server(options) {
|
|
|
1235
1249
|
header = {
|
|
1236
1250
|
':status': 200
|
|
1237
1251
|
};
|
|
1238
|
-
var url = (isWebroot) ? this._referrer : headers[':path'];
|
|
1239
|
-
var assets = this._options.template.assets;
|
|
1240
1252
|
var responseHeaders = ( typeof(this._responseHeaders) != 'undefined') ? this._responseHeaders : null;
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
}
|
|
1251
|
-
, cacheless = conf.cacheless
|
|
1252
|
-
;
|
|
1253
|
+
asset = {
|
|
1254
|
+
url : url,
|
|
1255
|
+
filename : assets[ url ].filename,
|
|
1256
|
+
file : null,
|
|
1257
|
+
isAvailable : assets[ url ].isAvailable,
|
|
1258
|
+
mime : assets[ url ].mime,
|
|
1259
|
+
encoding : conf.encoding,
|
|
1260
|
+
isHandler : isHandler
|
|
1261
|
+
};
|
|
1253
1262
|
|
|
1254
1263
|
console.debug('h2 pushing: '+ headers[':path'] + ' -> '+ asset.filename);
|
|
1255
1264
|
|
|
1256
|
-
//
|
|
1265
|
+
// Adding handler `gina.ready(...)` wrapper
|
|
1257
1266
|
if ( new RegExp('^'+ conf.handlersPath).test(asset.filename) ) {
|
|
1258
1267
|
|
|
1259
1268
|
if ( !fs.existsSync(asset.filename) ) {
|
|
@@ -1261,7 +1270,7 @@ function Server(options) {
|
|
|
1261
1270
|
return;
|
|
1262
1271
|
}
|
|
1263
1272
|
|
|
1264
|
-
asset.isHandler = true;
|
|
1273
|
+
asset.isHandler = this._options.template.assets[ headers[':path'] ].isHandler = true;
|
|
1265
1274
|
asset.file = fs.readFileSync(asset.filename, asset.encoding).toString();
|
|
1266
1275
|
asset.file = '(gina.ready(function onGinaReady($){\n'+ asset.file + '\n},window["originalContext"]));';
|
|
1267
1276
|
|
|
@@ -1287,6 +1296,9 @@ function Server(options) {
|
|
|
1287
1296
|
|
|
1288
1297
|
|
|
1289
1298
|
header['content-type'] = ( !/charset/.test(asset.mime ) ) ? asset.mime + '; charset='+ asset.encoding : asset.mime;
|
|
1299
|
+
if (assets[ url ].isBinary) {
|
|
1300
|
+
header['content-length'] = fs.statSync(assets[ url ].filename).size;
|
|
1301
|
+
}
|
|
1290
1302
|
|
|
1291
1303
|
if (cacheless) {
|
|
1292
1304
|
// source maps integration for javascript & css
|
|
@@ -1305,8 +1317,9 @@ function Server(options) {
|
|
|
1305
1317
|
header = merge(header, responseHeaders);
|
|
1306
1318
|
}
|
|
1307
1319
|
header = completeHeaders(header, local.request, response);
|
|
1320
|
+
var pushedFile = (/index.html$/.test(headers[':path']) && /\/$/.test(asset.filename) ) ? asset.filename +'index.html': asset.filename;
|
|
1308
1321
|
pushStream.respondWithFile(
|
|
1309
|
-
|
|
1322
|
+
pushedFile
|
|
1310
1323
|
, header
|
|
1311
1324
|
//, { onError }
|
|
1312
1325
|
);
|
|
@@ -1328,7 +1341,7 @@ function Server(options) {
|
|
|
1328
1341
|
|
|
1329
1342
|
var protocol = 'http/'+ local.request.httpVersion; // inheriting request protocol version by default
|
|
1330
1343
|
var bundleConf = self.conf[self.appName][self.env];
|
|
1331
|
-
//
|
|
1344
|
+
// Switching protocol to h2 when possible
|
|
1332
1345
|
if ( /http\/2/.test(bundleConf.server.protocol) && response.stream ) {
|
|
1333
1346
|
protocol = bundleConf.server.protocol;
|
|
1334
1347
|
}
|
|
@@ -1382,6 +1395,7 @@ function Server(options) {
|
|
|
1382
1395
|
var isFilenameDir = null
|
|
1383
1396
|
, dirname = null
|
|
1384
1397
|
, isBinary = null
|
|
1398
|
+
, isHandler = null
|
|
1385
1399
|
, hanlersPath = null
|
|
1386
1400
|
;
|
|
1387
1401
|
|
|
@@ -1392,313 +1406,353 @@ function Server(options) {
|
|
|
1392
1406
|
} else {
|
|
1393
1407
|
var s = 0, sLen = bundleConf.staticResources.length;
|
|
1394
1408
|
for ( ; s < sLen; ++s ) {
|
|
1395
|
-
//if ( new RegExp('^'+ bundleConf.staticResources[s]).test(pathname) ) {
|
|
1396
1409
|
if ( eval('/^' + bundleConf.staticResources[s].replace(/\//g,'\\/') +'/').test(pathname) ) {
|
|
1397
1410
|
filename = bundleConf.content.statics[ bundleConf.staticResources[s] ] +'/'+ pathname.replace(bundleConf.staticResources[s], '');
|
|
1398
1411
|
break;
|
|
1399
1412
|
}
|
|
1400
1413
|
}
|
|
1414
|
+
|
|
1415
|
+
// try local
|
|
1416
|
+
if ( !fs.existsSync(filename) ) {
|
|
1417
|
+
var key = pathname.replace(pathname.split('/').splice(-1), '');
|
|
1418
|
+
for ( ; s < sLen; ++s ) {
|
|
1419
|
+
if ( bundleConf.staticResources[s] == key ) {
|
|
1420
|
+
// if ( eval('/^' + bundleConf.staticResources[s].replace(/\//g,'\\/') +'/').test(pathname) ) {
|
|
1421
|
+
filename = bundleConf.content.statics[ bundleConf.staticResources[s] ] +'/'+ pathname.replace(bundleConf.staticResources[s], '');
|
|
1422
|
+
break;
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
key = null;
|
|
1426
|
+
}
|
|
1427
|
+
s = null;
|
|
1428
|
+
sLen = null;
|
|
1429
|
+
|
|
1401
1430
|
}
|
|
1402
1431
|
|
|
1432
|
+
|
|
1403
1433
|
filename = decodeURIComponent(filename);
|
|
1404
1434
|
fs.exists(filename, function onStaticExists(exist) {
|
|
1405
1435
|
|
|
1406
1436
|
if (!exist) {
|
|
1407
|
-
throwError(response, 404, 'Page not found: \n' + pathname, next);
|
|
1408
|
-
|
|
1409
|
-
} else {
|
|
1437
|
+
return throwError(response, 404, 'Page not found: \n' + pathname, next);
|
|
1438
|
+
}
|
|
1410
1439
|
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1440
|
+
isFilenameDir = fs.statSync(filename).isDirectory();
|
|
1441
|
+
if ( isFilenameDir ) {
|
|
1442
|
+
dirname = request.url;
|
|
1443
|
+
filename += 'index.html';
|
|
1444
|
+
request.url += 'index.html';
|
|
1416
1445
|
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1446
|
+
if ( !fs.existsSync(filename) ) {
|
|
1447
|
+
throwError(response, 403, 'Forbidden: \n' + pathname, next);
|
|
1448
|
+
return;
|
|
1449
|
+
} else {
|
|
1450
|
+
var ext = 'html';
|
|
1451
|
+
if ( /http\/2/.test(protocol) ) {
|
|
1452
|
+
header = {
|
|
1453
|
+
':status': 301,
|
|
1454
|
+
'location': request.url,
|
|
1455
|
+
'content-type': bundleConf.server.coreConfiguration.mime[ext]+'; charset='+ bundleConf.encoding
|
|
1456
|
+
};
|
|
1428
1457
|
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1458
|
+
if (cacheless) {
|
|
1459
|
+
header['cache-control'] = 'no-cache, no-store, must-revalidate';
|
|
1460
|
+
header['pragma'] = 'no-cache';
|
|
1461
|
+
header['expires'] = '0';
|
|
1462
|
+
}
|
|
1463
|
+
request = checkPreflightRequest(request, response);
|
|
1464
|
+
header = completeHeaders(header, request, response);
|
|
1436
1465
|
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1466
|
+
if (!stream.destroyed) {
|
|
1467
|
+
stream.respond(header);
|
|
1468
|
+
stream.end();
|
|
1469
|
+
}
|
|
1441
1470
|
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
}
|
|
1454
|
-
response.end()
|
|
1471
|
+
} else {
|
|
1472
|
+
response.setHeader('location', request.url);
|
|
1473
|
+
request = checkPreflightRequest(request, response);
|
|
1474
|
+
completeHeaders(null, request, response);
|
|
1475
|
+
if (cacheless) {
|
|
1476
|
+
response.writeHead(301, {
|
|
1477
|
+
'cache-control': 'no-cache, no-store, must-revalidate', // preventing browsers from using cache
|
|
1478
|
+
'pragma': 'no-cache',
|
|
1479
|
+
'expires': '0',
|
|
1480
|
+
'content-type': bundleConf.server.coreConfiguration.mime[ext]
|
|
1481
|
+
});
|
|
1455
1482
|
}
|
|
1483
|
+
response.end()
|
|
1456
1484
|
}
|
|
1457
|
-
return;
|
|
1458
1485
|
}
|
|
1486
|
+
return;
|
|
1487
|
+
}
|
|
1459
1488
|
|
|
1460
1489
|
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1490
|
+
if (cacheless) {
|
|
1491
|
+
delete require.cache[require.resolve(filename)];
|
|
1492
|
+
}
|
|
1464
1493
|
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1494
|
+
if (response.headersSent) {
|
|
1495
|
+
// May be sent by http/2 push
|
|
1496
|
+
return
|
|
1497
|
+
}
|
|
1498
|
+
fs.readFile(filename, bundleConf.encoding, function onStaticFileRead(err, file) {
|
|
1499
|
+
if (err) {
|
|
1500
|
+
throwError(response, 404, 'Page not found: \n' + pathname, next);
|
|
1501
|
+
return;
|
|
1502
|
+
}
|
|
1470
1503
|
|
|
1471
|
-
|
|
1504
|
+
if (!response.headersSent) {
|
|
1472
1505
|
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
// adding gina loader
|
|
1477
|
-
if ( /text\/html/i.test(contentType) && self.isCacheless() ) {
|
|
1478
|
-
isBinary = false;
|
|
1479
|
-
// javascriptsDeferEnabled
|
|
1480
|
-
if (bundleConf.content.templates._common.javascriptsDeferEnabled ) {
|
|
1481
|
-
file = file.replace(/\<\/head\>/i, '\t'+ bundleConf.content.templates._common.ginaLoader +'\n</head>');
|
|
1482
|
-
} else {
|
|
1483
|
-
file = file.replace(/\<\/body\>/i, '\t'+ bundleConf.content.templates._common.ginaLoader +'\n</body>');
|
|
1484
|
-
}
|
|
1506
|
+
isBinary = true;
|
|
1507
|
+
isHandler = false;
|
|
1485
1508
|
|
|
1509
|
+
try {
|
|
1510
|
+
contentType = getContentTypeByFilename(filename);
|
|
1511
|
+
|
|
1512
|
+
// adding gina loader
|
|
1513
|
+
if ( /text\/html/i.test(contentType) && self.isCacheless() ) {
|
|
1514
|
+
isBinary = false;
|
|
1515
|
+
// javascriptsDeferEnabled
|
|
1516
|
+
if (bundleConf.content.templates._common.javascriptsDeferEnabled ) {
|
|
1517
|
+
file = file.replace(/\<\/head\>/i, '\t'+ bundleConf.content.templates._common.ginaLoader +'\n</head>');
|
|
1486
1518
|
} else {
|
|
1487
|
-
|
|
1488
|
-
hanlersPath = bundleConf.handlersPath;
|
|
1489
|
-
|
|
1490
|
-
if ( new RegExp('^'+ hanlersPath).test(filename) ) {
|
|
1491
|
-
isBinary = false;
|
|
1492
|
-
file = '(gina.ready(function onGinaReady($){\n'+ file + '\n},window["originalContext"]));'
|
|
1493
|
-
}
|
|
1519
|
+
file = file.replace(/\<\/body\>/i, '\t'+ bundleConf.content.templates._common.ginaLoader +'\n</body>');
|
|
1494
1520
|
}
|
|
1495
1521
|
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
var ext = request.url.match(/\.([A-Za-z0-9]+)$/);
|
|
1500
|
-
request.url = ( ext != null && typeof(ext[0]) != 'undefined' ) ? request.url : request.url + 'index.html';
|
|
1501
|
-
|
|
1502
|
-
self._responseHeaders = response.getHeaders();
|
|
1503
|
-
if (!isBinary && typeof(self._options.template.assets[request.url]) == 'undefined')
|
|
1504
|
-
self._options.template.assets = getAssets(bundleConf, file);
|
|
1505
|
-
|
|
1506
|
-
if (
|
|
1507
|
-
typeof(self._options.template.assets[request.url]) == 'undefined'
|
|
1508
|
-
|| isBinary
|
|
1509
|
-
) {
|
|
1510
|
-
|
|
1511
|
-
self._options.template.assets[request.url] = {
|
|
1512
|
-
ext: ( ext != null && typeof(ext[0]) != 'undefined' ) ? ext[0] : null,
|
|
1513
|
-
isAvailable: true,
|
|
1514
|
-
mime: contentType,
|
|
1515
|
-
url: request.url,
|
|
1516
|
-
filename: filename
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1522
|
+
} else {
|
|
1523
|
+
// adding handler `gina.ready(...)` wrapper
|
|
1524
|
+
hanlersPath = bundleConf.handlersPath;
|
|
1519
1525
|
|
|
1520
|
-
|
|
1521
|
-
|
|
1526
|
+
if ( new RegExp('^'+ hanlersPath).test(filename) ) {
|
|
1527
|
+
isBinary = false;
|
|
1528
|
+
isHandler = true;
|
|
1529
|
+
file = '(gina.ready(function onGinaReady($){\n'+ file + '\n},window["originalContext"]));'
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1522
1532
|
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1533
|
+
if ( /http\/2/.test(protocol) ) {
|
|
1534
|
+
self._isStatic = true;
|
|
1535
|
+
self._referrer = request.url;
|
|
1536
|
+
var ext = request.url.match(/\.([A-Za-z0-9]+)$/);
|
|
1537
|
+
request.url = ( ext != null && typeof(ext[0]) != 'undefined' ) ? request.url : request.url + 'index.html';
|
|
1538
|
+
|
|
1539
|
+
self._responseHeaders = response.getHeaders();
|
|
1540
|
+
if (!isBinary && typeof(self._options.template.assets[request.url]) == 'undefined')
|
|
1541
|
+
self._options.template.assets = getAssets(bundleConf, file);
|
|
1542
|
+
|
|
1543
|
+
if (
|
|
1544
|
+
typeof(self._options.template.assets[request.url]) == 'undefined'
|
|
1545
|
+
|| isBinary
|
|
1546
|
+
) {
|
|
1527
1547
|
|
|
1528
|
-
|
|
1548
|
+
self._options.template.assets[request.url] = {
|
|
1549
|
+
ext: ( ext != null && typeof(ext[0]) != 'undefined' ) ? ext[0] : null,
|
|
1550
|
+
isAvailable: true,
|
|
1551
|
+
mime: contentType,
|
|
1552
|
+
url: request.url,
|
|
1553
|
+
filename: filename,
|
|
1554
|
+
isBinary: isBinary,
|
|
1555
|
+
isHandler: isHandler
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1529
1558
|
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
if (headers[':path'] != request.url) {
|
|
1533
|
-
request.url = headers[':path'];
|
|
1534
|
-
isPathMatchingUrl = false;
|
|
1535
|
-
}
|
|
1559
|
+
self.instance._isXMLRequest = request.isXMLRequest;
|
|
1560
|
+
self.instance._getAssetFilenameFromUrl = getAssetFilenameFromUrl;
|
|
1536
1561
|
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1562
|
+
var isPathMatchingUrl = null;
|
|
1563
|
+
if ( !self.instance._http2streamEventInitalized ) {
|
|
1564
|
+
self.instance._http2streamEventInitalized = true;
|
|
1565
|
+
self.instance.on('stream', function onHttp2Strem(stream, headers) {
|
|
1541
1566
|
|
|
1542
|
-
|
|
1543
|
-
isFilenameDir = fs.statSync(filename).isDirectory();
|
|
1544
|
-
if (!isFilenameDir) {
|
|
1545
|
-
filename = this._getAssetFilenameFromUrl(bundleConf, pathname);
|
|
1546
|
-
}
|
|
1567
|
+
if (!self._isStatic) return;
|
|
1547
1568
|
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1569
|
+
if (!this._isXMLRequest) {
|
|
1570
|
+
isPathMatchingUrl = true;
|
|
1571
|
+
if (headers[':path'] != request.url) {
|
|
1572
|
+
request.url = headers[':path'];
|
|
1573
|
+
isPathMatchingUrl = false;
|
|
1574
|
+
}
|
|
1552
1575
|
|
|
1576
|
+
// for new requests
|
|
1577
|
+
if (!isPathMatchingUrl) {
|
|
1578
|
+
pathname = ( webroot.length > 1 && re.test(request.url) ) ? request.url.replace(re, '/') : request.url;
|
|
1579
|
+
isFilenameDir = (webroot == request.url) ? true: false;
|
|
1553
1580
|
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
throwError(response, 403, 'Forbidden: \n' + pathname, next);
|
|
1560
|
-
return;
|
|
1561
|
-
} else {
|
|
1562
|
-
header = {
|
|
1563
|
-
':status': 301,
|
|
1564
|
-
'location': request.url
|
|
1565
|
-
};
|
|
1581
|
+
if ( !isFilenameDir && !/404\.html/.test(filename) && fs.existsSync(filename) )
|
|
1582
|
+
isFilenameDir = fs.statSync(filename).isDirectory();
|
|
1583
|
+
if (!isFilenameDir) {
|
|
1584
|
+
filename = this._getAssetFilenameFromUrl(bundleConf, pathname);
|
|
1585
|
+
}
|
|
1566
1586
|
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
}
|
|
1587
|
+
if ( !isFilenameDir && !fs.existsSync(filename) ) {
|
|
1588
|
+
throwError(response, 404, 'Page not found: \n' + pathname, next);
|
|
1589
|
+
return;
|
|
1590
|
+
}
|
|
1572
1591
|
|
|
1573
1592
|
|
|
1574
|
-
|
|
1575
|
-
|
|
1593
|
+
if ( isFilenameDir ) {
|
|
1594
|
+
dirname = bundleConf.publicPath + pathname;
|
|
1595
|
+
filename = dirname + 'index.html';
|
|
1596
|
+
request.url += 'index.html';
|
|
1597
|
+
if ( !fs.existsSync(filename) ) {
|
|
1598
|
+
throwError(response, 403, 'Forbidden: \n' + pathname, next);
|
|
1599
|
+
return;
|
|
1600
|
+
} else {
|
|
1601
|
+
header = {
|
|
1602
|
+
':status': 301,
|
|
1603
|
+
'location': request.url
|
|
1604
|
+
};
|
|
1605
|
+
|
|
1606
|
+
if (cacheless) {
|
|
1607
|
+
header['cache-control'] = 'no-cache, no-store, must-revalidate';
|
|
1608
|
+
header['pragma'] = 'no-cache';
|
|
1609
|
+
header['expires'] = '0';
|
|
1576
1610
|
}
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
1611
|
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
request.url = ( ext != null && typeof(ext[0]) != 'undefined' ) ? request.url : request.url + 'index.html';
|
|
1584
|
-
if (
|
|
1585
|
-
!isPathMatchingUrl
|
|
1586
|
-
&& typeof(self._options.template.assets[request.url]) == 'undefined'
|
|
1587
|
-
) {
|
|
1588
|
-
|
|
1589
|
-
self._options.template.assets[request.url] = {
|
|
1590
|
-
ext: ( ext != null && typeof(ext[0]) != 'undefined' ) ? ext[0] : null,
|
|
1591
|
-
//isAvailable: true,
|
|
1592
|
-
isAvailable: (!/404\.html/.test(filename)) ? true : false,
|
|
1593
|
-
mime: contentType,
|
|
1594
|
-
url: request.url,
|
|
1595
|
-
filename: filename
|
|
1612
|
+
|
|
1613
|
+
stream.respond(header);
|
|
1614
|
+
stream.end();
|
|
1596
1615
|
}
|
|
1597
1616
|
}
|
|
1617
|
+
}
|
|
1598
1618
|
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1619
|
+
contentType = getContentTypeByFilename(filename);
|
|
1620
|
+
contentType = contentType +'; charset='+ bundleConf.encoding;
|
|
1621
|
+
ext = request.url.match(/\.([A-Za-z0-9]+)$/);
|
|
1622
|
+
request.url = ( ext != null && typeof(ext[0]) != 'undefined' ) ? request.url : request.url + 'index.html';
|
|
1623
|
+
if (
|
|
1624
|
+
!isPathMatchingUrl
|
|
1625
|
+
&& typeof(self._options.template.assets[request.url]) == 'undefined'
|
|
1626
|
+
) {
|
|
1627
|
+
|
|
1628
|
+
self._options.template.assets[request.url] = {
|
|
1629
|
+
ext: ( ext != null && typeof(ext[0]) != 'undefined' ) ? ext[0] : null,
|
|
1630
|
+
//isAvailable: true,
|
|
1631
|
+
isAvailable: (!/404\.html/.test(filename)) ? true : false,
|
|
1632
|
+
mime: contentType,
|
|
1633
|
+
url: request.url,
|
|
1634
|
+
filename: filename,
|
|
1635
|
+
isBinary: isBinary,
|
|
1636
|
+
isHandler: isHandler
|
|
1610
1637
|
}
|
|
1611
|
-
self.onHttp2Stream(stream, headers, response);
|
|
1612
1638
|
}
|
|
1613
1639
|
|
|
1614
|
-
|
|
1615
|
-
|
|
1640
|
+
if (!fs.existsSync(filename)) return;
|
|
1641
|
+
isBinary = ( /text\/html/i.test(contentType) ) ? false : true;
|
|
1642
|
+
isHandler = ( new RegExp('^'+ bundleConf.handlersPath).test(filename) ) ? true : false;
|
|
1643
|
+
if ( isBinary ) {
|
|
1644
|
+
// override
|
|
1645
|
+
self._options.template.assets[request.url] = {
|
|
1646
|
+
ext: ( ext != null && typeof(ext[0]) != 'undefined' ) ? ext[0] : null,
|
|
1647
|
+
isAvailable: true,
|
|
1648
|
+
mime: contentType,
|
|
1649
|
+
url: request.url,
|
|
1650
|
+
filename: filename,
|
|
1651
|
+
isBinary: isBinary,
|
|
1652
|
+
isHandler: isHandler
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1616
1655
|
|
|
1656
|
+
if ( isHandler ) {
|
|
1657
|
+
// adding handler `gina.ready(...)` wrapper
|
|
1658
|
+
var file = null;
|
|
1659
|
+
if (!self._options.template.assets[request.url].file) {
|
|
1660
|
+
file = fs.readFileSync(filename, bundleConf.encoding).toString();
|
|
1661
|
+
file = '(gina.ready(function onGinaReady($){\n'+ file + '\n},window["originalContext"]));';
|
|
1662
|
+
self._options.template.assets[request.url].file = file;
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
self.onHttp2Stream(stream, headers, response);
|
|
1666
|
+
}
|
|
1617
1667
|
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
'content-type': contentType + '; charset='+ bundleConf.encoding
|
|
1621
|
-
};
|
|
1668
|
+
}); // EO self.instance.on('stream' ..
|
|
1669
|
+
}
|
|
1622
1670
|
|
|
1623
|
-
if (cacheless) {
|
|
1624
|
-
// source maps integration for javascript & css
|
|
1625
|
-
if ( /(.js|.css)$/.test(filename) && fs.existsSync(filename +'.map') && !/sourceMappingURL/.test(file) ) {
|
|
1626
|
-
//pathname = pathname +'.map';
|
|
1627
|
-
pathname = webroot + pathname.substr(1) +'.map';
|
|
1628
|
-
// serve without cache
|
|
1629
|
-
header['X-SourceMap'] = pathname;
|
|
1630
|
-
header['cache-control'] = 'no-cache, no-store, must-revalidate';
|
|
1631
|
-
header['pragma'] = 'no-cache';
|
|
1632
|
-
header['expires'] = '0';
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
1671
|
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
stream.respond(header);
|
|
1641
|
-
stream.end(file);
|
|
1642
|
-
}
|
|
1643
|
-
// Fixed on march 15 2021 by removing the return
|
|
1644
|
-
// Could be the cause why the push is pending
|
|
1645
|
-
//return;
|
|
1646
|
-
} else {
|
|
1672
|
+
header = {
|
|
1673
|
+
':status': 200,
|
|
1674
|
+
'content-type': contentType + '; charset='+ bundleConf.encoding
|
|
1675
|
+
};
|
|
1647
1676
|
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1677
|
+
if (cacheless) {
|
|
1678
|
+
// source maps integration for javascript & css
|
|
1679
|
+
if ( /(.js|.css)$/.test(filename) && fs.existsSync(filename +'.map') && !/sourceMappingURL/.test(file) ) {
|
|
1680
|
+
//pathname = pathname +'.map';
|
|
1681
|
+
pathname = webroot + pathname.substr(1) +'.map';
|
|
1682
|
+
// serve without cache
|
|
1683
|
+
header['X-SourceMap'] = pathname;
|
|
1684
|
+
header['cache-control'] = 'no-cache, no-store, must-revalidate';
|
|
1685
|
+
header['pragma'] = 'no-cache';
|
|
1686
|
+
header['expires'] = '0';
|
|
1655
1687
|
}
|
|
1688
|
+
}
|
|
1656
1689
|
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1690
|
+
header = completeHeaders(header, request, response);
|
|
1691
|
+
if (isBinary) {
|
|
1692
|
+
stream.respondWithFile(filename, header)
|
|
1693
|
+
} else {
|
|
1694
|
+
stream.respond(header);
|
|
1695
|
+
stream.end(file);
|
|
1696
|
+
}
|
|
1697
|
+
// Fixed on march 15 2021 by removing the return
|
|
1698
|
+
// Could be the cause why the push is pending
|
|
1699
|
+
//return;
|
|
1700
|
+
} else {
|
|
1664
1701
|
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1702
|
+
completeHeaders(null, request, response);
|
|
1703
|
+
response.setHeader('content-type', contentType +'; charset='+ bundleConf.encoding);
|
|
1704
|
+
// if (/\.(woff|woff2)$/i.test(filename) ) {
|
|
1705
|
+
// response.setHeader("Transfer-Encoding", 'Identity')
|
|
1706
|
+
// }
|
|
1707
|
+
if (isBinary) {
|
|
1708
|
+
response.setHeader('content-length', fs.statSync(filename).size);
|
|
1709
|
+
}
|
|
1671
1710
|
|
|
1672
|
-
|
|
1673
|
-
|
|
1711
|
+
if (cacheless) {
|
|
1712
|
+
// source maps integration for javascript & css
|
|
1713
|
+
if ( /(.js|.css)$/.test(filename) && fs.existsSync(filename +'.map') && !/sourceMappingURL/.test(file) ) {
|
|
1714
|
+
//pathname = pathname +'.map'
|
|
1715
|
+
pathname = webroot + pathname.substr(1) +'.map';
|
|
1716
|
+
response.setHeader("X-SourceMap", pathname)
|
|
1674
1717
|
}
|
|
1675
1718
|
|
|
1719
|
+
// serve without cache
|
|
1720
|
+
response.writeHead(200, {
|
|
1721
|
+
'cache-control': 'no-cache, no-store, must-revalidate', // preventing browsers from caching it
|
|
1722
|
+
'pragma': 'no-cache',
|
|
1723
|
+
'expires': '0'
|
|
1724
|
+
});
|
|
1676
1725
|
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
console.info(request.method +' [200] '+ pathname);
|
|
1681
|
-
})
|
|
1682
|
-
.pipe(response);
|
|
1683
|
-
} else {
|
|
1684
|
-
response.write(file, bundleConf.encoding);
|
|
1685
|
-
response.end();
|
|
1686
|
-
console.info(request.method +' [200] '+ pathname);
|
|
1687
|
-
}
|
|
1726
|
+
} else {
|
|
1727
|
+
response.writeHead(200)
|
|
1728
|
+
}
|
|
1688
1729
|
|
|
1689
|
-
|
|
1730
|
+
|
|
1731
|
+
if (isBinary) { // images, javascript, pdf ....
|
|
1732
|
+
fs.createReadStream(filename)
|
|
1733
|
+
.on('end', function onResponse(){
|
|
1734
|
+
console.info(request.method +' [200] '+ pathname);
|
|
1735
|
+
})
|
|
1736
|
+
.pipe(response);
|
|
1737
|
+
} else {
|
|
1738
|
+
response.write(file, bundleConf.encoding);
|
|
1739
|
+
response.end();
|
|
1740
|
+
console.info(request.method +' [200] '+ pathname);
|
|
1690
1741
|
}
|
|
1691
1742
|
|
|
1692
|
-
} catch(err) {
|
|
1693
|
-
throwError(response, 500, err.stack);
|
|
1694
1743
|
return;
|
|
1695
1744
|
}
|
|
1745
|
+
|
|
1746
|
+
} catch(err) {
|
|
1747
|
+
throwError(response, 500, err.stack);
|
|
1748
|
+
return;
|
|
1696
1749
|
}
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
return
|
|
1753
|
+
});
|
|
1697
1754
|
|
|
1698
|
-
return
|
|
1699
|
-
});
|
|
1700
1755
|
|
|
1701
|
-
}
|
|
1702
1756
|
})
|
|
1703
1757
|
}
|
|
1704
1758
|
|
|
@@ -1729,21 +1783,31 @@ function Server(options) {
|
|
|
1729
1783
|
* */
|
|
1730
1784
|
request.isWithCredentials = ( request.headers['access-control-allow-credentials'] && request.headers['access-control-allow-credentials'] == true ) ? true : false;
|
|
1731
1785
|
/**
|
|
1732
|
-
* Intercept gina headers
|
|
1786
|
+
* Intercept gina headers for:
|
|
1787
|
+
* - form valdiation
|
|
1788
|
+
* - form security
|
|
1733
1789
|
*/
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
var rule = request.headers['x-gina-form-rule'].split(/\@/);
|
|
1742
|
-
ginaHeaders.form.rule = rule[0];
|
|
1743
|
-
ginaHeaders.form.bundle = rule[1];
|
|
1744
|
-
}
|
|
1745
|
-
request.ginaHeaders = ginaHeaders;
|
|
1790
|
+
var ginaHeaders = {
|
|
1791
|
+
form: {},
|
|
1792
|
+
popin: {}
|
|
1793
|
+
};
|
|
1794
|
+
// if (/x\-gina\-form\-id/i.test(request.headers['access-control-request-headers']) ) {
|
|
1795
|
+
if ( typeof(request.headers['x-gina-form-rule']) != 'undefined' ) {
|
|
1796
|
+
ginaHeaders.form.id = request.headers['x-gina-form-id'];
|
|
1746
1797
|
}
|
|
1798
|
+
if ( typeof(request.headers['x-gina-popin-id']) != 'undefined' ) {
|
|
1799
|
+
ginaHeaders.popin.id = request.headers['x-gina-popin-id'];
|
|
1800
|
+
}
|
|
1801
|
+
if ( typeof(request.headers['x-gina-popin-name']) != 'undefined' ) {
|
|
1802
|
+
ginaHeaders.popin.name = request.headers['x-gina-popin-name'];
|
|
1803
|
+
}
|
|
1804
|
+
if ( typeof(request.headers['x-gina-form-rule']) != 'undefined' ) {
|
|
1805
|
+
var rule = request.headers['x-gina-form-rule'].split(/\@/);
|
|
1806
|
+
ginaHeaders.form.rule = rule[0];
|
|
1807
|
+
ginaHeaders.form.bundle = rule[1];
|
|
1808
|
+
rule = null;
|
|
1809
|
+
}
|
|
1810
|
+
request.ginaHeaders = ginaHeaders;
|
|
1747
1811
|
|
|
1748
1812
|
local.request = request;
|
|
1749
1813
|
|
|
@@ -1779,7 +1843,9 @@ function Server(options) {
|
|
|
1779
1843
|
if ( urls.indexOf('/') > -1 ) {
|
|
1780
1844
|
isWebrootHandledByRouting = true;
|
|
1781
1845
|
}
|
|
1846
|
+
urls = null;
|
|
1782
1847
|
}
|
|
1848
|
+
routing = null;
|
|
1783
1849
|
}
|
|
1784
1850
|
|
|
1785
1851
|
// priority to statics - this portion of code has been duplicated to SuperController : see `isStaticRoute` method
|
|
@@ -1815,6 +1881,9 @@ function Server(options) {
|
|
|
1815
1881
|
) {
|
|
1816
1882
|
staticProps.isStaticFilename = true
|
|
1817
1883
|
}
|
|
1884
|
+
|
|
1885
|
+
ext = null;
|
|
1886
|
+
isImage = null;
|
|
1818
1887
|
}
|
|
1819
1888
|
|
|
1820
1889
|
|
|
@@ -1825,27 +1894,25 @@ function Server(options) {
|
|
|
1825
1894
|
if ( matchedFirstInUrl && matchedFirstInUrl.length > 0 ) {
|
|
1826
1895
|
staticProps.firstLevel = self.conf[self.appName][self.env].server.webroot + matchedFirstInUrl[0]
|
|
1827
1896
|
}
|
|
1897
|
+
matchedFirstInUrl = null;
|
|
1828
1898
|
}
|
|
1829
1899
|
|
|
1830
1900
|
if (
|
|
1831
1901
|
staticProps.isStaticFilename && staticsArr.indexOf(request.url) > -1
|
|
1832
1902
|
|| staticProps.isStaticFilename && staticsArr.indexOf( request.url.replace(request.url.substr(request.url.lastIndexOf('/')+1), '') ) > -1
|
|
1833
|
-
//|| staticProps.isStaticFilename && staticsArr.indexOf(staticProps.firstLevel) > -1
|
|
1834
|
-
// take ^/dir/sub/*
|
|
1835
1903
|
|| staticProps.isStaticFilename && new RegExp('^'+ staticProps.firstLevel).test(request.url)
|
|
1836
1904
|
|| /\/$/.test(request.url) && !isWebrootHandledByRouting && !/\/engine\.io\//.test(request.url)
|
|
1837
1905
|
) {
|
|
1838
1906
|
self._isStatic = true;
|
|
1839
1907
|
|
|
1840
|
-
|
|
1841
1908
|
self._referrer = request.url;
|
|
1842
1909
|
// by default - used in `composeHeadersMiddleware`: see Default Global Middlewares (gna.js)
|
|
1843
1910
|
request.routing = {
|
|
1844
|
-
'url': request.url,
|
|
1845
|
-
'method': 'GET',
|
|
1846
|
-
'bundle'
|
|
1911
|
+
'url' : request.url,
|
|
1912
|
+
'method' : 'GET',
|
|
1913
|
+
'bundle' : self.appName
|
|
1847
1914
|
};
|
|
1848
|
-
request = checkPreflightRequest(request);
|
|
1915
|
+
request = checkPreflightRequest(request, response);
|
|
1849
1916
|
local.request = request; // update request
|
|
1850
1917
|
// filtered to handle only html for now
|
|
1851
1918
|
if ( /text\/html/.test(request.headers['accept'])
|
|
@@ -1923,6 +1990,8 @@ function Server(options) {
|
|
|
1923
1990
|
* - https://developers.google.com/web/updates/2012/06/How-to-convert-ArrayBuffer-to-and-from-String
|
|
1924
1991
|
* - https://jsperf.com/arraybuffer-string-conversion/4
|
|
1925
1992
|
*
|
|
1993
|
+
* TODO - Test with audio content
|
|
1994
|
+
*
|
|
1926
1995
|
* @param {string} str
|
|
1927
1996
|
*
|
|
1928
1997
|
* @returns {array} buffer
|
|
@@ -1955,7 +2024,7 @@ function Server(options) {
|
|
|
1955
2024
|
//var buf = new ArrayBuffer(str.length * 2); // 2 bytes for each char when using Uint16Array(buf)
|
|
1956
2025
|
//var buf = new ArrayBuffer(str.length); // Uint8Array
|
|
1957
2026
|
//var bufView = new Uint8Array(buf);
|
|
1958
|
-
for (
|
|
2027
|
+
for (let i = 0, strLen = str.length; i < strLen; i++) {
|
|
1959
2028
|
bufView[i] = str.charCodeAt(i);
|
|
1960
2029
|
}
|
|
1961
2030
|
|
|
@@ -2155,16 +2224,17 @@ function Server(options) {
|
|
|
2155
2224
|
|
|
2156
2225
|
});//EO this.instance
|
|
2157
2226
|
|
|
2158
|
-
|
|
2159
2227
|
self.instance.listen(self.conf[self.appName][self.env].server.port);//By Default 3100
|
|
2160
|
-
|
|
2228
|
+
// Timeout in milliseconds - e.g.: (1000x60)x2 => 2 min
|
|
2229
|
+
self.instance.timeout = 0; // zero for unlimited
|
|
2230
|
+
|
|
2161
2231
|
|
|
2162
2232
|
self.emit('started', self.conf[self.appName][self.env], true);
|
|
2163
2233
|
}
|
|
2164
2234
|
|
|
2165
2235
|
var processRequestData = function(request, response, next) {
|
|
2166
2236
|
|
|
2167
|
-
var bodyStr = null, obj = null;
|
|
2237
|
+
var bodyStr = null, obj = null, exception = null;
|
|
2168
2238
|
// to compare with /core/controller/controller.js -> getParams()
|
|
2169
2239
|
switch( request.method.toLowerCase() ) {
|
|
2170
2240
|
case 'post':
|
|
@@ -2193,7 +2263,13 @@ function Server(options) {
|
|
|
2193
2263
|
bodyStr = bodyStr.replace(/\"null\"/ig, null);
|
|
2194
2264
|
|
|
2195
2265
|
try {
|
|
2196
|
-
obj = parseBody(bodyStr);
|
|
2266
|
+
// obj = parseBody(bodyStr);
|
|
2267
|
+
obj = formatDataFromString(bodyStr);
|
|
2268
|
+
if ( !obj) {
|
|
2269
|
+
exception = new Error('Could not convert POST::BODY_STRING to POST::OBJECT. Possible JSON error in `bodyStr`');
|
|
2270
|
+
throwError(response, 500, exception, next);
|
|
2271
|
+
return;
|
|
2272
|
+
}
|
|
2197
2273
|
request.post = obj;
|
|
2198
2274
|
isPostSet = true;
|
|
2199
2275
|
} catch (err) {
|
|
@@ -2226,7 +2302,8 @@ function Server(options) {
|
|
|
2226
2302
|
if (request.body.count() == 0 && typeof(request.query) != 'string' && request.query.count() > 0 ) {
|
|
2227
2303
|
request.body = request.query
|
|
2228
2304
|
}
|
|
2229
|
-
|
|
2305
|
+
// 2023-01-31: fixed `request.body` might not be an `object`
|
|
2306
|
+
bodyStr = ( typeof(request.body) == 'object') ? JSON.stringify(request.body) : request.body;
|
|
2230
2307
|
// false & true case
|
|
2231
2308
|
if ( /(\"false\"|\"true\"|\"on\")/.test(bodyStr) )
|
|
2232
2309
|
bodyStr = bodyStr.replace(/\"false\"/g, false).replace(/\"true\"/g, true).replace(/\"on\"/g, true);
|
|
@@ -2235,7 +2312,7 @@ function Server(options) {
|
|
|
2235
2312
|
}
|
|
2236
2313
|
|
|
2237
2314
|
try {
|
|
2238
|
-
if ( obj.count() > 0 ) {
|
|
2315
|
+
if ( typeof(obj) == 'object' && obj.count() > 0 ) {
|
|
2239
2316
|
// still need this to allow compatibility with express & connect middlewares
|
|
2240
2317
|
request.body = request.post = obj;
|
|
2241
2318
|
}
|
|
@@ -2276,7 +2353,7 @@ function Server(options) {
|
|
|
2276
2353
|
|
|
2277
2354
|
|
|
2278
2355
|
if ( typeof(request.query.inheritedData) == 'string' ) {
|
|
2279
|
-
inheritedDataObj =
|
|
2356
|
+
inheritedDataObj = formatDataFromString(decodeURIComponent(request.query.inheritedData));
|
|
2280
2357
|
} else {
|
|
2281
2358
|
inheritedDataObj = JSON.clone(request.query.inheritedData);
|
|
2282
2359
|
}
|
|
@@ -2293,10 +2370,12 @@ function Server(options) {
|
|
|
2293
2370
|
bodyStr = bodyStr.replace(/\"null\"/ig, null);
|
|
2294
2371
|
|
|
2295
2372
|
|
|
2296
|
-
obj =
|
|
2373
|
+
obj = formatDataFromString(decodeURIComponent(bodyStr));
|
|
2297
2374
|
|
|
2298
2375
|
request.query = merge(obj, inheritedDataObj);
|
|
2299
|
-
delete obj;
|
|
2376
|
+
// delete obj;
|
|
2377
|
+
obj = null;
|
|
2378
|
+
inheritedDataObj = null;
|
|
2300
2379
|
|
|
2301
2380
|
request.get = request.query;
|
|
2302
2381
|
}
|
|
@@ -2336,7 +2415,7 @@ function Server(options) {
|
|
|
2336
2415
|
if ( /(\"null\")/i.test(bodyStr) )
|
|
2337
2416
|
bodyStr = bodyStr.replace(/\"null\"/ig, null);
|
|
2338
2417
|
|
|
2339
|
-
obj =
|
|
2418
|
+
obj = formatDataFromString(bodyStr);
|
|
2340
2419
|
|
|
2341
2420
|
if ( typeof(obj) != 'undefined' && obj.count() == 0 && bodyStr.length > 1 ) {
|
|
2342
2421
|
try {
|
|
@@ -2418,21 +2497,21 @@ function Server(options) {
|
|
|
2418
2497
|
})
|
|
2419
2498
|
}
|
|
2420
2499
|
|
|
2421
|
-
var
|
|
2500
|
+
var getContentTypeByFilename = function(filename) {
|
|
2422
2501
|
try {
|
|
2423
|
-
var s =
|
|
2502
|
+
var s = filename.split(/\./);
|
|
2424
2503
|
var ext = s[s.length-1];
|
|
2425
2504
|
var type = null;
|
|
2426
2505
|
var mime = self.conf[self.appName][self.env].server.coreConfiguration.mime;
|
|
2427
2506
|
|
|
2428
|
-
if( typeof(mime[ext]) != 'undefined' ) {
|
|
2507
|
+
if ( typeof(mime[ext]) != 'undefined' ) {
|
|
2429
2508
|
type = mime[ext];
|
|
2430
2509
|
} else {
|
|
2431
|
-
console.warn('[ '+
|
|
2510
|
+
console.warn('[ '+filename+' ] extension: `'+s[2]+'` not supported by gina: `core/mime.types`. Pathname must be a directory. Replacing with `plain/text` ')
|
|
2432
2511
|
}
|
|
2433
|
-
return type ||
|
|
2512
|
+
return type || 'plain/text';
|
|
2434
2513
|
} catch (err) {
|
|
2435
|
-
console.error('Error while trying to
|
|
2514
|
+
console.error('Error while trying to getContentTypeByFilename('+ filename +') extention. Replacing with `plain/text` '+ err.stack);
|
|
2436
2515
|
return 'plain/text'
|
|
2437
2516
|
}
|
|
2438
2517
|
|
|
@@ -2454,10 +2533,10 @@ function Server(options) {
|
|
|
2454
2533
|
if (self.isStandalone) {
|
|
2455
2534
|
|
|
2456
2535
|
end:
|
|
2457
|
-
for (
|
|
2536
|
+
for (let b in conf) {
|
|
2458
2537
|
if (self.bundles.indexOf(b) < 0) continue;
|
|
2459
2538
|
if ( typeof(conf[b][self.env].content) != 'undefined' && typeof(conf[b][self.env].content.statics) != 'undefined' && conf[b][self.env].content.statics.count() > 0 ) {
|
|
2460
|
-
for (
|
|
2539
|
+
for (let s in conf[b][self.env].content.statics) {
|
|
2461
2540
|
s = (s.substr(0,1) == '/') ? s.substr(1) : s;
|
|
2462
2541
|
if ( (new RegExp('^/'+s)).test(pathname) ) {
|
|
2463
2542
|
bundle = b;
|
|
@@ -2500,7 +2579,8 @@ function Server(options) {
|
|
|
2500
2579
|
, res = options.res
|
|
2501
2580
|
, config = options.conf
|
|
2502
2581
|
, next = options.next
|
|
2503
|
-
, callback = options.callback
|
|
2582
|
+
, callback = options.callback
|
|
2583
|
+
;
|
|
2504
2584
|
|
|
2505
2585
|
//Reloading assets & files.
|
|
2506
2586
|
// if (!cacheless) { // all but dev & debug
|
|
@@ -2531,13 +2611,13 @@ function Server(options) {
|
|
|
2531
2611
|
}
|
|
2532
2612
|
|
|
2533
2613
|
expressMiddlewares[nextMiddleware._index](nextMiddleware._request, nextMiddleware._response, function onNextMiddleware(err, request, response) {
|
|
2534
|
-
++nextMiddleware._index;
|
|
2535
2614
|
|
|
2536
2615
|
if (err) {
|
|
2537
2616
|
throwError(nextMiddleware._response, 500, (err.stack||err.message||err), nextMiddleware._next, nextMiddleware._nextAction);
|
|
2538
2617
|
return;
|
|
2539
2618
|
}
|
|
2540
2619
|
|
|
2620
|
+
++nextMiddleware._index;
|
|
2541
2621
|
if (request)
|
|
2542
2622
|
nextMiddleware._request = request;
|
|
2543
2623
|
|
|
@@ -2562,7 +2642,7 @@ function Server(options) {
|
|
|
2562
2642
|
});
|
|
2563
2643
|
};
|
|
2564
2644
|
|
|
2565
|
-
var checkPreflightRequest = function(request) {
|
|
2645
|
+
var checkPreflightRequest = function(request, response) {
|
|
2566
2646
|
var config = self.conf[self.appName][self.env];
|
|
2567
2647
|
// by default, if not set in `${projectPath}/env.json`
|
|
2568
2648
|
var corsMethod = 'GET, POST, HEAD';
|
|
@@ -2606,7 +2686,7 @@ function Server(options) {
|
|
|
2606
2686
|
} else {
|
|
2607
2687
|
request.method = method
|
|
2608
2688
|
}
|
|
2609
|
-
accessControlRequestHeaders = ( typeof(request.headers['access-control-request-headers']) != 'undefined' ) ? request.headers['access-control-request-headers'] : '';
|
|
2689
|
+
accessControlRequestHeaders = ( typeof(request.headers['access-control-request-headers']) != 'undefined' ) ? request.headers['access-control-request-headers'].replace(/\s+/, '').split(/\,/g) : '';
|
|
2610
2690
|
if ( typeof(request.headers['access-control-request-credentials']) != 'undefined' && typeof(serverResponseHeaders['access-control-allow-credentials']) != 'undefined' ) {
|
|
2611
2691
|
request.isWithCredentials = true;
|
|
2612
2692
|
}
|
|
@@ -2616,6 +2696,7 @@ function Server(options) {
|
|
|
2616
2696
|
request.isXMLRequest = true;
|
|
2617
2697
|
}
|
|
2618
2698
|
}
|
|
2699
|
+
response.setHeader('access-control-allow-headers', request.headers['access-control-request-headers']);
|
|
2619
2700
|
}
|
|
2620
2701
|
}
|
|
2621
2702
|
|
|
@@ -2632,9 +2713,9 @@ function Server(options) {
|
|
|
2632
2713
|
, wroot = null
|
|
2633
2714
|
;
|
|
2634
2715
|
|
|
2635
|
-
//matched =
|
|
2716
|
+
//matched = routingLib.getRouteByUrl(req.url, bundle, (req.method||req[':method']), req);
|
|
2636
2717
|
|
|
2637
|
-
req = checkPreflightRequest(req);
|
|
2718
|
+
req = checkPreflightRequest(req, res);
|
|
2638
2719
|
var params = {}
|
|
2639
2720
|
, _routing = {}
|
|
2640
2721
|
, method = ( /http\/2/.test(self.conf[self.appName][self.env].server.protocol) ) ? req.headers[':method'] : req.method
|
|
@@ -2657,9 +2738,10 @@ function Server(options) {
|
|
|
2657
2738
|
}
|
|
2658
2739
|
var isMethodAllowed = null, hostname = null;
|
|
2659
2740
|
out:
|
|
2660
|
-
for (
|
|
2661
|
-
if (typeof(routing[name]['param']) == 'undefined')
|
|
2741
|
+
for (let name in routing) {
|
|
2742
|
+
if ( typeof(routing[name]['param']) == 'undefined' ) {
|
|
2662
2743
|
break;
|
|
2744
|
+
}
|
|
2663
2745
|
|
|
2664
2746
|
// updating hostname
|
|
2665
2747
|
// if (
|
|
@@ -2687,7 +2769,7 @@ function Server(options) {
|
|
|
2687
2769
|
method : method,
|
|
2688
2770
|
requirements : routing[name].requirements,
|
|
2689
2771
|
namespace : routing[name].namespace || undefined,
|
|
2690
|
-
url :
|
|
2772
|
+
url : decodeURI(pathname), /// avoid %20
|
|
2691
2773
|
rule : routing[name].originalRule || name,
|
|
2692
2774
|
param : JSON.clone(routing[name].param),
|
|
2693
2775
|
middleware : JSON.clone(routing[name].middleware),
|
|
@@ -2698,7 +2780,7 @@ function Server(options) {
|
|
|
2698
2780
|
|
|
2699
2781
|
//Parsing for the right url.
|
|
2700
2782
|
try {
|
|
2701
|
-
isRoute = await
|
|
2783
|
+
isRoute = await routingLib.compareUrls(params, routing[name].url, req, res, next);
|
|
2702
2784
|
} catch (err) {
|
|
2703
2785
|
var msg = 'Internal server error.\nRule [ '+name+' ] needs your attention.\n';
|
|
2704
2786
|
// TODO - Refactor `ApiError`to handle the following param
|
|
@@ -2724,51 +2806,51 @@ function Server(options) {
|
|
|
2724
2806
|
throwError(res, 405, 'Method Not Allowed.\n'+ ' `'+req.url+'` is expecting `' + _routing.method.toUpperCase() +'` method but got `'+ req.method.toUpperCase() +'` instead');
|
|
2725
2807
|
break;
|
|
2726
2808
|
}
|
|
2727
|
-
}
|
|
2809
|
+
}
|
|
2728
2810
|
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
}
|
|
2746
|
-
++p
|
|
2811
|
+
// handling GET method exception - if no param found
|
|
2812
|
+
var methods = ['get', 'delete'], method = req.method.toLowerCase();
|
|
2813
|
+
var p = null;
|
|
2814
|
+
if (
|
|
2815
|
+
methods.indexOf(method) > -1 && typeof(req.query) != 'undefined' && req.query.count() == 0
|
|
2816
|
+
|| methods.indexOf(method) > -1 && typeof(req.query) == 'undefined' && typeof(req.params) != 'undefined' && req.params.count() > 1
|
|
2817
|
+
) {
|
|
2818
|
+
//req.params = parseObject(req.params);
|
|
2819
|
+
p = 0;
|
|
2820
|
+
for (let parameter in req.params) {
|
|
2821
|
+
if (p > 0) {
|
|
2822
|
+
// false & true case
|
|
2823
|
+
if ( /^(false|true|on)$/.test( req.params[parameter] ) && typeof(req.params[parameter]) == 'string' )
|
|
2824
|
+
req.params[parameter] = ( /^(true|on)$/.test( req.params[parameter] ) ) ? true : false;
|
|
2825
|
+
|
|
2826
|
+
req[method][parameter] = req.params[parameter]
|
|
2747
2827
|
}
|
|
2828
|
+
++p
|
|
2829
|
+
}
|
|
2748
2830
|
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2831
|
+
} else if ( method == 'put' ) { // merging req.params with req.put (passed through URI)
|
|
2832
|
+
p = 0;
|
|
2833
|
+
for (let parameter in req.params) {
|
|
2834
|
+
if (p > 0) {
|
|
2835
|
+
// false & true case
|
|
2836
|
+
if ( /^(false|true|on)$/.test( req.params[parameter] ) && typeof(req.params[parameter]) == 'string' )
|
|
2837
|
+
req.params[parameter] = ( /^(true|on)$/.test( req.params[parameter] ) ) ? true : false;
|
|
2756
2838
|
|
|
2757
|
-
|
|
2758
|
-
}
|
|
2759
|
-
++p
|
|
2839
|
+
req[method][parameter] = req.params[parameter]
|
|
2760
2840
|
}
|
|
2841
|
+
++p
|
|
2761
2842
|
}
|
|
2843
|
+
}
|
|
2762
2844
|
|
|
2763
2845
|
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2846
|
+
// onRouting Event ???
|
|
2847
|
+
if (isRoute.past) {
|
|
2848
|
+
matched = true;
|
|
2849
|
+
isRoute = {};
|
|
2850
|
+
|
|
2851
|
+
break;
|
|
2852
|
+
}
|
|
2768
2853
|
|
|
2769
|
-
break;
|
|
2770
|
-
}
|
|
2771
|
-
//}
|
|
2772
2854
|
}
|
|
2773
2855
|
}
|
|
2774
2856
|
|
|
@@ -2783,15 +2865,15 @@ function Server(options) {
|
|
|
2783
2865
|
nextMiddleware._next = next;
|
|
2784
2866
|
nextMiddleware._nextAction = 'route'
|
|
2785
2867
|
|
|
2786
|
-
nextMiddleware()
|
|
2787
|
-
} else {
|
|
2788
|
-
router._server = self.instance;
|
|
2789
|
-
router.route(req, res, next, req.routing)
|
|
2868
|
+
return nextMiddleware()
|
|
2790
2869
|
}
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2870
|
+
|
|
2871
|
+
router._server = self.instance;
|
|
2872
|
+
|
|
2873
|
+
return router.route(req, res, next, req.routing);
|
|
2794
2874
|
}
|
|
2875
|
+
|
|
2876
|
+
return throwError(res, 404, 'Page not found: \n' + pathname, next);
|
|
2795
2877
|
}
|
|
2796
2878
|
|
|
2797
2879
|
|
|
@@ -2810,16 +2892,16 @@ function Server(options) {
|
|
|
2810
2892
|
|
|
2811
2893
|
if ( typeof(msg) != 'object' ) {
|
|
2812
2894
|
err = {
|
|
2813
|
-
code: code,
|
|
2814
|
-
message: msg
|
|
2895
|
+
code : code,
|
|
2896
|
+
message : msg
|
|
2815
2897
|
}
|
|
2816
2898
|
} else {
|
|
2817
2899
|
err = JSON.clone(msg);
|
|
2818
2900
|
}
|
|
2819
2901
|
|
|
2820
2902
|
if (!res.headersSent) {
|
|
2821
|
-
res.headersSent = true;
|
|
2822
|
-
local.request = checkPreflightRequest(local.request);
|
|
2903
|
+
// res.headersSent = true;
|
|
2904
|
+
local.request = checkPreflightRequest(local.request, local.response);
|
|
2823
2905
|
// updated filter on controller.js : 2020/09/25
|
|
2824
2906
|
//if (isXMLRequest || !withViews || !isUsingTemplate ) {
|
|
2825
2907
|
if (isXMLRequest || !withViews || !isUsingTemplate || withViews && !isUsingTemplate ) {
|
|
@@ -2864,8 +2946,8 @@ function Server(options) {
|
|
|
2864
2946
|
|
|
2865
2947
|
} else {
|
|
2866
2948
|
res.end(JSON.stringify({
|
|
2867
|
-
status: code,
|
|
2868
|
-
error: msg
|
|
2949
|
+
status : code,
|
|
2950
|
+
error : msg
|
|
2869
2951
|
}));
|
|
2870
2952
|
}
|
|
2871
2953
|
return;
|
|
@@ -2873,9 +2955,10 @@ function Server(options) {
|
|
|
2873
2955
|
} else {
|
|
2874
2956
|
|
|
2875
2957
|
//console.error('[ BUNDLE ][ '+self.appName+' ] '+ local.request.method +' [ '+code+' ] '+ local.request.url);
|
|
2876
|
-
console.error(local.request.method +' [ '+code+' ] '+ local.request.url);
|
|
2958
|
+
// console.error(local.request.method +' [ '+code+' ] '+ local.request.url);
|
|
2959
|
+
console.error('[ BUNDLE ][ '+self.appName+' ] '+ local.request.method +' [ '+code+' ] \n'+ msg);
|
|
2877
2960
|
// intercept none HTML mime types
|
|
2878
|
-
var url =
|
|
2961
|
+
var url = decodeURI(local.request.url) /// avoid %20
|
|
2879
2962
|
, ext = null
|
|
2880
2963
|
, isHtmlContent = false
|
|
2881
2964
|
, hasCustomErrorFile = false
|
|
@@ -2937,7 +3020,7 @@ function Server(options) {
|
|
|
2937
3020
|
}
|
|
2938
3021
|
|
|
2939
3022
|
var eRule = 'custom-error-page@'+ self.appName;
|
|
2940
|
-
var routeObj =
|
|
3023
|
+
var routeObj = routingLib.getRoute(eRule);
|
|
2941
3024
|
routeObj.rule = eRule;
|
|
2942
3025
|
routeObj.url = url;
|
|
2943
3026
|
routeObj.param.title = ( typeof(eData.title) != 'undefined' ) ? eData.title : 'Error ' + eData.status;
|
|
@@ -2947,30 +3030,36 @@ function Server(options) {
|
|
|
2947
3030
|
|
|
2948
3031
|
local.request.routing = routeObj;
|
|
2949
3032
|
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
// } else {
|
|
3033
|
+
var hasMiddlewareException = null;
|
|
3034
|
+
for (let i=0, len = __stack.length; i<len; i++) {
|
|
3035
|
+
let c = __stack[i].getFunctionName() || null;
|
|
3036
|
+
if ( /processMiddlewares/.test(c) ) {
|
|
3037
|
+
hasMiddlewareException = true;
|
|
3038
|
+
break;
|
|
3039
|
+
}
|
|
3040
|
+
}
|
|
3041
|
+
if ( !hasMiddlewareException ) {
|
|
2960
3042
|
var router = local.router;
|
|
2961
3043
|
if ( typeof(router._server) == 'undefined' ) {
|
|
2962
3044
|
router._server = self.instance;
|
|
2963
3045
|
}
|
|
2964
3046
|
router.route(local.request, res, next, local.request.routing);
|
|
2965
|
-
// }
|
|
2966
3047
|
|
|
2967
|
-
|
|
3048
|
+
return;
|
|
3049
|
+
}
|
|
3050
|
+
hasMiddlewareException = null;
|
|
3051
|
+
// TODO - Instead of setting `hasCustomErrorFile` to false, compile custom error page with:
|
|
3052
|
+
// JSON.stringify({
|
|
3053
|
+
// status : code,
|
|
3054
|
+
// error : msg
|
|
3055
|
+
// })
|
|
3056
|
+
hasCustomErrorFile = false;
|
|
2968
3057
|
}
|
|
2969
3058
|
|
|
2970
3059
|
if ( /http\/2/.test(protocol) && stream ) {
|
|
2971
3060
|
header = {
|
|
2972
|
-
':status': code,
|
|
2973
|
-
'content-type': bundleConf.server.coreConfiguration.mime[ext]+'; charset='+ bundleConf.encoding
|
|
3061
|
+
':status' : code,
|
|
3062
|
+
'content-type' : bundleConf.server.coreConfiguration.mime[ext]+'; charset='+ bundleConf.encoding
|
|
2974
3063
|
};
|
|
2975
3064
|
} else {
|
|
2976
3065
|
res.writeHead(code, { 'content-type': bundleConf.server.coreConfiguration.mime[ext]+'; charset='+ bundleConf.encoding });
|
|
@@ -2984,7 +3073,10 @@ function Server(options) {
|
|
|
2984
3073
|
if ( isHtmlContent && !hasCustomErrorFile ) {
|
|
2985
3074
|
stream.end('<html><body><pre><h1>Error '+ code +'.</h1><pre>'+ msg + '</pre></body></html>');
|
|
2986
3075
|
} else {
|
|
2987
|
-
stream.end(
|
|
3076
|
+
stream.end(JSON.stringify({
|
|
3077
|
+
status : code,
|
|
3078
|
+
error : msg
|
|
3079
|
+
}));
|
|
2988
3080
|
}
|
|
2989
3081
|
|
|
2990
3082
|
// }
|
|
@@ -2992,7 +3084,10 @@ function Server(options) {
|
|
|
2992
3084
|
if ( isHtmlContent && !hasCustomErrorFile ) {
|
|
2993
3085
|
res.end('<html><body><pre><h1>Error '+ code +'.</h1><pre>'+ msg + '</pre></body><html>');
|
|
2994
3086
|
} else {
|
|
2995
|
-
res.end(
|
|
3087
|
+
res.end(JSON.stringify({
|
|
3088
|
+
status : code,
|
|
3089
|
+
error : msg
|
|
3090
|
+
}))
|
|
2996
3091
|
}
|
|
2997
3092
|
}
|
|
2998
3093
|
return;
|