gina 0.1.6-alpha.15 → 0.1.6-alpha.150
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 +14 -8
- package/README.md +13 -4
- package/bin/cli +16 -2
- package/bin/gina +29 -1
- package/framework/{v0.1.6-alpha.15/lib/inherits → v0.1.6-alpha.150}/LICENSE +1 -1
- package/framework/v0.1.6-alpha.150/VERSION +1 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/asset/plugin/README.md +1 -0
- package/framework/v0.1.6-alpha.150/core/asset/plugin/dist/vendor/gina/css/gina.min.css.br +0 -0
- package/framework/v0.1.6-alpha.150/core/asset/plugin/dist/vendor/gina/css/gina.min.css.gz +0 -0
- package/framework/v0.1.6-alpha.150/core/asset/plugin/dist/vendor/gina/css/gina.min.css.map +1 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/asset/plugin/dist/vendor/gina/html/toolbar.html +1 -1
- package/framework/v0.1.6-alpha.150/core/asset/plugin/dist/vendor/gina/html/toolbar.html.br +0 -0
- package/framework/v0.1.6-alpha.150/core/asset/plugin/dist/vendor/gina/html/toolbar.html.gz +0 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/asset/plugin/dist/vendor/gina/js/gina.js +6403 -5609
- package/framework/v0.1.6-alpha.150/core/asset/plugin/dist/vendor/gina/js/gina.min.js +789 -0
- package/framework/v0.1.6-alpha.150/core/asset/plugin/dist/vendor/gina/js/gina.min.js.br +0 -0
- package/framework/v0.1.6-alpha.150/core/asset/plugin/dist/vendor/gina/js/gina.min.js.gz +0 -0
- package/framework/v0.1.6-alpha.150/core/asset/plugin/dist/vendor/gina/js/gina.min.js.map +8 -0
- package/framework/v0.1.6-alpha.150/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js +9 -0
- package/framework/v0.1.6-alpha.150/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js.br +0 -0
- package/framework/v0.1.6-alpha.150/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js.gz +0 -0
- package/framework/v0.1.6-alpha.150/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js.map +8 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/config.js +167 -76
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/connectors/couchbase/index.js +108 -26
- package/framework/{v0.1.6-alpha.15/core/connectors/couchbase/lib/connector.v4.js → v0.1.6-alpha.150/core/connectors/couchbase/lib/connector.v3.js} +170 -69
- package/framework/v0.1.6-alpha.150/core/connectors/couchbase/lib/connector.v4.js +470 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/connectors/couchbase/lib/session-store.v4.js +5 -2
- package/framework/v0.1.6-alpha.150/core/content.encoding +9 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/controller/controller.js +861 -1185
- package/framework/v0.1.6-alpha.150/core/controller/controller.renderSwig.js +1022 -0
- package/framework/v0.1.6-alpha.150/core/controller/controller.renderv1.js +911 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/controller/index.js +2 -2
- package/framework/v0.1.6-alpha.150/core/deps/busboy-1.6.0/.github/workflows/ci.yml +24 -0
- package/framework/v0.1.6-alpha.150/core/deps/busboy-1.6.0/.github/workflows/lint.yml +23 -0
- package/framework/v0.1.6-alpha.150/core/deps/busboy-1.6.0/README.md +191 -0
- package/framework/v0.1.6-alpha.150/core/deps/busboy-1.6.0/bench/bench-multipart-fields-100mb-big.js +149 -0
- package/framework/v0.1.6-alpha.150/core/deps/busboy-1.6.0/bench/bench-multipart-fields-100mb-small.js +143 -0
- package/framework/v0.1.6-alpha.150/core/deps/busboy-1.6.0/bench/bench-multipart-files-100mb-big.js +154 -0
- package/framework/v0.1.6-alpha.150/core/deps/busboy-1.6.0/bench/bench-multipart-files-100mb-small.js +148 -0
- package/framework/v0.1.6-alpha.150/core/deps/busboy-1.6.0/bench/bench-urlencoded-fields-100pairs-small.js +101 -0
- package/framework/v0.1.6-alpha.150/core/deps/busboy-1.6.0/bench/bench-urlencoded-fields-900pairs-small-alt.js +84 -0
- package/framework/v0.1.6-alpha.150/core/deps/busboy-1.6.0/lib/index.js +57 -0
- package/framework/v0.1.6-alpha.150/core/deps/busboy-1.6.0/lib/types/multipart.js +680 -0
- package/framework/v0.1.6-alpha.150/core/deps/busboy-1.6.0/lib/types/urlencoded.js +350 -0
- package/framework/v0.1.6-alpha.150/core/deps/busboy-1.6.0/lib/utils.js +596 -0
- package/framework/v0.1.6-alpha.150/core/deps/busboy-1.6.0/package.json +22 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/.travis.yml +4 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/LICENSE +21 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/example/bool.js +10 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/example/boolean_double.js +7 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/example/boolean_single.js +7 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/example/default_hash.js +8 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/example/default_singles.js +7 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/example/divide.js +8 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/example/line_count.js +20 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/example/line_count_options.js +29 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/example/line_count_wrap.js +29 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/example/nonopt.js +4 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/example/reflect.js +2 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/example/short.js +3 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/example/string.js +11 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/example/usage-options.js +19 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/example/xup.js +10 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/index.js +343 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/package.json +31 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/package.json.dist +39 -0
- package/framework/v0.1.6-alpha.150/core/deps/optimist-0.6.1/readme.markdown +513 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/HISTORY.md +498 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/LICENSE +7 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/README.md +88 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/bin/swig.js +161 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/bin/swig.js.dist +161 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/dist/swig.min.js +7 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/dist/swig.min.js.map +8 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/index.js +1 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/dateformatter.js +198 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/filters.js +630 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/lexer.js +306 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/loaders/filesystem.js +59 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/loaders/index.js +53 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/loaders/memory.js +63 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/parser.js +744 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/swig.js +740 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/tags/autoescape.js +37 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/tags/block.js +25 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/tags/else.js +25 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/tags/elseif.js +28 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/tags/extends.js +19 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/tags/filter.js +68 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/tags/for.js +130 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/tags/if.js +86 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/tags/import.js +91 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/tags/include.js +100 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/tags/index.js +16 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/tags/macro.js +79 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/tags/parent.js +51 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/tags/raw.js +23 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/tags/set.js +109 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/tags/spaceless.js +42 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/lib/utils.js +184 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/package.json +57 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-1.4.2/package.json.dist +61 -0
- package/framework/v0.1.6-alpha.150/core/deps/swig-client/swig.js +5031 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/dev/index.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/dev/lib/factory.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/gna.js +123 -23
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/locales/index.js +3 -3
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/locales/src/make.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/mime.types +1 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/model/entity.js +5 -5
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/model/index.js +30 -26
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/model/template/entityFactory.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/model/template/index.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/plugins/index.js +3 -3
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/plugins/lib/file/package.json +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/plugins/lib/intl/package.json +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/plugins/lib/storage/package.json +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/plugins/lib/validator/package.json +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/plugins/lib/validator/src/form-validator.js +39 -27
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/plugins/lib/validator/src/main.js +496 -119
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/router.js +92 -47
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/server.isaac.js +329 -43
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/server.js +433 -159
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/status.codes +1 -11
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle/controllers/setup.js +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/command/gina.tpl +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/conf/env.json +20 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/conf/settings.json +4 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/conf/templates.json +4 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/console.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/context.js +30 -13
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/data/package.json +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/data/src/main.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/dateFormat.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/index.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/json/package.json +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/json/src/main.js +7 -4
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/path.js +32 -16
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/plugins/package.json +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/plugins/src/api-error.js +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/plugins/src/main.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/prototypes.js +8 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/task.js +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/text.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/archiver/package.json +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/archiver/src/main.js +11 -11
- package/framework/v0.1.6-alpha.150/lib/cache/package.json +20 -0
- package/framework/v0.1.6-alpha.150/lib/cache/src/main.js +160 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/bundle/add.js +2 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/bundle/restart.js +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/bundle/start.js +26 -11
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/env/get.js +1 -1
- package/framework/v0.1.6-alpha.150/lib/cmd/env/help.js +30 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/env/set.js +21 -0
- package/framework/v0.1.6-alpha.150/lib/cmd/framework/arguments.json +7 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/framework/build.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/framework/dot.js +21 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/framework/init.js +19 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/framework/link-node-modules.js +2 -3
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/framework/link.js +3 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/framework/restart.js +3 -3
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/framework/start.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/framework/tail.js +29 -12
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/framework/version.js +15 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/helper.js +44 -15
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/index.js +1 -1
- package/framework/v0.1.6-alpha.150/lib/cmd/minion/help.txt +18 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/port/reset.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/project/add.js +7 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/project/arguments.json +1 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/project/build.js +32 -7
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/project/help.txt +4 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/project/list.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/protocol/list.js +71 -50
- package/framework/v0.1.6-alpha.150/lib/collection/README.md +5 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/collection/package.json +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/collection/src/main.js +21 -14
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/config.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cron/package.json +2 -2
- package/framework/v0.1.6-alpha.150/lib/domain/dist/2025-03-14_13-41-20_UTC.dat +15754 -0
- package/framework/v0.1.6-alpha.150/lib/domain/dist/public_suffix_list.dat +15754 -0
- package/framework/v0.1.6-alpha.150/lib/domain/dist/public_suffix_list.dat.br +0 -0
- package/framework/v0.1.6-alpha.150/lib/domain/dist/public_suffix_list.dat.gz +0 -0
- package/framework/v0.1.6-alpha.150/lib/domain/exemples/backend.js +12 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/domain/package.json +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/domain/src/main.js +75 -13
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/generator/index.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/index.js +3 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150/lib/inherits}/LICENSE +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/inherits/package.json +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/inherits/src/main.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/logger/package.json +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/logger/src/containers/file/index.js +2 -0
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/logger/src/containers/mq/listener.js +10 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/logger/src/helper.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/logger/src/main.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/math/index.js +1 -1
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/merge/package.json +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/model.js +3 -3
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/proc.js +10 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/routing/package.json +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/routing/src/main.js +201 -35
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/session-store.js +3 -3
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/shell.js +7 -6
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/swig-filters/package.json +2 -2
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/swig-filters/src/main.js +100 -17
- package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/validator.js +2 -2
- package/framework/v0.1.6-alpha.150/package.json +11 -0
- package/package.json +3 -3
- package/resources/package.json.template +1 -1
- package/script/post_install.js +4 -4
- package/script/pre_install.js +3 -3
- package/utils/helper.js +38 -14
- package/framework/v0.1.6-alpha.15/VERSION +0 -1
- package/framework/v0.1.6-alpha.15/core/asset/plugin/dist/vendor/gina/css/gina.min.css.map +0 -1
- package/framework/v0.1.6-alpha.15/core/asset/plugin/dist/vendor/gina/js/gina.min.js +0 -766
- package/framework/v0.1.6-alpha.15/core/asset/plugin/dist/vendor/gina/js/gina.min.js.map +0 -8
- package/framework/v0.1.6-alpha.15/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js +0 -7
- package/framework/v0.1.6-alpha.15/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js.map +0 -8
- package/framework/v0.1.6-alpha.15/core/connectors/couchbase/lib/connector.v3.js +0 -432
- package/framework/v0.1.6-alpha.15/core/deps/busboy/.travis.yml +0 -17
- package/framework/v0.1.6-alpha.15/core/deps/busboy/README.md +0 -225
- package/framework/v0.1.6-alpha.15/core/deps/busboy/deps/encoding/encoding-indexes.js +0 -73
- package/framework/v0.1.6-alpha.15/core/deps/busboy/deps/encoding/encoding.js +0 -2391
- package/framework/v0.1.6-alpha.15/core/deps/busboy/lib/main.js +0 -89
- package/framework/v0.1.6-alpha.15/core/deps/busboy/lib/types/multipart.js +0 -328
- package/framework/v0.1.6-alpha.15/core/deps/busboy/lib/types/urlencoded.js +0 -214
- package/framework/v0.1.6-alpha.15/core/deps/busboy/lib/utils.js +0 -191
- package/framework/v0.1.6-alpha.15/core/deps/busboy/package.json +0 -69
- package/framework/v0.1.6-alpha.15/lib/domain/dist/public_suffix_list.dat +0 -14186
- package/framework/v0.1.6-alpha.15/package.json +0 -14
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/AUTHORS +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/asset/html/nolayout.html +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/asset/html/static.html +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/asset/img/android-chrome-192x192.png +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/asset/img/android-chrome-512x512.png +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/asset/img/apple-touch-icon.png +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/asset/img/favicon-16x16.png +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/asset/img/favicon-32x32.png +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/asset/img/favicon.ico +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/asset/plugin/dist/vendor/gina/css/gina.min.css +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/asset/plugin/uuid.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/connectors/couchbase/lib/connector.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/connectors/couchbase/lib/connector.v2.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/connectors/couchbase/lib/n1ql.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/connectors/couchbase/lib/session-store.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/connectors/couchbase/lib/session-store.v2.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/connectors/couchbase/lib/session-store.v3.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/controller/controller.framework.js +0 -0
- /package/framework/{v0.1.6-alpha.15/core/deps/busboy → v0.1.6-alpha.150/core/deps/busboy-1.6.0}/LICENSE +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/deps/swig-client/swig-2.0.0.min.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/dev/lib/class.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/dev/lib/tools.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/locales/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/locales/currency.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/locales/dist/language/en.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/locales/dist/language/fr.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/locales/dist/region/en.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/locales/dist/region/fr.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/locales/src/resources/currency.csv +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/locales/src/resources/region.csv +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/locales/src/resources/region.mapping.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/plugins/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/plugins/lib/file/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/plugins/lib/file/build.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/plugins/lib/intl/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/plugins/lib/intl/build.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/plugins/lib/intl/src/main.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/plugins/lib/storage/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/plugins/lib/storage/build.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/plugins/lib/storage/src/main.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/plugins/lib/validator/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/plugins/lib/validator/build.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/server.express.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/_gitignore +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle/config/app.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle/config/routing.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle/config/settings.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle/config/settings.server.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle/config/templates.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle/controllers/controller.content.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle/controllers/controller.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle/index.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle_namespace/controllers/controller.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle_public/css/default.css +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle_public/css/vendor/readme.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle_public/favicon.ico +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle_public/js/vendor/readme.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle_public/readme.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle_templates/handlers/main.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle_templates/html/content/homepage.html +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle_templates/html/includes/error-msg-noscript.html +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle_templates/html/includes/error-msg-outdated-browser.html +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/boilerplate/bundle_templates/html/layouts/main.html +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/command/gina.bat.tpl +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/conf/manifest.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/conf/package.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/conf/statics.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/error/client/json/401.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/error/client/json/403.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/error/client/json/404.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/error/server/html/50x.html +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/error/server/json/500.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/error/server/json/503.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/core/template/extensions/logger/config.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/data/LICENSE +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/data/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/json/LICENSE +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/json/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/helpers/plugins/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/archiver/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/archiver/build.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/archiver/src/dep/jszip.min.js +0 -0
- /package/framework/{v0.1.6-alpha.15/lib/collection → v0.1.6-alpha.150/lib/cache}/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15/lib/collection → v0.1.6-alpha.150/lib/cache}/build.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/aliases.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/bundle/arguments.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/bundle/copy.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/bundle/cp.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/bundle/help.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/bundle/help.txt +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/bundle/list.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/bundle/remove.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/bundle/rename.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/bundle/rm.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/bundle/status.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/bundle/stop.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/env/add.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/env/help.txt +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/env/link-dev.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/env/list.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/env/remove.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/env/rm.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/env/unset.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/env/use.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/framework/get.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/framework/help.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/framework/help.txt +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/framework/msg.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/framework/open.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/framework/set.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/framework/status.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/framework/stop.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/framework/update.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/gina-dev.1.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/gina-framework.1.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/gina.1.md +0 -0
- /package/framework/{v0.1.6-alpha.15/lib/cmd/env → v0.1.6-alpha.150/lib/cmd/minion}/help.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/msg.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/port/help.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/port/help.txt +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/port/inc/scan.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/port/list.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/port/set.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/project/help.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/project/import.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/project/move.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/project/remove.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/project/rename.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/project/restart.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/project/rm.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/project/start.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/project/status.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/project/stop.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/protocol/help.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/protocol/help.txt +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/protocol/set.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/scope/add.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/scope/help.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/scope/help.txt +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/scope/link-local.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/scope/link-production.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/scope/list.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/scope/remove.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/scope/rm.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/scope/use.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cmd/view/add.js +0 -0
- /package/framework/{v0.1.6-alpha.15/lib/routing → v0.1.6-alpha.150/lib/collection}/build.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cron/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/cron/src/main.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/domain/LICENSE +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/domain/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/domain/exemples/frontend.html +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/inherits/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/inherits/example/inheriting_eventemitter.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/inherits/example/protected_inheritance.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/inherits/example/simple_inheritance.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/inherits/example/super_attribute_overridden_by_child_on_init.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/logger/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/logger/src/containers/default/index.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/logger/src/containers/file/lib/logrotator/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/logger/src/containers/file/lib/logrotator/index.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/logger/src/containers/mq/index.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/logger/src/containers/mq/speaker.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/merge/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/merge/example/merge.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/merge/example/merge_2_literal objects.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/merge/example/merge_and_preserve_first.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/merge/src/main.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/routing/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15/lib/domain/exemples/backend.js → v0.1.6-alpha.150/lib/routing/build.json} +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/swig-filters/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/url/README.md +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/url/index.js +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/url/mocks.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/url/routing.json +0 -0
- /package/framework/{v0.1.6-alpha.15 → v0.1.6-alpha.150}/lib/url/test.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
3
|
* This file is part of the gina package.
|
|
4
|
-
* Copyright (c) 2009-
|
|
4
|
+
* Copyright (c) 2009-2025 Rhinostone <contact@gina.io>
|
|
5
5
|
*
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
@@ -10,14 +10,13 @@
|
|
|
10
10
|
//Imports.
|
|
11
11
|
var fs = require('fs');
|
|
12
12
|
const {promises: {readFile}} = require("fs");
|
|
13
|
+
const exec = require('child_process').exec;
|
|
13
14
|
var util = require('util');
|
|
14
15
|
var promisify = util.promisify;
|
|
15
16
|
var EventEmitter = require('events').EventEmitter;
|
|
16
|
-
var zlib = require('zlib');
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// var crypto = require('crypto');
|
|
18
|
+
const { Resolver } = require('node:dns').promises;
|
|
19
|
+
const resolver = new Resolver();
|
|
21
20
|
|
|
22
21
|
var lib = require('./../../lib') || require.cache[require.resolve('./../../lib')];
|
|
23
22
|
var merge = lib.merge;
|
|
@@ -25,9 +24,10 @@ var inherits = lib.inherits;
|
|
|
25
24
|
var console = lib.logger;
|
|
26
25
|
var Collection = lib.Collection;
|
|
27
26
|
var routingLib = lib.routing;
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
var Domain = lib.Domain;
|
|
28
|
+
var domainLib = new Domain();
|
|
29
|
+
var swig = require('./../deps/swig-1.4.2');
|
|
30
|
+
const { type } = require('node:os');
|
|
31
31
|
var SwigFilters = lib.SwigFilters;
|
|
32
32
|
var statusCodes = requireJSON( _( getPath('gina').core + '/status.codes') );
|
|
33
33
|
|
|
@@ -68,29 +68,26 @@ function SuperController(options) {
|
|
|
68
68
|
var init = function() {
|
|
69
69
|
|
|
70
70
|
if ( typeof(SuperController.initialized) != 'undefined' ) {
|
|
71
|
-
return getInstance()
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
SuperController.instance = self;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (local.options) {
|
|
78
|
-
SuperController.instance._options = local.options;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
SuperController.initialized = true;
|
|
71
|
+
return getInstance();
|
|
72
|
+
}
|
|
82
73
|
|
|
74
|
+
SuperController.instance = self;
|
|
75
|
+
if (local.options) {
|
|
76
|
+
SuperController.instance._options = local.options;
|
|
83
77
|
}
|
|
78
|
+
|
|
79
|
+
SuperController.initialized = true;
|
|
84
80
|
}
|
|
85
81
|
|
|
86
82
|
var getInstance = function() {
|
|
87
83
|
local.options = SuperController.instance._options = options;
|
|
88
|
-
// 2022-03-07
|
|
84
|
+
// Fixed on 2022-03-07 for none-developpement environnements (without cache)
|
|
89
85
|
self._options = local.options;
|
|
90
86
|
|
|
91
87
|
return SuperController.instance;
|
|
92
88
|
}
|
|
93
89
|
|
|
90
|
+
|
|
94
91
|
var hasViews = function() {
|
|
95
92
|
return ( typeof(local.options.template) != 'undefined' ) ? true : false;
|
|
96
93
|
}
|
|
@@ -195,12 +192,12 @@ function SuperController(options) {
|
|
|
195
192
|
return (/^true$/i.test(process.env.NODE_SCOPE_IS_PRODUCTION)) ? true : false;
|
|
196
193
|
}
|
|
197
194
|
|
|
195
|
+
|
|
198
196
|
this.setOptions = function(req, res, next, options) {
|
|
199
197
|
local.options = SuperController.instance._options = options;
|
|
200
198
|
local.options.renderingStack = (local.options.renderingStack) ? local.options.renderingStack : [];
|
|
201
199
|
local.options.isRenderingCustomError = (local.options.isRenderingCustomError) ? local.options.isRenderingCustomError : false;
|
|
202
200
|
|
|
203
|
-
|
|
204
201
|
// N.B.: Avoid setting `page` properties as much as possible from the routing.json
|
|
205
202
|
// It will be easier for the framework if set from the controller.
|
|
206
203
|
//
|
|
@@ -240,12 +237,12 @@ function SuperController(options) {
|
|
|
240
237
|
|
|
241
238
|
if ( /^:/.test(value) ) {
|
|
242
239
|
str = 'page.view.params.'+ key + '.';
|
|
243
|
-
set(str.
|
|
240
|
+
set(str.substring(0, str.length-1), req.params[value.substring(1)]);
|
|
244
241
|
} else if (/^(file|title)$/.test(key)) {
|
|
245
242
|
str = 'page.view.'+ key + '.';
|
|
246
|
-
set(str.
|
|
243
|
+
set(str.substring(0, str.length-1), value);
|
|
247
244
|
} else {
|
|
248
|
-
set(str.
|
|
245
|
+
set(str.substring(0, str.length-1), value)
|
|
249
246
|
}
|
|
250
247
|
|
|
251
248
|
str = 'page.'
|
|
@@ -322,10 +319,24 @@ function SuperController(options) {
|
|
|
322
319
|
|
|
323
320
|
var ctx = getContext('gina');
|
|
324
321
|
// new declaration && overrides
|
|
322
|
+
var arch = process.arch;
|
|
323
|
+
switch (process.arch) {
|
|
324
|
+
case 'x64':
|
|
325
|
+
arch = 'amd64'
|
|
326
|
+
break;
|
|
327
|
+
case 'armv7l':
|
|
328
|
+
arch = 'armhf'
|
|
329
|
+
break;
|
|
330
|
+
case 'x86':
|
|
331
|
+
arch = 'i386'
|
|
332
|
+
break;
|
|
333
|
+
default:
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
325
336
|
var version = {
|
|
326
337
|
"number" : ctx.version,
|
|
327
338
|
"platform" : process.platform,
|
|
328
|
-
"arch" :
|
|
339
|
+
"arch" : arch,
|
|
329
340
|
"nodejs" : process.versions.node,
|
|
330
341
|
"middleware" : ctx.middleware
|
|
331
342
|
};
|
|
@@ -336,27 +347,139 @@ function SuperController(options) {
|
|
|
336
347
|
set('page.environment.gina pid', GINA_PID);
|
|
337
348
|
set('page.environment.nodejs', version.nodejs +' '+ version.platform +' '+ version.arch);
|
|
338
349
|
set('page.environment.engine', options.conf.server.engine);//version.middleware
|
|
350
|
+
set('page.environment.uvThreadpoolSize', process.env.UV_THREADPOOL_SIZE);
|
|
339
351
|
set('page.environment.env', process.env.NODE_ENV);
|
|
340
|
-
set('page.environment.envIsDev',
|
|
352
|
+
set('page.environment.envIsDev', /^true$/i.test(process.env.NODE_ENV_IS_DEV) );
|
|
341
353
|
set('page.environment.scope', process.env.NODE_SCOPE);
|
|
342
354
|
set('page.environment.scopeIsLocal', /^true$/i.test(process.env.NODE_SCOPE_IS_LOCAL) );
|
|
343
355
|
set('page.environment.scopeIsProduction', /^true$/i.test(process.env.NODE_SCOPE_IS_PRODUCTION) );
|
|
344
356
|
set('page.environment.date.now', new Date().format("isoDateTime"));
|
|
357
|
+
set('page.environment.isCacheless', self.isCacheless());
|
|
358
|
+
|
|
359
|
+
// var requestPort = req.headers.port || req.headers[':port'];
|
|
360
|
+
// var isProxyHost = (
|
|
361
|
+
// typeof(req.headers.host) != 'undefined'
|
|
362
|
+
// && typeof(requestPort) != 'undefined'
|
|
363
|
+
// && /^(80|443)$/.test(requestPort)
|
|
364
|
+
// && local.options.conf.server.scheme +'://'+ req.headers.host +':'+ requestPort != local.options.conf.hostname.replace(/\:\d+$/, '') +':'+ local.options.conf.server.port
|
|
365
|
+
// ||
|
|
366
|
+
// typeof(req.headers[':authority']) != 'undefined'
|
|
367
|
+
// && local.options.conf.server.scheme +'://'+ req.headers[':authority'] != local.options.conf.hostname
|
|
368
|
+
// ||
|
|
369
|
+
// typeof(req.headers.host) != 'undefined'
|
|
370
|
+
// && typeof(requestPort) != 'undefined'
|
|
371
|
+
// && /^(80|443)$/.test(requestPort)
|
|
372
|
+
// && req.headers.host == local.options.conf.host
|
|
373
|
+
// ||
|
|
374
|
+
// typeof(req.headers['x-nginx-proxy']) != 'undefined'
|
|
375
|
+
// && /^true$/i.test(req.headers['x-nginx-proxy'])
|
|
376
|
+
// ) ? true : false;
|
|
377
|
+
// setContext('isProxyHost', isProxyHost);
|
|
378
|
+
var isProxyHost = getContext('isProxyHost') || false;
|
|
379
|
+
set('page.environment.isProxyHost', isProxyHost);
|
|
380
|
+
if ( /^true$/.test(isProxyHost) ) {
|
|
381
|
+
set('page.environment.proxyHost', process.gina.PROXY_HOST);
|
|
382
|
+
set('page.environment.proxyHostname', process.gina.PROXY_HOSTNAME);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
var _config = ctx.config.envConf[options.conf.bundle][process.env.NODE_ENV];
|
|
386
|
+
// by default
|
|
387
|
+
var hostname = _config.hostname + _config.server.webroot;
|
|
388
|
+
var scheme = hostname.match(/^(https|http)/)[0];
|
|
389
|
+
var requestPort = (local.req.headers.port||local.req.headers[':port']);
|
|
390
|
+
|
|
391
|
+
var hostPort = hostname.match(/(\:d+\/|\:\d+)$/);
|
|
392
|
+
hostPort = (hostPort) ? ~~(hostPort[0].replace(/\:/g, '')) : _config.port[_config.server.protocol][_config.server.scheme];
|
|
393
|
+
// Linking bundle B from bundle A wihtout proxy
|
|
394
|
+
var isSpecialCase = (
|
|
395
|
+
getContext('bundle') != _config.bundle
|
|
396
|
+
&& requestPort != hostPort
|
|
397
|
+
&& local.req.headers[':host'] != process.gina.PROXY_HOST
|
|
398
|
+
) ? true : false;
|
|
399
|
+
|
|
400
|
+
if (isSpecialCase) {
|
|
401
|
+
hostname = _config.hostname;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// if (
|
|
405
|
+
// isProxyHost
|
|
406
|
+
// && !isSpecialCase
|
|
407
|
+
// ) {
|
|
408
|
+
// // Rewrite hostname vs req.headers.host
|
|
409
|
+
// hostname = scheme + '://'+ (local.req.headers.host||local.req.headers[':host']);
|
|
410
|
+
|
|
411
|
+
// if (
|
|
412
|
+
// !/^(80|443)$/.test(requestPort)
|
|
413
|
+
// && !new RegExp(requestPort+'$').test(hostname)
|
|
414
|
+
// ) {
|
|
415
|
+
// hostname += ':'+ requestPort;
|
|
416
|
+
// }
|
|
417
|
+
// }
|
|
418
|
+
|
|
419
|
+
set('page.environment.hostname', hostname);
|
|
420
|
+
// Updating _config.rootDomain - 2024/04/15
|
|
421
|
+
// _config.rootDomain = domainLib.getRootDomain(hostname).value;
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
set('page.environment.rootDomain', _config.rootDomain);
|
|
425
|
+
set('page.environment.webroot', options.conf.server.webroot);
|
|
426
|
+
|
|
427
|
+
if ( typeof(ctx.config.envConf._isRoutingUpdateNeeded) == 'undefined') {
|
|
428
|
+
ctx.config.envConf._isRoutingUpdateNeeded = false;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
if (
|
|
432
|
+
typeof(ctx.config.envConf._proxyHostname) == 'undefined'
|
|
433
|
+
||
|
|
434
|
+
hostname != ctx.config.envConf._proxyHostname
|
|
435
|
+
) {
|
|
436
|
+
ctx.config.envConf._proxyHostname = (isProxyHost) ? hostname : null;
|
|
437
|
+
ctx.config.envConf._isRoutingUpdateNeeded = true;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
if ( typeof(ctx.config.envConf._routingCloned) == 'undefined' ) {
|
|
441
|
+
ctx.config.envConf._routingCloned = JSON.clone(ctx.config.envConf.routing);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
var routing = local.options.conf.routing = ctx.config.envConf._routingCloned; // all routes
|
|
445
|
+
if ( /^true$/i.test(ctx.config.envConf._isRoutingUpdateNeeded) ) {
|
|
446
|
+
|
|
447
|
+
for (let r in ctx.config.envConf.routing) {
|
|
448
|
+
if ( isProxyHost ) {
|
|
449
|
+
local.options.conf.routing[r].host = hostname.replace(/^(https|http)\:\/\//, '');
|
|
450
|
+
local.options.conf.routing[r].hostname = hostname;
|
|
451
|
+
let scheme = hostname.match(/^(https|http)/)[0];
|
|
452
|
+
local.options.conf.routing[r].hostname = scheme + '://'+ (local.req.headers.host||local.req.headers[':host']);
|
|
453
|
+
let requestPort = (local.req.headers.port||local.req.headers[':port']);
|
|
454
|
+
if (
|
|
455
|
+
!/^(80|443)$/.test(requestPort)
|
|
456
|
+
&& !new RegExp(requestPort+'$').test(local.options.conf.routing[r].hostname)
|
|
457
|
+
) {
|
|
458
|
+
local.options.conf.routing[r].hostname += ':'+ requestPort
|
|
459
|
+
}
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
local.options.conf.routing[r].host = ctx.config.envConf.routing[r].host;
|
|
463
|
+
local.options.conf.routing[r].hostname = ctx.config.envConf.routing[r].hostname;
|
|
464
|
+
}
|
|
465
|
+
ctx.config.envConf._isRoutingUpdateNeeded = false;
|
|
345
466
|
|
|
467
|
+
}
|
|
468
|
+
// Adding 289 KB of datas in the page when including routing & reverseRouting
|
|
469
|
+
// set('page.environment.routing', encodeRFC5987ValueChars(JSON.stringify(routing))); // export for GFF
|
|
470
|
+
set('page.environment.routing',encodeRFC5987ValueChars('{}'));
|
|
346
471
|
|
|
347
|
-
|
|
348
|
-
set('page.environment.routing', encodeRFC5987ValueChars(JSON.stringify(routing))); // export for GFF
|
|
349
|
-
//reverseRouting
|
|
472
|
+
//// reverseRouting
|
|
350
473
|
var reverseRouting = local.options.conf.reverseRouting = ctx.config.envConf.reverseRouting; // all routes
|
|
351
|
-
set('page.environment.reverseRouting', encodeRFC5987ValueChars(JSON.stringify(reverseRouting))); // export for GFF
|
|
474
|
+
// set('page.environment.reverseRouting', encodeRFC5987ValueChars(JSON.stringify(reverseRouting))); // export for GFF
|
|
475
|
+
set('page.environment.reverseRouting',encodeRFC5987ValueChars('{}'));
|
|
352
476
|
|
|
353
477
|
var forms = local.options.conf.forms = options.conf.content.forms // all forms
|
|
354
478
|
set('page.environment.forms', encodeRFC5987ValueChars(JSON.stringify(forms))); // export for GFF
|
|
355
479
|
set('page.forms', options.conf.content.forms);
|
|
356
480
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
set('page.environment.webroot', options.conf.server.webroot);
|
|
481
|
+
|
|
482
|
+
|
|
360
483
|
set('page.environment.bundle', options.conf.bundle);
|
|
361
484
|
set('page.environment.project', options.conf.projectName);
|
|
362
485
|
set('page.environment.protocol', options.conf.server.protocol);
|
|
@@ -426,7 +549,7 @@ function SuperController(options) {
|
|
|
426
549
|
// user locale
|
|
427
550
|
options.conf.locale = new Collection(userLocales).findOne({ short: userCountryCode }) || {};
|
|
428
551
|
|
|
429
|
-
//
|
|
552
|
+
// current date
|
|
430
553
|
if ( typeof(options.conf.locale) == 'undefined' || !options.conf.locale ) {
|
|
431
554
|
options.conf.locale = {}
|
|
432
555
|
}
|
|
@@ -437,21 +560,16 @@ function SuperController(options) {
|
|
|
437
560
|
set('page.view.lang', userCulture);
|
|
438
561
|
}
|
|
439
562
|
|
|
440
|
-
if ( !getContext('isProxyHost') ) {
|
|
441
|
-
var isProxyHost = ( typeof(req.headers.host) != 'undefined' && local.options.conf.server.scheme +'://'+ req.headers.host != local.options.conf.hostname || typeof(req.headers[':authority']) != 'undefined' && local.options.conf.server.scheme +'://'+ req.headers[':authority'] != local.options.conf.hostname ) ? true : false;
|
|
442
|
-
setContext('isProxyHost', isProxyHost);
|
|
443
|
-
isProxyHost = null;
|
|
444
|
-
}
|
|
445
563
|
|
|
446
564
|
//TODO - detect when to use swig
|
|
447
565
|
var dir = null;
|
|
448
566
|
if (local.options.template || self.templates) {
|
|
449
|
-
dir = local.options.template.
|
|
567
|
+
dir = local.options.template.html || self.templates;
|
|
450
568
|
|
|
451
569
|
var swigOptions = {
|
|
452
570
|
autoescape : ( typeof(local.options.autoescape) != 'undefined') ? local.options.autoescape : false,
|
|
453
571
|
// `memory` is no working yet ... advanced rendering setup required
|
|
454
|
-
// cache : (local.options.
|
|
572
|
+
// cache : (local.options.isCacheless) ? false : 'memory'
|
|
455
573
|
cache : false
|
|
456
574
|
};
|
|
457
575
|
if (dir) {
|
|
@@ -470,6 +588,7 @@ function SuperController(options) {
|
|
|
470
588
|
swig.setDefaultTZOffset(defaultTZOffset);
|
|
471
589
|
defaultTZOffset = null;
|
|
472
590
|
|
|
591
|
+
|
|
473
592
|
self.engine = swig;
|
|
474
593
|
|
|
475
594
|
dir = null;
|
|
@@ -480,867 +599,319 @@ function SuperController(options) {
|
|
|
480
599
|
freeMemory([action, rule, ext, isWithoutLayout, namespace, ctx, version, routing, reverseRouting, forms, parameters, acceptLanguage, userCulture, userCultureCode, userLangCode, userCountryCode, locales, userLocales], false);
|
|
481
600
|
}
|
|
482
601
|
|
|
483
|
-
|
|
602
|
+
var parseDataObject = function(o, obj, override) {
|
|
484
603
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
604
|
+
for (let i in o) {
|
|
605
|
+
if ( o[i] !== null && typeof(o[i]) == 'object' || override && o[i] !== null && typeof(o[i]) == 'object' ) {
|
|
606
|
+
parseDataObject(o[i], obj);
|
|
607
|
+
} else if (o[i] == '_content_'){
|
|
608
|
+
o[i] = obj
|
|
609
|
+
}
|
|
488
610
|
}
|
|
489
611
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
self.render(data, displayToolbar);
|
|
612
|
+
return o
|
|
493
613
|
}
|
|
494
614
|
|
|
495
615
|
/**
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
* Extend default filters
|
|
499
|
-
* - length
|
|
500
|
-
*
|
|
501
|
-
* Avilable filters:
|
|
502
|
-
* - getWebroot()
|
|
503
|
-
* - getUrl()
|
|
504
|
-
*
|
|
505
|
-
* N.B.: Filters can be extended through your `<project>/src/<bundle>/controllers/setup.js`
|
|
616
|
+
* Set data
|
|
506
617
|
*
|
|
618
|
+
* @param {string} nave - variable name to set
|
|
619
|
+
* @param {string|object} value - value to set
|
|
620
|
+
* @param {boolean} [override]
|
|
507
621
|
*
|
|
508
|
-
* @param {object} userData
|
|
509
|
-
* @param {boolean} [displayToolbar]
|
|
510
|
-
* @param {object} [errOptions]
|
|
511
622
|
* @returns {void}
|
|
512
623
|
* */
|
|
513
|
-
|
|
514
|
-
var err = null;
|
|
515
|
-
var isRenderingCustomError = (
|
|
516
|
-
typeof(userData.isRenderingCustomError) != 'undefined'
|
|
517
|
-
&& /^true$/i.test(userData.isRenderingCustomError)
|
|
518
|
-
) ? true : false;
|
|
519
|
-
if (isRenderingCustomError)
|
|
520
|
-
delete userData.isRenderingCustomError;
|
|
521
|
-
|
|
522
|
-
var localOptions = (errOptions) ? errOptions : local.options;
|
|
523
|
-
localOptions.renderingStack.push( self.name );
|
|
524
|
-
// preventing multiple call of self.render() when controller is rendering from another required controller
|
|
525
|
-
if ( localOptions.renderingStack.length > 1 && !isRenderingCustomError ) {
|
|
526
|
-
return false;
|
|
527
|
-
}
|
|
624
|
+
var set = function(name, value, override) {
|
|
528
625
|
|
|
626
|
+
var override = ( typeof(override) != 'undefined' ) ? override : false;
|
|
529
627
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
, plugin = null
|
|
536
|
-
// By default
|
|
537
|
-
, isWithoutLayout = (localOptions.isWithoutLayout) ? true : false
|
|
538
|
-
;
|
|
628
|
+
if ( typeof(name) == 'string' && /\./.test(name) ) {
|
|
629
|
+
var keys = name.split(/\./g)
|
|
630
|
+
, newObj = {}
|
|
631
|
+
, str = '{'
|
|
632
|
+
, _count = 0;
|
|
539
633
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
// Display session
|
|
543
|
-
if (
|
|
544
|
-
typeof(local.req.session) != 'undefined'
|
|
545
|
-
) {
|
|
546
|
-
if ( typeof(data.page.data) == 'undefined' ) {
|
|
547
|
-
data.page.data = {};
|
|
548
|
-
}
|
|
634
|
+
for (let k = 0, len = keys.length; k<len; ++k) {
|
|
635
|
+
str += "\""+ keys.splice(0,1)[0] + "\":{";
|
|
549
636
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
var elapsed = dateEnd - dateStart;
|
|
557
|
-
// var expiresAt =
|
|
558
|
-
if ( typeof(data.page.data.session) == 'undefined' ) {
|
|
559
|
-
data.page.data.session = {
|
|
560
|
-
id : local.req.session.id,
|
|
561
|
-
lastModified: local.req.session.lastModified
|
|
562
|
-
};
|
|
637
|
+
++_count;
|
|
638
|
+
if (k == len-1) {
|
|
639
|
+
str = str.substring(0, str.length-1);
|
|
640
|
+
str += "\"_content_\"";
|
|
641
|
+
for (let c = 0; c<_count; ++c) {
|
|
642
|
+
str += "}"
|
|
563
643
|
}
|
|
564
|
-
// In milliseconds
|
|
565
|
-
data.page.data.session.createdAt = local.req.session.createdAt;
|
|
566
|
-
data.page.data.session.expiresAt = dateEnd.format('isoDateTime');
|
|
567
|
-
data.page.data.session.timeout = elapsed;
|
|
568
|
-
|
|
569
|
-
dateEnd = null;
|
|
570
|
-
dateStart = null;
|
|
571
|
-
elapsed = null;
|
|
572
644
|
}
|
|
573
645
|
}
|
|
574
646
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
local.req.routing.param.file
|
|
578
|
-
&& local.req.routing.param.file != data.page.view.file
|
|
579
|
-
) {
|
|
580
|
-
data.page.view.file = local.req.routing.param.file;
|
|
581
|
-
}
|
|
582
|
-
if (
|
|
583
|
-
local.req.routing.param.ext
|
|
584
|
-
&& local.req.routing.param.ext != data.page.view.ext
|
|
585
|
-
) {
|
|
586
|
-
data.page.view.ext = local.req.routing.param.ext;
|
|
587
|
-
}
|
|
588
|
-
file = (isRenderingCustomError) ? localOptions.file : data.page.view.file;
|
|
589
|
-
// making path thru [namespace &] file
|
|
590
|
-
if ( typeof(localOptions.namespace) != 'undefined' && localOptions.namespace ) {
|
|
591
|
-
// excepted for custom paths
|
|
592
|
-
var fileNamingConvention = file.replace(localOptions.namespace+'-', '');
|
|
593
|
-
if ( !/^(\.|\/|\\)/.test(file) && file != fileNamingConvention ) {
|
|
594
|
-
var _ext = data.page.view.ext;
|
|
595
|
-
|
|
596
|
-
console.warn('file `'+ file +'` used in routing `'+ localOptions.rule +'` does not respect gina naming convention ! You should rename the file `'+ file + _ext +'` to `'+ ''+ fileNamingConvention + _ext +'`');
|
|
597
|
-
console.warn('The reason you are getting this message is because your filename begeins with `<namespace>-`\n If you don\‘t want to rename, use template path like ./../'+ localOptions.namespace +'/'+file);
|
|
598
|
-
file = ''+ file.replace(localOptions.namespace+'-', '');
|
|
599
|
-
}
|
|
600
|
-
fileNamingConvention = null;
|
|
601
|
-
_ext = null;
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
// means that rule name === namespace -> pointing to root namespace dir
|
|
605
|
-
if (!file || file === localOptions.namespace) {
|
|
606
|
-
file = 'index'
|
|
607
|
-
}
|
|
608
|
-
path = (isRenderingCustomError) ? _(file) : _(localOptions.template.html +'/'+ localOptions.namespace + '/' + file)
|
|
609
|
-
} else {
|
|
610
|
-
if ( localOptions.path && !/(\?|\#)/.test(localOptions.path) ) {
|
|
611
|
-
path = _(localOptions.path);
|
|
612
|
-
var re = new RegExp( data.page.view.ext+'$');
|
|
613
|
-
if ( data.page.view.ext && re.test(data.page.view.file) ) {
|
|
614
|
-
data.page.view.path = path.replace('/'+ data.page.view.file, '');
|
|
647
|
+
newObj = parseDataObject(JSON.parse(str), value, override);
|
|
648
|
+
local.userData = merge(local.userData, newObj);
|
|
615
649
|
|
|
616
|
-
|
|
617
|
-
data.page.view.file = data.page.view.file.replace(re, '');
|
|
650
|
+
freeMemory([name, value, keys, newObj, str, _count], false);
|
|
618
651
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
path = (!isRenderingCustomError && !/^(\.|\/|\\)/.test(file))
|
|
625
|
-
? _(localOptions.template.html +'/'+ file)
|
|
626
|
-
: file
|
|
627
|
-
}
|
|
628
|
-
}
|
|
652
|
+
} else if ( typeof(local.userData[name]) == 'undefined' ) {
|
|
653
|
+
local.userData[name] = value.replace(/\\/g, '');
|
|
654
|
+
freeMemory([name, value], false)
|
|
655
|
+
}
|
|
656
|
+
}
|
|
629
657
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
658
|
+
/**
|
|
659
|
+
* Get data
|
|
660
|
+
*
|
|
661
|
+
* @param {String} variable Data name to set
|
|
662
|
+
* @returns {Object | String} data Data object or String
|
|
663
|
+
* */
|
|
664
|
+
var get = function(variable) {
|
|
665
|
+
return local.userData[variable]
|
|
666
|
+
}
|
|
633
667
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
668
|
+
/**
|
|
669
|
+
* Set resources
|
|
670
|
+
*
|
|
671
|
+
* @param {object} template - template configuration
|
|
672
|
+
* */
|
|
673
|
+
var setResources = function(viewConf) {
|
|
674
|
+
if (!viewConf) {
|
|
675
|
+
return self.throwError(500, new Error('No views configuration found. Did you try to add views before using Controller::render(...) ? Try to run: gina view:add '+ options.conf.bundle +' @'+ options.conf.projectName));
|
|
637
676
|
}
|
|
638
677
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
var
|
|
642
|
-
var hasLayoutInPath = /\{\%(\s+extends|extends)/.test(_templateContent) || false;
|
|
643
|
-
var layoutPath = null;
|
|
644
|
-
|
|
678
|
+
var authority = ( typeof(local.req.headers['x-forwarded-proto']) != 'undefined' ) ? local.req.headers['x-forwarded-proto'] : local.options.conf.server.scheme;
|
|
679
|
+
authority += '://'+ local.req.headers.host;
|
|
680
|
+
var useWebroot = false;
|
|
645
681
|
if (
|
|
646
|
-
|
|
647
|
-
&&
|
|
648
|
-
&&
|
|
649
|
-
&& !hasLayoutInPath
|
|
682
|
+
!/^\/$/.test(local.options.conf.server.webroot)
|
|
683
|
+
&& local.options.conf.server.webroot.length > 0
|
|
684
|
+
// && local.options.conf.hostname.replace(/\:\d+$/, '') == authority
|
|
650
685
|
) {
|
|
651
|
-
|
|
652
|
-
}
|
|
653
|
-
pageContentObj = null;
|
|
654
|
-
|
|
655
|
-
// Retrieve layoutPath from content
|
|
656
|
-
if (hasLayoutInPath && _templateContent) {
|
|
657
|
-
var extendFound = _templateContent.match(/\{\%(\s+extends|extends)(.*)\%}/);
|
|
658
|
-
if (extendFound && Array.isArray(extendFound)) {
|
|
659
|
-
var extendPath = null;
|
|
660
|
-
try {
|
|
661
|
-
// localOptions.template.templates +'/'+
|
|
662
|
-
layoutPath = extendFound[0].match(/(\"|\')(.*)(\"|\')/)[0].replace(/(\"|\')/g, '');
|
|
663
|
-
data.page.view.layout = layoutPath;
|
|
664
|
-
layoutPath = localOptions.template.templates +'/'+ layoutPath;
|
|
665
|
-
localOptions.template.layout = layoutPath;
|
|
666
|
-
} catch (extendErr) {
|
|
667
|
-
// nothing to do
|
|
668
|
-
}
|
|
669
|
-
extendPath = null;
|
|
670
|
-
}
|
|
671
|
-
extendFound = null;
|
|
686
|
+
useWebroot = true
|
|
672
687
|
}
|
|
673
|
-
|
|
674
|
-
_templateContent = null;
|
|
688
|
+
authority = null;
|
|
675
689
|
|
|
676
|
-
|
|
690
|
+
var reURL = new RegExp('^'+ local.options.conf.server.webroot);
|
|
677
691
|
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
localOptions.debugMode = true;
|
|
697
|
-
} else if ( localOptions.debugMode == undefined ) {
|
|
698
|
-
localOptions.debugMode = self.isCacheless()
|
|
692
|
+
var cssStr = ''
|
|
693
|
+
, jsStr = ''
|
|
694
|
+
;
|
|
695
|
+
//Get css
|
|
696
|
+
if( viewConf.stylesheets ) {
|
|
697
|
+
// cssStr = getNodeRes('css', viewConf.stylesheets, useWebroot, reURL);
|
|
698
|
+
// Fixed on 2025-03-08: ordered by route, making sure that _common could all be loaded first
|
|
699
|
+
var cssColl = new Collection(viewConf.stylesheets).orderBy({route: 'asc'})
|
|
700
|
+
cssStr = getNodeRes('css', cssColl, useWebroot, reURL);
|
|
701
|
+
cssColl = null;
|
|
702
|
+
}
|
|
703
|
+
//Get js
|
|
704
|
+
if( viewConf.javascripts ) {
|
|
705
|
+
// jsStr = getNodeRes('js', viewConf.javascripts, useWebroot, reURL);
|
|
706
|
+
// Fixed on 2025-03-08: ordered by route, making sure that _common could all be loaded first
|
|
707
|
+
var jsColl = new Collection(viewConf.javascripts).orderBy({route: 'asc'})
|
|
708
|
+
jsStr = getNodeRes('js', jsColl, useWebroot, reURL);
|
|
709
|
+
jsColl = null;
|
|
699
710
|
}
|
|
700
711
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
if (!userData) {
|
|
704
|
-
userData = { page: { view: {}}}
|
|
705
|
-
} else if ( userData && !userData['page']) {
|
|
712
|
+
set('page.view.stylesheets', cssStr);
|
|
713
|
+
set('page.view.scripts', jsStr);
|
|
706
714
|
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
} else {
|
|
712
|
-
data = (isRenderingCustomError) ? userData : merge(userData, data)
|
|
713
|
-
}
|
|
715
|
+
reURL = null;
|
|
716
|
+
cssStr = null;
|
|
717
|
+
jsStr = null;
|
|
718
|
+
}
|
|
714
719
|
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
720
|
+
/**
|
|
721
|
+
* Get node resources
|
|
722
|
+
*
|
|
723
|
+
* @param {string} type
|
|
724
|
+
* @param {string} resStr
|
|
725
|
+
* @param {array} resArr
|
|
726
|
+
* @param {boolean} useWebroot
|
|
727
|
+
* @param {object} reURL - RegExp for webroot
|
|
728
|
+
*
|
|
729
|
+
* @returns {object} content
|
|
730
|
+
*
|
|
731
|
+
* @private
|
|
732
|
+
* */
|
|
733
|
+
var getNodeRes = function(type, resArr, useWebroot, reURL) {
|
|
724
734
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
)
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
735
|
+
var r = 0
|
|
736
|
+
, rLen = resArr.length
|
|
737
|
+
, obj = null
|
|
738
|
+
, str = ''
|
|
739
|
+
, isProxyHost = getContext('isProxyHost')
|
|
740
|
+
, requestHost = ( /http\/2/.test(local.options.conf.server.protocol) )
|
|
741
|
+
? local.req.headers[':host']
|
|
742
|
+
: local.req.headers.host
|
|
743
|
+
, hostname = ( typeof(requestHost) != 'undefined' && local.options.conf.host != requestHost)
|
|
744
|
+
? local.options.conf.server.scheme +'://'+ requestHost
|
|
745
|
+
: local.options.conf.hostname
|
|
746
|
+
, scheme = hostname.match(/^(https|http)/)[0]
|
|
747
|
+
;
|
|
748
|
+
var requestPort = (local.req.headers.port||local.req.headers[':port']);
|
|
749
|
+
var hostPort = local.options.conf.hostname.match(/(\:d+\/|\:\d+)$/);
|
|
750
|
+
hostPort = (hostPort) ? ~~(hostPort[0].replace(/\:/g, '')) : local.options.conf.port[local.options.conf.server.protocol][local.options.conf.server.scheme];
|
|
751
|
+
// Linking bundle B from bundle A wihtout proxy
|
|
752
|
+
var isSpecialCase = (
|
|
753
|
+
getContext('bundle') != local.options.conf.bundle
|
|
754
|
+
&& requestPort != hostPort
|
|
755
|
+
&& local.req.headers[':host'] != process.gina.PROXY_HOST
|
|
756
|
+
) ? true : false;
|
|
738
757
|
|
|
739
|
-
|
|
758
|
+
if (isSpecialCase) {
|
|
759
|
+
hostname = local.options.conf.hostname
|
|
760
|
+
}
|
|
740
761
|
|
|
741
|
-
// pre-compiling variables
|
|
742
|
-
data = merge(data, getData()); // needed !!
|
|
743
762
|
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
763
|
+
if (
|
|
764
|
+
isProxyHost
|
|
765
|
+
&& !isSpecialCase
|
|
766
|
+
) {
|
|
747
767
|
|
|
768
|
+
hostname = scheme + '://'+ (local.req.headers.host||local.req.headers[':host']||process.gina.PROXY_HOST);
|
|
748
769
|
|
|
749
770
|
if (
|
|
750
|
-
|
|
751
|
-
&&
|
|
752
|
-
&& !/^2/.test(data.page.data.status)
|
|
753
|
-
&& typeof(data.page.data.error) != 'undefined'
|
|
771
|
+
!/^(80|443)$/.test(requestPort)
|
|
772
|
+
&& !new RegExp(requestPort+'$').test(hostname)
|
|
754
773
|
) {
|
|
755
|
-
|
|
756
|
-
var errorObject = {
|
|
757
|
-
status: data.page.data.status,
|
|
758
|
-
//errors: msg.error || msg.errors || msg,
|
|
759
|
-
error: statusCodes[data.page.data.status] || msg.error || msg,
|
|
760
|
-
message: data.page.data.message || data.page.data.error,
|
|
761
|
-
stack: data.page.data.stack
|
|
762
|
-
};
|
|
763
|
-
if ( typeof(data.page.data.session) != 'undefined' ) {
|
|
764
|
-
errorObject.session = data.page.data.session;
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
return self.throwError(errorObject);
|
|
774
|
+
hostname += ':'+ requestPort;
|
|
768
775
|
}
|
|
776
|
+
}
|
|
769
777
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
778
|
+
switch(type){
|
|
779
|
+
case 'css':
|
|
780
|
+
for (; r < rLen; ++r) {
|
|
781
|
+
obj = resArr[r];
|
|
782
|
+
if (useWebroot && !reURL.test(obj.url) ) {
|
|
783
|
+
obj.url = local.options.conf.server.webroot + obj.url.substring(1);
|
|
784
|
+
}
|
|
785
|
+
// HTTP2 Push via Link
|
|
786
|
+
if (
|
|
787
|
+
/http\/2/.test(local.options.conf.server.protocol)
|
|
788
|
+
&& !self.isCacheless()
|
|
789
|
+
) {
|
|
790
|
+
local.options.template.h2Links += '<'+ obj.url +'>; as=style; rel=preload,'
|
|
791
|
+
}
|
|
792
|
+
// TODO - add support for cdn
|
|
793
|
+
if (!/\:\/\//.test(obj.url) ) {
|
|
794
|
+
obj.url = hostname + obj.url;
|
|
795
|
+
}
|
|
776
796
|
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
797
|
+
if (obj.media) {
|
|
798
|
+
str += '\n\t\t<link href="'+ obj.url +'" media="'+ obj.media +'" rel="'+ obj.rel +'" type="'+ obj.type +'">';
|
|
799
|
+
} else {
|
|
800
|
+
str += '\n\t\t<link href="'+ obj.url +'" rel="'+ obj.rel +'" type="'+ obj.type +'">';
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
break;
|
|
781
804
|
|
|
805
|
+
case 'js':
|
|
806
|
+
var deferMode = (local.options.template.javascriptsDeferEnabled) ? ' defer' : '';
|
|
782
807
|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
// data.page.view.path = path.replace('/'+ data.page.view.file, '');
|
|
800
|
-
// }
|
|
801
|
-
|
|
802
|
-
// } else {
|
|
803
|
-
// path = (!isRenderingCustomError && !/^(\.|\/|\\)/.test(file))
|
|
804
|
-
// ? _(localOptions.template.html +'/'+ file)
|
|
805
|
-
// : file
|
|
806
|
-
// }
|
|
807
|
-
// }
|
|
808
|
+
for (; r < rLen; ++r) {
|
|
809
|
+
obj = resArr[r];
|
|
810
|
+
if (useWebroot && !reURL.test(obj.url) ) {
|
|
811
|
+
obj.url = local.options.conf.server.webroot + obj.url.substring(1);
|
|
812
|
+
}
|
|
813
|
+
// HTTP2 Push via Link
|
|
814
|
+
if (
|
|
815
|
+
/http\/2/.test(local.options.conf.server.protocol)
|
|
816
|
+
&& !self.isCacheless()
|
|
817
|
+
) {
|
|
818
|
+
local.options.template.h2Links += '<'+ obj.url +'>; as=script; rel=preload,'
|
|
819
|
+
}
|
|
820
|
+
// TODO - add support for cdn
|
|
821
|
+
if (!/\:\/\//.test(obj.url) ) {
|
|
822
|
+
obj.url = hostname + obj.url;
|
|
823
|
+
}
|
|
808
824
|
|
|
809
|
-
// if (data.page.view.ext && !new RegExp(data.page.view.ext+ '$').test(file) /** && hasViews() && fs.existsSync(_(path + data.page.view.ext, true))*/ ) {
|
|
810
|
-
// path += data.page.view.ext
|
|
811
|
-
// }
|
|
812
|
-
|
|
813
|
-
// data.page.view.path = path;
|
|
814
|
-
|
|
815
|
-
var dic = {}, msg = '';
|
|
816
|
-
for (let d in data.page) {
|
|
817
|
-
dic['page.'+d] = data.page[d]
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
// please, do not start with a slashe when including...
|
|
823
|
-
// ex.:
|
|
824
|
-
// /html/inc/_partial.html (BAD)
|
|
825
|
-
// html/inc/_partial.html (GOOD)
|
|
826
|
-
// ./html/namespace/page.html (GOOD)
|
|
827
|
-
|
|
828
|
-
if ( !fs.existsSync(path) ) {
|
|
829
|
-
msg = 'could not open "'+ path +'"' +
|
|
830
|
-
'\n1) The requested file does not exists in your templates/html (check your template directory). Can you find: '+path +
|
|
831
|
-
'\n2) Check the following rule in your `'+localOptions.conf.bundlePath+'/config/routing.json` and look around `param` to make sure that nothing is wrong with your file declaration: '+
|
|
832
|
-
'\n' + options.rule +':'+ JSON.stringify(options.conf.content.routing[options.rule], null, 4) +
|
|
833
|
-
'\n3) At this point, if you still have problems trying to run this portion of code, you can contact us telling us how to reproduce the bug.'
|
|
834
|
-
//'\n\r[ stack trace ] '
|
|
835
|
-
;
|
|
836
|
-
err = new ApiError(msg, 500);
|
|
837
|
-
console.error(err.stack);
|
|
838
|
-
self.throwError(err);
|
|
839
|
-
return;
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
var isProxyHost = (
|
|
843
|
-
typeof(local.req.headers.host) != 'undefined'
|
|
844
|
-
&& localOptions.conf.server.scheme +'://'+ local.req.headers.host != localOptions.conf.hostname
|
|
845
|
-
|| typeof(local.req.headers[':authority']) != 'undefined'
|
|
846
|
-
&& localOptions.conf.server.scheme +'://'+ local.req.headers[':authority'] != localOptions.conf.hostname
|
|
847
|
-
) ? true : false;
|
|
848
|
-
// setup swig default filters
|
|
849
|
-
var filters = SwigFilters({
|
|
850
|
-
options : JSON.clone(localOptions),
|
|
851
|
-
isProxyHost : isProxyHost,
|
|
852
|
-
throwError : self.throwError,
|
|
853
|
-
req : local.req,
|
|
854
|
-
res : local.res
|
|
855
|
-
});
|
|
856
|
-
|
|
857
|
-
try {
|
|
858
|
-
|
|
859
|
-
// Extends default `length` filter
|
|
860
|
-
swig.setFilter('length', filters.length);
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
// Allows you to get a bundle web root
|
|
865
|
-
swig.setFilter('getWebroot', filters.getWebroot);
|
|
866
|
-
|
|
867
|
-
swig.setFilter('getUrl', filters.getUrl);
|
|
868
|
-
|
|
869
|
-
} catch (err) {
|
|
870
|
-
// [ martin ]
|
|
871
|
-
// i sent an email to [ paul@paularmstrongdesigns.com ] on 2014/08 to see if there is:
|
|
872
|
-
// a way of retrieving swig compilation stack traces
|
|
873
|
-
//var stack = __stack.splice(1).toString().split(',').join('\n');
|
|
874
|
-
// -> no response...
|
|
875
|
-
self.throwError(local.res, 500, new Error('template compilation exception encoutered: [ '+path+' ]\n'+(err.stack||err.message)));
|
|
876
|
-
return;
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
var assets = null
|
|
882
|
-
, mapping = null
|
|
883
|
-
, XHRData = null
|
|
884
|
-
, XHRView = null
|
|
885
|
-
, isDeferModeEnabled = null
|
|
886
|
-
, viewInfos = null
|
|
887
|
-
, filename = null
|
|
888
|
-
, isWithSwigLayout = null
|
|
889
|
-
, isUsingGinaLayout = (!isWithoutLayout && typeof(localOptions.template.layout) != 'undefined' && fs.existsSync(local.options.template.layout)) ? true : false
|
|
890
|
-
;
|
|
891
|
-
|
|
892
|
-
if ( isWithoutLayout || isUsingGinaLayout ) {
|
|
893
|
-
layoutPath = (isWithoutLayout) ? localOptions.template.noLayout : localOptions.template.layout;
|
|
894
|
-
// user layout override
|
|
895
|
-
if ( isUsingGinaLayout && !isWithoutLayout ) {
|
|
896
|
-
layoutPath = localOptions.template.layout;
|
|
897
|
-
}
|
|
898
|
-
if (isWithoutLayout) {
|
|
899
|
-
data.page.view.layout = layoutPath;
|
|
900
|
-
}
|
|
901
|
-
} else { // without layout case
|
|
902
|
-
|
|
903
|
-
// by default
|
|
904
|
-
layoutPath = localOptions.template.layout;
|
|
905
|
-
if ( !/^\//.test(layoutPath)) {
|
|
906
|
-
layoutPath = localOptions.template.templates +'/'+ layoutPath;
|
|
907
|
-
}
|
|
908
|
-
// default layout
|
|
909
|
-
if (
|
|
910
|
-
!isWithoutLayout && !fs.existsSync(layoutPath) && layoutPath == localOptions.template.templates +'/index.html'
|
|
911
|
-
) {
|
|
912
|
-
console.warn('Layout '+ local.options.template.layout +' not found, replacing with `nolayout`: '+ localOptions.template.noLayout);
|
|
913
|
-
layoutPath = localOptions.template.noLayout
|
|
914
|
-
isWithoutLayout = true;
|
|
915
|
-
data.page.view.layout = layoutPath;
|
|
916
|
-
}
|
|
917
|
-
// user defiend layout
|
|
918
|
-
else if ( !isWithoutLayout && !fs.existsSync(layoutPath) ) {
|
|
919
|
-
isWithSwigLayout = true;
|
|
920
|
-
layoutPath = localOptions.template.noLayout;
|
|
921
|
-
data.page.view.layout = layoutPath;
|
|
922
|
-
}
|
|
923
|
-
// layout defiendd but not found
|
|
924
|
-
else if (!fs.existsSync(layoutPath) ) {
|
|
925
|
-
err = new ApiError(options.bundle +' SuperController exception while trying to load your layout `'+ layoutPath +'`.\nIt seems like you have defined a layout, but gina could not locate the file.\nFor more informations, check your `config/templates.json` declaration around `'+ local.options.rule.replace(/\@(.*)/g, '') +'`', 500);
|
|
926
|
-
self.throwError(err);
|
|
927
|
-
return;
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
var isLoadingPartial = false;
|
|
934
|
-
try {
|
|
935
|
-
assets = {assets:"${assets}"};
|
|
936
|
-
|
|
937
|
-
/**
|
|
938
|
-
* retrieve template & layout
|
|
939
|
-
* */
|
|
940
|
-
var tpl = null;
|
|
941
|
-
// tpl = fs.readFileSync(path).toString();
|
|
942
|
-
// layout = fs.readFileSync(layoutPath).toString();
|
|
943
|
-
|
|
944
|
-
await Promise.all([
|
|
945
|
-
readFile(layoutPath),
|
|
946
|
-
readFile(path)
|
|
947
|
-
])
|
|
948
|
-
.then(([_layout, _tpl]) => {
|
|
949
|
-
layout = _layout.toString();
|
|
950
|
-
tpl = _tpl.toString();
|
|
951
|
-
})
|
|
952
|
-
.catch(error => {
|
|
953
|
-
console.error(error.message);
|
|
954
|
-
return;
|
|
955
|
-
});
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
// mappin conf
|
|
959
|
-
mapping = { filename: path };
|
|
960
|
-
if (isRenderingCustomError) {
|
|
961
|
-
// TODO - Test if there is a block call `gina-error` in the layout & replace block name from tpl
|
|
962
|
-
|
|
963
|
-
if ( !/\{\%(\s+extends|extends)/.test(tpl) ) {
|
|
964
|
-
tpl = "\n{% extends '"+ layoutPath +"' %}\n" + tpl;
|
|
965
|
-
}
|
|
966
|
-
if (!/\{\% block content/.test(tpl)) {
|
|
967
|
-
// TODO - test if lyout has <body>
|
|
968
|
-
tpl = '{% block content %}<p>If you view this message you didn’t define a content block in your template.</p>{% endblock %}' + tpl;
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
tpl = tpl.replace(/\{\{ page\.content \}\}/g, '');
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
if ( isWithoutLayout || isWithSwigLayout) {
|
|
975
|
-
layout = tpl;
|
|
976
|
-
} else if (isUsingGinaLayout) {
|
|
977
|
-
mapping = { filename: path };
|
|
978
|
-
if ( /(\{\{|\{\{\s+)page\.content/.test(layout) ) {
|
|
979
|
-
|
|
980
|
-
if ( /\{\%(\s+extends|extends)/.test(tpl) ) {
|
|
981
|
-
err = new Error('You cannot use at the same time `page.content` in your layout `'+ layoutPath +'` while calling `extends` from your page or content `'+ path +'`. You have to choose one or the other');
|
|
982
|
-
self.throwError(local.res, 500, err);
|
|
983
|
-
return
|
|
984
|
-
}
|
|
985
|
-
layout = layout.replace('{{ page.content }}', tpl);
|
|
986
|
-
} else {
|
|
987
|
-
layout = layout.replace(/\<\/body\>/i, '\t'+tpl+'\n</body>');
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
} else {
|
|
991
|
-
tpl = tpl.replace('{{ page.view.layout }}', data.page.view.layout);
|
|
992
|
-
if (/\<\/body\>/i.test(layout)) {
|
|
993
|
-
layout = layout.replace(/\<\/body\>/i, '\t'+tpl+'\n</body>');
|
|
994
|
-
}
|
|
995
|
-
else {
|
|
996
|
-
layout += tpl;
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
// precompilation needed in case of `extends` or in order to display the toolbar
|
|
1001
|
-
if ( hasViews() && self.isCacheless() || /\{\%(\s+extends|extends)/.test(layout) ) {
|
|
1002
|
-
layout = swig.compile(layout, mapping)(data);
|
|
1003
|
-
}
|
|
1004
|
-
//dic['page.content'] = layout;
|
|
1005
|
-
|
|
1006
|
-
tpl = null;
|
|
1007
|
-
|
|
1008
|
-
} catch(err) {
|
|
1009
|
-
err.stack = 'Exception, bad syntax or undefined data found: start investigating in '+ mapping.filename +'\n' + err.stack;
|
|
1010
|
-
return self.throwError(local.res, 500, err);
|
|
1011
|
-
}
|
|
1012
|
-
mapping = null;
|
|
1013
|
-
filename = null;
|
|
1014
|
-
|
|
1015
|
-
isLoadingPartial = (
|
|
1016
|
-
!/\<html/i.test(layout)
|
|
1017
|
-
|| !/\<head/i.test(layout)
|
|
1018
|
-
|| !/\<body/i.test(layout)
|
|
1019
|
-
) ? true : false;
|
|
1020
|
-
|
|
1021
|
-
// if (isLoadingPartial) {
|
|
1022
|
-
// console.warn('----------------> loading partial `'+ path);
|
|
1023
|
-
// }
|
|
1024
|
-
|
|
1025
|
-
isDeferModeEnabled = localOptions.template.javascriptsDeferEnabled || localOptions.conf.content.templates._common.javascriptsDeferEnabled || false;
|
|
1026
|
-
|
|
1027
|
-
// iframe case - without HTML TAG
|
|
1028
|
-
if (!self.isXMLRequest() && !/\<html/.test(layout) ) {
|
|
1029
|
-
layout = '<html>\n\t<head></head>\n\t<body class="gina-iframe-body">\n\t\t'+ layout +'\n\t</body>\n</html>';
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
// adding stylesheets
|
|
1033
|
-
if (!isWithoutLayout && data.page.view.stylesheets && !/\{\{\s+(page\.view\.stylesheets)\s+\}\}/.test(layout) ) {
|
|
1034
|
-
layout = layout.replace(/\<\/head\>/i, '\n\t{{ page.view.stylesheets }}\n</head>')
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
if (hasViews() && isWithoutLayout) {
|
|
1038
|
-
// $.getScript(...)
|
|
1039
|
-
//var isProxyHost = ( typeof(local.req.headers.host) != 'undefined' && localOptions.conf.server.scheme +'://'+ local.req.headers.host != localOptions.conf.hostname || typeof(local.req.headers[':authority']) != 'undefined' && localOptions.conf.server.scheme +'://'+ local.req.headers[':authority'] != localOptions.conf.hostname ) ? true : false;
|
|
1040
|
-
//var hostname = (isProxyHost) ? localOptions.conf.hostname.replace(/\:\d+$/, '') : localOptions.conf.hostname;
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
var scripts = data.page.view.scripts;
|
|
1045
|
-
scripts = scripts.replace(/\s+\<script/g, '\n<script');
|
|
1046
|
-
|
|
1047
|
-
if (!isProxyHost) {
|
|
1048
|
-
var webroot = data.page.environment.webroot;
|
|
1049
|
-
scripts = scripts.replace(/src\=\"\/(.*)\"/g, 'src="'+ webroot +'$1"');
|
|
1050
|
-
//stylesheets = stylesheets.replace(/href\=\"\/(.*)\"/g, 'href="'+ webroot +'$1"')
|
|
1051
|
-
webroot = null;
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
// iframe case - without HTML TAG
|
|
1055
|
-
if (self.isXMLRequest() || !/\<html/.test(layout) ) {
|
|
1056
|
-
layout += scripts;
|
|
1057
|
-
//layout += stylesheets;
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
// adding plugins
|
|
1063
|
-
// means that we don't want GFF context or we already have it loaded
|
|
1064
|
-
viewInfos = JSON.clone(data.page.view);
|
|
1065
|
-
if ( !isWithoutLayout )
|
|
1066
|
-
viewInfos.assets = assets;
|
|
1067
|
-
|
|
1068
|
-
if (
|
|
1069
|
-
hasViews() && self.isCacheless() && !isWithoutLayout
|
|
1070
|
-
&& localOptions.debugMode
|
|
1071
|
-
||
|
|
1072
|
-
hasViews() && self.isCacheless() && !isWithoutLayout
|
|
1073
|
-
&& typeof(localOptions.debugMode) == 'undefined'
|
|
1074
|
-
||
|
|
1075
|
-
hasViews() && localOptions.debugMode
|
|
1076
|
-
) {
|
|
1077
|
-
|
|
1078
|
-
layout = ''
|
|
1079
|
-
// + '{%- set ginaDataInspector = JSON.clone(page) -%}'
|
|
1080
|
-
+ '{%- set ginaDataInspector = JSON.clone(page) -%}'
|
|
1081
|
-
// + '{%- set ginaDataInspector = { view: {}, environment: { routing: {}}} -%}'
|
|
1082
|
-
+ '{%- set ginaDataInspector.view.assets = {} -%}'
|
|
1083
|
-
+ '{%- set ginaDataInspector.view.scripts = "ignored-by-toolbar" -%}'
|
|
1084
|
-
+ '{%- set ginaDataInspector.view.stylesheets = "ignored-by-toolbar" -%}'
|
|
1085
|
-
+ layout
|
|
1086
|
-
;
|
|
1087
|
-
|
|
1088
|
-
plugin = '\t'
|
|
1089
|
-
+ '{# Gina Toolbar #}'
|
|
1090
|
-
+ '{%- set userDataInspector = JSON.clone(page) -%}'
|
|
1091
|
-
// + '{%- set userDataInspector = { view: {}, environment: { routing: {}}} -%}'
|
|
1092
|
-
+ '{%- set userDataInspector.view.scripts = "ignored-by-toolbar" -%}'
|
|
1093
|
-
+ '{%- set userDataInspector.view.stylesheets = "ignored-by-toolbar" -%}'
|
|
1094
|
-
+ '{%- set userDataInspector.view.assets = '+ JSON.stringify(assets) +' -%}'
|
|
1095
|
-
+ '{%- include "'+ getPath('gina').core +'/asset/plugin/dist/vendor/gina/html/toolbar.html" with { gina: ginaDataInspector, user: userDataInspector } -%}'// jshint ignore:line
|
|
1096
|
-
+ '{# END Gina Toolbar #}'
|
|
1097
|
-
;
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
if (isWithoutLayout && localOptions.debugMode || localOptions.debugMode ) {
|
|
1101
|
-
|
|
1102
|
-
if (self.isXMLRequest()) {
|
|
1103
|
-
XHRData = '\t<input type="hidden" id="gina-without-layout-xhr-data" value="'+ encodeRFC5987ValueChars(JSON.stringify(data.page.data)) +'">\n\r';
|
|
1104
|
-
XHRView = '\n<input type="hidden" id="gina-without-layout-xhr-view" value="'+ encodeRFC5987ValueChars(JSON.stringify(viewInfos)) +'">';
|
|
1105
|
-
if ( /<\/body>/i.test(layout) ) {
|
|
1106
|
-
layout = layout.replace(/<\/body>/i, XHRData + XHRView + '\n\t</body>');
|
|
1107
|
-
} else {
|
|
1108
|
-
// Popin case
|
|
1109
|
-
// Fix added on 2023-01-25
|
|
1110
|
-
layout += XHRData + XHRView + '\n\t'
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
if (self.isCacheless() || localOptions.debugMode ) {
|
|
1118
|
-
layout = layout.replace(/<\/body>/i, plugin + '\n\t</body>');
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
// adding javascripts
|
|
1122
|
-
layout.replace('{{ page.view.scripts }}', '');
|
|
1123
|
-
// placed in the HEAD excepted when rendering a partial or when `isDeferModeEnabled` == true
|
|
1124
|
-
if (isLoadingPartial) {
|
|
1125
|
-
layout += '\t{{ page.view.scripts }}';
|
|
1126
|
-
} else {
|
|
1127
|
-
if ( isDeferModeEnabled ) {
|
|
1128
|
-
layout = layout.replace(/\<\/head\>/i, '\t{{ page.view.scripts }}\n\t</head>');
|
|
1129
|
-
} else { // placed in the BODY
|
|
1130
|
-
layout = layout.replace(/\<\/body\>/i, '\t{{ page.view.scripts }}\n</body>');
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
// ginaLoader cannot be deferred
|
|
1135
|
-
if ( !localOptions.template.javascriptsExcluded || localOptions.template.javascriptsExcluded != '**' ) {
|
|
1136
|
-
layout = layout.replace(/\<\/head\>/i, '\t'+ localOptions.template.ginaLoader +'\n</head>');
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
} else if ( hasViews() && self.isCacheless() && self.isXMLRequest() ) {
|
|
1140
825
|
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
delete data.page.view.stylesheets;
|
|
1144
|
-
}
|
|
1145
|
-
// means that we don't want GFF context or we already have it loaded
|
|
1146
|
-
// viewInfos = JSON.clone(data.page.view);
|
|
1147
|
-
// if ( !isWithoutLayout )
|
|
1148
|
-
// viewInfos.assets = assets;
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
XHRData = '\n<input type="hidden" id="gina-without-layout-xhr-data" value="'+ encodeRFC5987ValueChars(JSON.stringify(data.page.data)) +'">';
|
|
1152
|
-
XHRView = '\n<input type="hidden" id="gina-without-layout-xhr-view" value="'+ encodeRFC5987ValueChars(JSON.stringify(viewInfos)) +'">';
|
|
1153
|
-
if ( /<\/body>/i.test(layout) ) {
|
|
1154
|
-
layout = layout.replace(/<\/body>/i, XHRData + XHRView + '\n\t</body>');
|
|
1155
|
-
} else {
|
|
1156
|
-
// Popin case
|
|
1157
|
-
// Fix added on 2023-01-25
|
|
1158
|
-
layout += XHRData + XHRView + '\n\t'
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
// layout += XHRData + XHRView;
|
|
1162
|
-
|
|
1163
|
-
} else { // other envs like prod ...
|
|
1164
|
-
|
|
1165
|
-
// adding javascripts
|
|
1166
|
-
// cleanup first
|
|
1167
|
-
layout.replace('{{ page.view.scripts }}', '');
|
|
1168
|
-
// placed in the HEAD excepted when rendering a partial or when `isDeferModeEnabled` == true
|
|
1169
|
-
// if (isLoadingPartial) {
|
|
1170
|
-
// layout += '\t{{ page.view.scripts }}';
|
|
1171
|
-
// } else {
|
|
1172
|
-
// if ( isDeferModeEnabled ) {
|
|
1173
|
-
// layout = layout.replace(/\<\/head\>/i, '\t{{ page.view.scripts }}\n\t</head>');
|
|
1174
|
-
// } else { // placed in the BODY
|
|
1175
|
-
// layout = layout.replace(/\<\/body\>/i, '\t{{ page.view.scripts }}\n</body>');
|
|
1176
|
-
// }
|
|
1177
|
-
// }
|
|
1178
|
-
|
|
1179
|
-
// // ginaLoader cannot be deferred
|
|
1180
|
-
// if ( !localOptions.template.javascriptsExcluded || localOptions.template.javascriptsExcluded != '**' ) {
|
|
1181
|
-
// layout = layout.replace(/\<\/head\>/i, '\t'+ localOptions.template.ginaLoader +'\n</head>');
|
|
1182
|
-
// }
|
|
1183
|
-
|
|
1184
|
-
// adding javascripts
|
|
1185
|
-
layout.replace('{{ page.view.scripts }}', '');
|
|
1186
|
-
if (isLoadingPartial) {
|
|
1187
|
-
layout += '\t{{ page.view.scripts }}\n';
|
|
1188
|
-
if ( !localOptions.template.javascriptsExcluded || localOptions.template.javascriptsExcluded != '**' ) {
|
|
1189
|
-
layout += '\t'+ localOptions.template.ginaLoader +'\n';
|
|
1190
|
-
}
|
|
1191
|
-
} else {
|
|
1192
|
-
if ( isDeferModeEnabled && /\<\/head\>/i.test(layout) ) { // placed in the HEAD
|
|
1193
|
-
layout = layout.replace(/\<\/head\>/i, '\t{{ page.view.scripts }}\n\t</head>');
|
|
1194
|
-
|
|
1195
|
-
} else { // placed in the BODY
|
|
1196
|
-
layout = layout.replace(/\<\/body\>/i, '\t{{ page.view.scripts }}\n</body>');
|
|
826
|
+
if ( /\/jquery\.(.*)\.(min\.js|js)$/i.test(obj.url) ) {
|
|
827
|
+
console.warn('jQuery Plugin found in templates.json !\nIf you want to load it before [gina.min.js], you should declare it at the top of your handler using requireJS or add property "isExternalPlugin: true" in your templates.json, under: '+ (obj.route || local.req.routing.rule) +' .');
|
|
1197
828
|
}
|
|
1198
|
-
//
|
|
1199
|
-
if (
|
|
1200
|
-
|
|
829
|
+
// Allow jQuery & other external plugins to be loaded in the HEAD section before gina
|
|
830
|
+
if (
|
|
831
|
+
obj.isExternalPlugin
|
|
832
|
+
) {
|
|
833
|
+
local.options.template.externalPlugins.splice(1, 0, '\n\t\t<script'+ deferMode +' type="'+ obj.type +'" src="'+ obj.url +'"></script>');
|
|
1201
834
|
}
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
layout = whisper(dic, layout, /\{{ ([a-zA-Z.]+) \}}/g );
|
|
1207
|
-
dic['page.content'] = layout;
|
|
1208
|
-
/**
|
|
1209
|
-
// special case for template without layout in debug mode - dev only
|
|
1210
|
-
if ( hasViews() && localOptions.debugMode && self.isCacheless() && !/\{\# Gina Toolbar \#\}/.test(layout) ) {
|
|
1211
|
-
try {
|
|
1212
|
-
|
|
1213
|
-
layout = layout.replace(/<\/body>/i, plugin + '\n\t</body>');
|
|
1214
|
-
layout = whisper(dic, layout, /\{{ ([a-zA-Z.]+) \}}/g );
|
|
1215
|
-
//swig.invalidateCache();
|
|
1216
|
-
layout = swig.compile(layout, mapping)(swigData);
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
} catch (err) {
|
|
1220
|
-
filename = localOptions.template.html;
|
|
1221
|
-
filename += ( typeof(data.page.view.namespace) != 'undefined' && data.page.view.namespace != '' && new RegExp('^' + data.page.view.namespace +'-').test(data.page.view.file) ) ? '/' + data.page.view.namespace + data.page.view.file.split(data.page.view.namespace +'-').join('/') + ( (data.page.view.ext != '') ? data.page.view.ext: '' ) : '/' + data.page.view.file+ ( (data.page.view.ext != '') ? data.page.view.ext: '' );
|
|
1222
|
-
self.throwError(local.res, 500, new Error('Compilation error encountered while trying to process template `'+ filename + '`\n'+(err.stack||err.message)));
|
|
1223
|
-
return;
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
else if (hasViews() && localOptions.debugMode && self.isCacheless()) {
|
|
1227
|
-
try {
|
|
1228
|
-
//layout = whisper(dic, layout, /\{{ ([a-zA-Z.]+) \}}/g );
|
|
1229
|
-
layout = swig.compile(layout, mapping)(swigData);
|
|
1230
|
-
} catch (err) {
|
|
1231
|
-
filename = localOptions.template.html;
|
|
1232
|
-
filename += ( typeof(data.page.view.namespace) != 'undefined' && data.page.view.namespace != '' && new RegExp('^' + data.page.view.namespace +'-').test(data.page.view.file) ) ? '/' + data.page.view.namespace + data.page.view.file.split(data.page.view.namespace +'-').join('/') + ( (data.page.view.ext != '') ? data.page.view.ext: '' ) : '/' + data.page.view.file+ ( (data.page.view.ext != '') ? data.page.view.ext: '' );
|
|
1233
|
-
self.throwError(local.res, 500, new Error('Compilation error encountered while trying to process template `'+ filename + '`\n'+(err.stack||err.message)));
|
|
1234
|
-
return;
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
*/
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
// if ( !local.res.headersSent ) {
|
|
1241
|
-
if ( !headersSent() ) {
|
|
1242
|
-
local.res.statusCode = ( typeof(localOptions.conf.server.coreConfiguration.statusCodes[data.page.data.status]) != 'undefined' ) ? data.page.data.status : 200; // by default
|
|
1243
|
-
//catching errors
|
|
1244
|
-
if (
|
|
1245
|
-
typeof(data.page.data.errno) != 'undefined' && /^2/.test(data.page.data.status) && typeof(localOptions.conf.server.coreConfiguration.statusCodes[data.page.data.status]) != 'undefined'
|
|
1246
|
-
|| typeof(data.page.data.status) != 'undefined' && !/^2/.test(data.page.data.status) && typeof(localOptions.conf.server.coreConfiguration.statusCodes[data.page.data.status]) != 'undefined'
|
|
1247
|
-
) {
|
|
1248
|
-
|
|
1249
|
-
try {
|
|
1250
|
-
local.res.statusMessage = localOptions.conf.server.coreConfiguration.statusCodes[data.page.data.status];
|
|
1251
|
-
} catch (err){
|
|
1252
|
-
local.res.statusCode = 500;
|
|
1253
|
-
local.res.statusMessage = err.stack||err.message||localOptions.conf.server.coreConfiguration.statusCodes[local.res.statusCode];
|
|
835
|
+
else {
|
|
836
|
+
// normal case
|
|
837
|
+
str += '\n\t\t<script'+ deferMode +' type="'+ obj.type +'" src="'+ obj.url +'"></script>';
|
|
1254
838
|
}
|
|
1255
839
|
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
// escape special chars
|
|
1262
|
-
var blacklistRe = new RegExp('[\<\>]', 'g');
|
|
1263
|
-
// DO NOT REPLACE IT BY JSON.clone() !!!!
|
|
1264
|
-
|
|
1265
|
-
data.page.data = JSON.parse(JSON.stringify(data.page.data).replace(blacklistRe, '\$&'));
|
|
1266
|
-
blacklistRe = null;
|
|
1267
|
-
} catch (err) {
|
|
1268
|
-
filename = localOptions.template.html;
|
|
1269
|
-
filename += ( typeof(data.page.view.namespace) != 'undefined' && data.page.view.namespace != '' && new RegExp('^' + data.page.view.namespace +'-').test(data.page.view.file) ) ? '/' + data.page.view.namespace + data.page.view.file.split(data.page.view.namespace +'-').join('/') + ( (data.page.view.ext != '') ? data.page.view.ext: '' ) : '/' + data.page.view.file+ ( (data.page.view.ext != '') ? data.page.view.ext: '' );
|
|
1270
|
-
self.throwError(local.res, 500, new Error('Controller::render(...) compilation error encountered while trying to process template `'+ filename + '`\n' + (err.stack||err.message||err) ));
|
|
1271
|
-
filename = null;
|
|
1272
|
-
blacklistRe = null;
|
|
1273
|
-
return;
|
|
1274
|
-
}
|
|
840
|
+
break;
|
|
841
|
+
}
|
|
842
|
+
r = null;
|
|
843
|
+
rLen = null;
|
|
844
|
+
obj = null;
|
|
1275
845
|
|
|
1276
846
|
|
|
847
|
+
return str;
|
|
848
|
+
}
|
|
1277
849
|
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
// assets string -> object
|
|
1285
|
-
//assets = self.serverInstance.getAssets(localOptions.conf, layout.toString(), swig, data);
|
|
1286
|
-
assets = self.serverInstance.getAssets(localOptions.conf, layout, swig, data);
|
|
1287
|
-
localOptions.template.assets = JSON.parse(assets);
|
|
1288
|
-
}
|
|
850
|
+
/**
|
|
851
|
+
* TODO - SuperController.setMeta()
|
|
852
|
+
* */
|
|
853
|
+
// this.setMeta = function(metaName, metacontent) {
|
|
854
|
+
//
|
|
855
|
+
// }
|
|
1289
856
|
|
|
1290
|
-
// only for toolbar - TODO hasToolbar()
|
|
1291
|
-
if (
|
|
1292
|
-
self.isCacheless() && hasViews() && !isWithoutLayout
|
|
1293
|
-
|| hasViews() && localOptions.debugMode
|
|
1294
|
-
|| self.isCacheless() && hasViews() && self.isXMLRequest()
|
|
1295
|
-
) {
|
|
1296
|
-
layout = layout.replace('{"assets":"${assets}"}', assets );
|
|
1297
|
-
}
|
|
1298
|
-
assets = null;
|
|
1299
857
|
|
|
1300
|
-
} catch (err) {
|
|
1301
|
-
assets = null;
|
|
1302
|
-
self.throwError(local.res, 500, new Error('Controller::render(...) calling getAssets(...) \n' + (err.stack||err.message||err) ));
|
|
1303
|
-
return;
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
858
|
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
859
|
+
var isValidURL = function(url){
|
|
860
|
+
// var re = /(http|ftp|https|sftp):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/;
|
|
861
|
+
return (/(http|ftp|https|sftp):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/.test(url)) ? true : false;
|
|
862
|
+
}
|
|
1310
863
|
|
|
1311
|
-
|
|
1312
|
-
if ( local.options.isRenderingCustomError ) {
|
|
1313
|
-
local.options.isRenderingCustomError = false;
|
|
1314
|
-
}
|
|
864
|
+
this.renderWithoutLayout = function (data, displayToolbar) {
|
|
1315
865
|
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
866
|
+
// preventing multiple call of self.renderWithoutLayout() when controller is rendering from another required controller
|
|
867
|
+
if (local.options.renderingStack.length > 1) {
|
|
868
|
+
return false;
|
|
869
|
+
}
|
|
1319
870
|
|
|
1320
|
-
|
|
871
|
+
local.options.isWithoutLayout = true;
|
|
1321
872
|
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
}
|
|
1325
|
-
return;
|
|
1326
|
-
}
|
|
873
|
+
self.render(data, displayToolbar);
|
|
874
|
+
}
|
|
1327
875
|
|
|
1328
876
|
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
local.res.end('Unexpected controller error while trying to render.');
|
|
877
|
+
var getData = function() {
|
|
878
|
+
return refToObj( local.userData )
|
|
879
|
+
}
|
|
1333
880
|
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
881
|
+
if (this.isCacheless() ) {
|
|
882
|
+
delete require.cache[require.resolve( _(__dirname + '/controller.renderv1', true))];
|
|
883
|
+
delete require.cache[require.resolve( _(__dirname + '/controller.renderSwig', true))];
|
|
884
|
+
}
|
|
1337
885
|
|
|
1338
|
-
|
|
886
|
+
/**
|
|
887
|
+
* Render HTML templates : Swig is the default template engine
|
|
888
|
+
*
|
|
889
|
+
* Extend default filters
|
|
890
|
+
* - length
|
|
891
|
+
*
|
|
892
|
+
* Available filters:
|
|
893
|
+
* - getWebroot()
|
|
894
|
+
* - getUrl()
|
|
895
|
+
*
|
|
896
|
+
* N.B.: Filters can be extended through your `<project>/src/<bundle>/controllers/setup.js`
|
|
897
|
+
*
|
|
898
|
+
*
|
|
899
|
+
* @param {object} userData
|
|
900
|
+
* @param {boolean} [displayToolbar]
|
|
901
|
+
* @param {object} [errOptions]
|
|
902
|
+
* @returns {void}
|
|
903
|
+
* */
|
|
904
|
+
this.render = require( _(__dirname + '/controller.renderSwig', true) )({
|
|
905
|
+
self : self,
|
|
906
|
+
local : local,
|
|
907
|
+
getData : getData,
|
|
908
|
+
hasViews : hasViews,
|
|
909
|
+
setResources: setResources,
|
|
910
|
+
swig : swig,
|
|
911
|
+
SwigFilters : SwigFilters,
|
|
912
|
+
headersSent : headersSent
|
|
913
|
+
}); //(userData, displayToolbar, errOptions)
|
|
1339
914
|
|
|
1340
|
-
} catch (err) {
|
|
1341
|
-
return self.throwError(local.res, 500, err);
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1344
915
|
|
|
1345
916
|
|
|
1346
917
|
this.isXMLRequest = function() {
|
|
@@ -1418,14 +989,25 @@ function SuperController(options) {
|
|
|
1418
989
|
|
|
1419
990
|
try {
|
|
1420
991
|
response.statusCode = jsonObj.status;
|
|
1421
|
-
|
|
992
|
+
// HTTP/2 (RFC7540 8.1.2.4):
|
|
993
|
+
// This standard for HTTP/2 explicitly states that status messages are not supported.
|
|
994
|
+
// In HTTP/2, the status is conveyed solely by the numerical status code (e.g., 200, 404, 500),
|
|
995
|
+
// and there is no field for a human-readable status message.
|
|
996
|
+
if ( !/http\/2/.test(local.options.conf.server.protocol) ) {
|
|
997
|
+
response.statusMessage = local.options.conf.server.coreConfiguration.statusCodes[jsonObj.status];
|
|
998
|
+
}
|
|
1422
999
|
} catch (err){
|
|
1423
1000
|
response.statusCode = 500;
|
|
1424
|
-
|
|
1001
|
+
// HTTP/2 (RFC7540 8.1.2.4):
|
|
1002
|
+
// This standard for HTTP/2 explicitly states that status messages are not supported.
|
|
1003
|
+
// In HTTP/2, the status is conveyed solely by the numerical status code (e.g., 200, 404, 500),
|
|
1004
|
+
// and there is no field for a human-readable status message.
|
|
1005
|
+
if ( !/http\/2/.test(local.options.conf.server.protocol) ) {
|
|
1006
|
+
response.statusMessage = err.stack;
|
|
1007
|
+
}
|
|
1425
1008
|
}
|
|
1426
1009
|
}
|
|
1427
1010
|
|
|
1428
|
-
|
|
1429
1011
|
// Internet Explorer override
|
|
1430
1012
|
if ( /msie/i.test(request.headers['user-agent']) ) {
|
|
1431
1013
|
response.setHeader('content-type', 'text/plain' + '; charset='+ local.options.conf.encoding)
|
|
@@ -1433,302 +1015,113 @@ function SuperController(options) {
|
|
|
1433
1015
|
response.setHeader('content-type', local.options.conf.server.coreConfiguration.mime['json'] + '; charset='+ local.options.conf.encoding)
|
|
1434
1016
|
}
|
|
1435
1017
|
|
|
1436
|
-
|
|
1437
|
-
console.info(request.method +' ['+ response.statusCode +'] '+ request.url);
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
if ( local.options.isXMLRequest && self.isWithCredentials() ) {
|
|
1018
|
+
console.info(request.method +' ['+ response.statusCode +'] '+ request.url);
|
|
1441
1019
|
|
|
1442
|
-
// content length must be the right size !
|
|
1443
|
-
var len = Buffer.byteLength(data, 'utf8') || 0;
|
|
1444
|
-
if ( !headersSent(response) ) {
|
|
1445
|
-
response.setHeader("content-length", len);
|
|
1446
|
-
}
|
|
1447
|
-
|
|
1448
|
-
response.write(data);
|
|
1449
1020
|
|
|
1450
|
-
|
|
1451
|
-
setTimeout(function () {
|
|
1452
|
-
response.end();
|
|
1453
|
-
try {
|
|
1454
|
-
response.headersSent = true;
|
|
1455
|
-
} catch(err) {
|
|
1456
|
-
// Ignoring warning
|
|
1457
|
-
//console.warn(err);
|
|
1458
|
-
}
|
|
1021
|
+
if ( local.options.isXMLRequest && self.isWithCredentials() ) {
|
|
1459
1022
|
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1023
|
+
// content length must be the right size !
|
|
1024
|
+
var len = Buffer.byteLength(data, 'utf8') || 0;
|
|
1025
|
+
if ( !headersSent(response) ) {
|
|
1026
|
+
response.setHeader("content-length", len);
|
|
1027
|
+
}
|
|
1463
1028
|
|
|
1464
|
-
|
|
1465
|
-
}, 200);
|
|
1029
|
+
response.write(data);
|
|
1466
1030
|
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
// normal case
|
|
1471
|
-
response.end(JSON.stringify(jsonObj));
|
|
1472
|
-
if (!headersSent(response)) {
|
|
1031
|
+
// required to close connection
|
|
1032
|
+
setTimeout(function () {
|
|
1033
|
+
response.end();
|
|
1473
1034
|
try {
|
|
1474
1035
|
response.headersSent = true;
|
|
1475
1036
|
} catch(err) {
|
|
1476
1037
|
// Ignoring warning
|
|
1477
1038
|
//console.warn(err);
|
|
1478
1039
|
}
|
|
1479
|
-
}
|
|
1480
|
-
if ( next ) {
|
|
1481
|
-
return next()
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
|
-
freeMemory([jsonObj, data, request, response, next]);
|
|
1485
|
-
|
|
1486
|
-
return;
|
|
1487
|
-
// }
|
|
1488
|
-
} catch (err) {
|
|
1489
|
-
return self.throwError(response, 500, err);
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
this.renderTEXT = function(content) {
|
|
1495
|
-
|
|
1496
|
-
// preventing multiple call of self.renderTEXT() when controller is rendering from another required controller
|
|
1497
|
-
if (local.options.renderingStack.length > 1) {
|
|
1498
|
-
return false
|
|
1499
|
-
}
|
|
1500
|
-
if ( self.isProcessingError ) {
|
|
1501
|
-
return;
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
var request = local.req;
|
|
1505
|
-
var response = local.res;
|
|
1506
|
-
var next = local.next || null;
|
|
1507
|
-
// var stream = null;
|
|
1508
|
-
// if ( /http\/2/.test(local.options.conf.server.protocol) ) {
|
|
1509
|
-
// stream = response.stream;
|
|
1510
|
-
// }
|
|
1511
|
-
|
|
1512
|
-
// Added on 2023-06-12
|
|
1513
|
-
if ( headersSent(response) ) {
|
|
1514
|
-
freeMemory([content, request, response, next]);
|
|
1515
|
-
return;
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1518
|
-
if ( typeof(content) != "string" ) {
|
|
1519
|
-
content = content.toString();
|
|
1520
|
-
}
|
|
1521
1040
|
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
if ( !response.getHeaders()['content-type'] ) {
|
|
1526
|
-
response.setHeader('content-type', 'text/plain' + '; charset='+ local.options.conf.encoding);
|
|
1527
|
-
}
|
|
1528
|
-
|
|
1529
|
-
if ( !headersSent() ) {
|
|
1530
|
-
console.info(request.method +' ['+response.statusCode +'] '+ request.url);
|
|
1531
|
-
response.end(content);
|
|
1532
|
-
try {
|
|
1533
|
-
response.headersSent = true
|
|
1534
|
-
} catch(err) {
|
|
1535
|
-
// Ignoring warning
|
|
1536
|
-
//console.warn(err);
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
freeMemory([jsonObj, data, request, response, next]);
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1041
|
+
if ( next ) {
|
|
1042
|
+
next()
|
|
1043
|
+
}
|
|
1542
1044
|
|
|
1543
|
-
|
|
1045
|
+
freeMemory([jsonObj, data, request, response, next]);
|
|
1046
|
+
}, 200);
|
|
1544
1047
|
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
parseDataObject(o[i], obj);
|
|
1548
|
-
} else if (o[i] == '_content_'){
|
|
1549
|
-
o[i] = obj
|
|
1048
|
+
// force completion
|
|
1049
|
+
return
|
|
1550
1050
|
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
* @param {string} nave - variable name to set
|
|
1560
|
-
* @param {string|object} value - value to set
|
|
1561
|
-
* @param {boolean} [override]
|
|
1562
|
-
*
|
|
1563
|
-
* @returns {void}
|
|
1564
|
-
* */
|
|
1565
|
-
var set = function(name, value, override) {
|
|
1566
|
-
|
|
1567
|
-
var override = ( typeof(override) != 'undefined' ) ? override : false;
|
|
1568
|
-
|
|
1569
|
-
if ( typeof(name) == 'string' && /\./.test(name) ) {
|
|
1570
|
-
var keys = name.split(/\./g)
|
|
1571
|
-
, newObj = {}
|
|
1572
|
-
, str = '{'
|
|
1573
|
-
, _count = 0;
|
|
1574
|
-
|
|
1575
|
-
for (let k = 0, len = keys.length; k<len; ++k) {
|
|
1576
|
-
str += "\""+ keys.splice(0,1)[0] + "\":{";
|
|
1577
|
-
|
|
1578
|
-
++_count;
|
|
1579
|
-
if (k == len-1) {
|
|
1580
|
-
str = str.substr(0, str.length-1);
|
|
1581
|
-
str += "\"_content_\"";
|
|
1582
|
-
for (let c = 0; c<_count; ++c) {
|
|
1583
|
-
str += "}"
|
|
1584
|
-
}
|
|
1051
|
+
// normal case
|
|
1052
|
+
response.end(JSON.stringify(jsonObj));
|
|
1053
|
+
if (!headersSent(response)) {
|
|
1054
|
+
try {
|
|
1055
|
+
response.headersSent = true;
|
|
1056
|
+
} catch(err) {
|
|
1057
|
+
// Ignoring warning
|
|
1058
|
+
//console.warn(err);
|
|
1585
1059
|
}
|
|
1586
1060
|
}
|
|
1061
|
+
if ( next ) {
|
|
1062
|
+
return next()
|
|
1063
|
+
}
|
|
1587
1064
|
|
|
1588
|
-
|
|
1589
|
-
local.userData = merge(local.userData, newObj);
|
|
1590
|
-
|
|
1591
|
-
freeMemory([name, value, keys, newObj, str, _count], false);
|
|
1592
|
-
|
|
1593
|
-
} else if ( typeof(local.userData[name]) == 'undefined' ) {
|
|
1594
|
-
local.userData[name] = value.replace(/\\/g, '');
|
|
1595
|
-
freeMemory([name, value], false)
|
|
1596
|
-
}
|
|
1597
|
-
}
|
|
1598
|
-
|
|
1599
|
-
/**
|
|
1600
|
-
* Get data
|
|
1601
|
-
*
|
|
1602
|
-
* @param {String} variable Data name to set
|
|
1603
|
-
* @returns {Object | String} data Data object or String
|
|
1604
|
-
* */
|
|
1605
|
-
var get = function(variable) {
|
|
1606
|
-
return local.userData[variable]
|
|
1607
|
-
}
|
|
1608
|
-
|
|
1609
|
-
/**
|
|
1610
|
-
* Set resources
|
|
1611
|
-
*
|
|
1612
|
-
* @param {object} template - template configuration
|
|
1613
|
-
* */
|
|
1614
|
-
var setResources = function(viewConf) {
|
|
1615
|
-
if (!viewConf) {
|
|
1616
|
-
return self.throwError(500, new Error('No views configuration found. Did you try to add views before using Controller::render(...) ? Try to run: gina view:add '+ options.conf.bundle +' @'+ options.conf.projectName));
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
|
-
var authority = ( typeof(local.req.headers['x-forwarded-proto']) != 'undefined' ) ? local.req.headers['x-forwarded-proto'] : local.options.conf.server.scheme;
|
|
1620
|
-
authority += '://'+ local.req.headers.host;
|
|
1621
|
-
var useWebroot = false;
|
|
1622
|
-
if ( !/^\/$/.test(local.options.conf.server.webroot) && local.options.conf.server.webroot.length > 0 && local.options.conf.hostname.replace(/\:\d+$/, '') == authority ) {
|
|
1623
|
-
useWebroot = true
|
|
1624
|
-
}
|
|
1625
|
-
authority = null;
|
|
1626
|
-
|
|
1627
|
-
var reURL = new RegExp('^'+ local.options.conf.server.webroot);
|
|
1065
|
+
freeMemory([jsonObj, data, request, response, next]);
|
|
1628
1066
|
|
|
1629
|
-
|
|
1067
|
+
return;
|
|
1630
1068
|
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
cssStr = getNodeRes('css', viewConf.stylesheets, useWebroot, reURL)
|
|
1634
|
-
}
|
|
1635
|
-
//Get js
|
|
1636
|
-
if( viewConf.javascripts ) {
|
|
1637
|
-
jsStr = getNodeRes('js', viewConf.javascripts, useWebroot, reURL)
|
|
1069
|
+
} catch (err) {
|
|
1070
|
+
return self.throwError(response, 500, err);
|
|
1638
1071
|
}
|
|
1639
|
-
|
|
1640
|
-
set('page.view.stylesheets', cssStr);
|
|
1641
|
-
set('page.view.scripts', jsStr);
|
|
1642
|
-
|
|
1643
|
-
reURL = null;
|
|
1644
|
-
cssStr = null;
|
|
1645
|
-
jsStr = null;
|
|
1646
1072
|
}
|
|
1647
1073
|
|
|
1648
|
-
/**
|
|
1649
|
-
* Get node resources
|
|
1650
|
-
*
|
|
1651
|
-
* @param {string} type
|
|
1652
|
-
* @param {string} resStr
|
|
1653
|
-
* @param {array} resArr
|
|
1654
|
-
* @param {object} resObj
|
|
1655
|
-
*
|
|
1656
|
-
* @returns {object} content
|
|
1657
|
-
*
|
|
1658
|
-
* @private
|
|
1659
|
-
* */
|
|
1660
|
-
var getNodeRes = function(type, resArr, useWebroot, reURL) {
|
|
1661
1074
|
|
|
1662
|
-
|
|
1663
|
-
, rLen = resArr.length
|
|
1664
|
-
, obj = null
|
|
1665
|
-
, str = ''
|
|
1666
|
-
, requestHost = ( /http\/2/.test(local.options.conf.server.protocol) )
|
|
1667
|
-
? local.req.headers[':host']
|
|
1668
|
-
: local.req.headers.host
|
|
1669
|
-
, hostname = ( typeof(requestHost) != 'undefined' && local.options.conf.host != requestHost)
|
|
1670
|
-
? local.options.conf.server.scheme +'://'+ requestHost + ':'+ local.options.conf.server.port
|
|
1671
|
-
: local.options.conf.hostname
|
|
1672
|
-
;
|
|
1673
|
-
switch(type){
|
|
1674
|
-
case 'css':
|
|
1675
|
-
for (; r < rLen; ++r) {
|
|
1676
|
-
obj = resArr[r];
|
|
1677
|
-
if (useWebroot && !reURL.test(obj.url) ) {
|
|
1678
|
-
obj.url = local.options.conf.server.webroot + obj.url.substr(1);
|
|
1679
|
-
}
|
|
1680
|
-
// TODO - add support for cdn
|
|
1681
|
-
if (!/\:\/\//.test(obj.url) ) {
|
|
1682
|
-
obj.url = hostname + obj.url;
|
|
1683
|
-
}
|
|
1075
|
+
this.renderTEXT = function(content) {
|
|
1684
1076
|
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1077
|
+
// preventing multiple call of self.renderTEXT() when controller is rendering from another required controller
|
|
1078
|
+
if (local.options.renderingStack.length > 1) {
|
|
1079
|
+
return false
|
|
1080
|
+
}
|
|
1081
|
+
if ( self.isProcessingError ) {
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1691
1084
|
|
|
1692
|
-
|
|
1693
|
-
|
|
1085
|
+
var request = local.req;
|
|
1086
|
+
var response = local.res;
|
|
1087
|
+
var next = local.next || null;
|
|
1088
|
+
// var stream = null;
|
|
1089
|
+
// if ( /http\/2/.test(local.options.conf.server.protocol) ) {
|
|
1090
|
+
// stream = response.stream;
|
|
1091
|
+
// }
|
|
1694
1092
|
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
}
|
|
1700
|
-
// TODO - add support for cdn
|
|
1701
|
-
if (!/\:\/\//.test(obj.url) ) {
|
|
1702
|
-
obj.url = hostname + obj.url;
|
|
1703
|
-
}
|
|
1704
|
-
str += '\n\t\t<script'+ deferMode +' type="'+ obj.type +'" src="'+ obj.url +'"></script>'
|
|
1705
|
-
}
|
|
1706
|
-
break;
|
|
1093
|
+
// Added on 2023-06-12
|
|
1094
|
+
if ( headersSent(response) ) {
|
|
1095
|
+
freeMemory([content, request, response, next]);
|
|
1096
|
+
return;
|
|
1707
1097
|
}
|
|
1708
|
-
r = null;
|
|
1709
|
-
rLen = null;
|
|
1710
|
-
obj = null;
|
|
1711
1098
|
|
|
1099
|
+
if ( typeof(content) != "string" ) {
|
|
1100
|
+
content = content.toString();
|
|
1101
|
+
}
|
|
1712
1102
|
|
|
1713
|
-
|
|
1714
|
-
|
|
1103
|
+
// if (typeof(options) != "undefined" && typeof(options.charset) !="undefined") {
|
|
1104
|
+
// response.setHeader("charset", options.charset);
|
|
1105
|
+
// }
|
|
1106
|
+
if ( !response.getHeaders()['content-type'] ) {
|
|
1107
|
+
response.setHeader('content-type', 'text/plain' + '; charset='+ local.options.conf.encoding);
|
|
1108
|
+
}
|
|
1715
1109
|
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1110
|
+
if ( !headersSent() ) {
|
|
1111
|
+
console.info(request.method +' ['+response.statusCode +'] '+ request.url);
|
|
1112
|
+
response.end(content);
|
|
1113
|
+
try {
|
|
1114
|
+
response.headersSent = true
|
|
1115
|
+
} catch(err) {
|
|
1116
|
+
// Ignoring warning
|
|
1117
|
+
//console.warn(err);
|
|
1118
|
+
}
|
|
1722
1119
|
|
|
1723
|
-
|
|
1724
|
-
|
|
1120
|
+
freeMemory([content, request, response, next]);
|
|
1121
|
+
}
|
|
1725
1122
|
}
|
|
1726
1123
|
|
|
1727
1124
|
|
|
1728
|
-
var isValidURL = function(url){
|
|
1729
|
-
// var re = /(http|ftp|https|sftp):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/;
|
|
1730
|
-
return (/(http|ftp|https|sftp):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/.test(url)) ? true : false;
|
|
1731
|
-
}
|
|
1732
1125
|
|
|
1733
1126
|
/**
|
|
1734
1127
|
* Set method - Override current method
|
|
@@ -1797,7 +1190,7 @@ function SuperController(options) {
|
|
|
1797
1190
|
|
|
1798
1191
|
if (
|
|
1799
1192
|
staticProps.isStaticFilename && staticsArr.indexOf(url) > -1
|
|
1800
|
-
|| staticProps.isStaticFilename && staticsArr.indexOf( url.replace(url.
|
|
1193
|
+
|| staticProps.isStaticFilename && staticsArr.indexOf( url.replace(url.substring(url.lastIndexOf('/')+1), '') ) > -1
|
|
1801
1194
|
|| staticProps.isStaticFilename && staticsArr.indexOf(staticProps.firstLevel) > -1
|
|
1802
1195
|
) {
|
|
1803
1196
|
staticProps = null;
|
|
@@ -1895,9 +1288,9 @@ function SuperController(options) {
|
|
|
1895
1288
|
// ignoreWebRoot = false
|
|
1896
1289
|
// } else
|
|
1897
1290
|
if (typeof(res) === 'string' || typeof(res) === 'number' || typeof(res) === 'boolean') {
|
|
1898
|
-
if (
|
|
1291
|
+
if ( /^(true|1)$/i.test(res) ) {
|
|
1899
1292
|
ignoreWebRoot = true
|
|
1900
|
-
} else if (
|
|
1293
|
+
} else if ( /^(false|0)$/i.test(res) ) {
|
|
1901
1294
|
ignoreWebRoot = false
|
|
1902
1295
|
} else {
|
|
1903
1296
|
res = local.res;
|
|
@@ -1918,13 +1311,13 @@ function SuperController(options) {
|
|
|
1918
1311
|
|
|
1919
1312
|
}
|
|
1920
1313
|
|
|
1921
|
-
if ( req.
|
|
1922
|
-
// if (wroot.
|
|
1923
|
-
// wroot = wroot.
|
|
1314
|
+
if ( req.substring(0,1) === '/') { // is relative (not checking if the URI is defined in the routing.json)
|
|
1315
|
+
// if (wroot.substring(wroot.length-1,1) == '/') {
|
|
1316
|
+
// wroot = wroot.substring(wroot.length-1,1).replace('/', '')
|
|
1924
1317
|
// }
|
|
1925
1318
|
|
|
1926
1319
|
if ( /^\//.test(req) && !ignoreWebRoot )
|
|
1927
|
-
req = req.
|
|
1320
|
+
req = req.substring(1);
|
|
1928
1321
|
|
|
1929
1322
|
rte = ( ignoreWebRoot != null && ignoreWebRoot ) ? req : wroot + req;
|
|
1930
1323
|
// cleaning url in case of ?param=value
|
|
@@ -2015,11 +1408,32 @@ function SuperController(options) {
|
|
|
2015
1408
|
|
|
2016
1409
|
if ( !self.forward404Unless(condition, req, res) ) { // forward to 404 if bad route
|
|
2017
1410
|
|
|
2018
|
-
var
|
|
2019
|
-
var
|
|
1411
|
+
var localRequestPort = local.req.headers.port || local.req.headers[':port'];
|
|
1412
|
+
var isProxyHost = (
|
|
1413
|
+
typeof(local.req.headers.host) != 'undefined'
|
|
1414
|
+
&& typeof(localRequestPort) != 'undefined'
|
|
1415
|
+
&& /^(80|443)$/.test(localRequestPort)
|
|
1416
|
+
&& local.options.conf.server.scheme +'://'+ local.req.headers.host +':'+ localRequestPort != local.options.conf.hostname.replace(/\:\d+$/, '') +':'+ local.options.conf.server.port
|
|
1417
|
+
||
|
|
1418
|
+
typeof(local.req.headers[':authority']) != 'undefined'
|
|
1419
|
+
&& local.options.conf.server.scheme +'://'+ local.req.headers[':authority'] != local.options.conf.hostname
|
|
1420
|
+
||
|
|
1421
|
+
typeof(local.req.headers.host) != 'undefined'
|
|
1422
|
+
&& typeof(localRequestPort) != 'undefined'
|
|
1423
|
+
&& /^(80|443)$/.test(localRequestPort)
|
|
1424
|
+
&& req.headers.host == local.options.conf.host
|
|
1425
|
+
||
|
|
1426
|
+
typeof(local.req.headers['x-nginx-proxy']) != 'undefined'
|
|
1427
|
+
&& /^true$/i.test(local.req.headers['x-nginx-proxy'])
|
|
1428
|
+
||
|
|
1429
|
+
typeof(process.gina.PROXY_HOSTNAME) != 'undefined'
|
|
1430
|
+
) ? true : false;
|
|
1431
|
+
|
|
1432
|
+
// var isProxyHost = getContext('isProxyHost');
|
|
1433
|
+
var hostname = (isProxyHost)
|
|
1434
|
+
? process.gina.PROXY_HOSTNAME
|
|
1435
|
+
: ctx.config.envConf[bundle][env].hostname;
|
|
2020
1436
|
|
|
2021
|
-
// if ( !/\:\d+$/.test(req.headers.host) )
|
|
2022
|
-
// hostname = hostname.replace(/\:\d+$/, '');
|
|
2023
1437
|
|
|
2024
1438
|
if (route) { // will go with route first
|
|
2025
1439
|
|
|
@@ -2078,7 +1492,7 @@ function SuperController(options) {
|
|
|
2078
1492
|
originalMethod && !/GET/i.test(originalMethod)
|
|
2079
1493
|
) { // trying to redirect using the wrong method ?
|
|
2080
1494
|
|
|
2081
|
-
console.warn(new Error('Your are trying to redirect using the wrong method: `'+ req.method+'`.\nThis can often occur while redirecting from a controller to another controller or from a bundle to another.\nA redirection is not permitted in this scenario.\
|
|
1495
|
+
console.warn(new Error('Your are trying to redirect using the wrong method: `'+ req.method+'`.\nThis can often occur while redirecting from a controller to another controller or from a bundle to another.\nA redirection is not permitted in this scenario.\nDon\'t panic :)\nSwitching request method to `GET` method instead.\n').message);
|
|
2082
1496
|
method = local.req.method = self.setRequestMethod('GET', conf);
|
|
2083
1497
|
code = 303;
|
|
2084
1498
|
}
|
|
@@ -2287,9 +1701,8 @@ function SuperController(options) {
|
|
|
2287
1701
|
* @param {string} url - eg.: https://upload.wikimedia.org/wikipedia/fr/2/2f/Firefox_Old_Logo.png
|
|
2288
1702
|
* @param {object} [options]
|
|
2289
1703
|
*
|
|
2290
|
-
*
|
|
2291
1704
|
* */
|
|
2292
|
-
this.downloadFromURL = function(url, options) {
|
|
1705
|
+
this.downloadFromURL = function(url, options, cb) {
|
|
2293
1706
|
|
|
2294
1707
|
var defaultOptions = {
|
|
2295
1708
|
// file name i you want to rename the file
|
|
@@ -2326,15 +1739,13 @@ function SuperController(options) {
|
|
|
2326
1739
|
|
|
2327
1740
|
if ( /\:\/\//.test(url) ) {
|
|
2328
1741
|
scheme = url.match(/^\w+\:/)[0];
|
|
2329
|
-
scheme = scheme.
|
|
1742
|
+
scheme = scheme.substring(0, scheme.length-1);
|
|
2330
1743
|
|
|
2331
1744
|
if ( !/^http/.test(scheme) ) {
|
|
2332
1745
|
self.throwError(local.res, 500, new Error('[ '+ scheme +' ] Scheme not supported. Ref.: `http` or `https` only'));
|
|
2333
1746
|
return;
|
|
2334
1747
|
}
|
|
2335
1748
|
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
1749
|
} else { // by default
|
|
2339
1750
|
scheme = 'http';
|
|
2340
1751
|
}
|
|
@@ -2342,9 +1753,10 @@ function SuperController(options) {
|
|
|
2342
1753
|
requestOptions.scheme = scheme +':';
|
|
2343
1754
|
|
|
2344
1755
|
//defining port
|
|
1756
|
+
// console.debug('[ CONTROLLER ][ HTTP/2.0#downloadFromURL ] defining port from: ', url);
|
|
2345
1757
|
var port = url.match(/\:\d+\//) || null;
|
|
2346
1758
|
if ( port != null ) {
|
|
2347
|
-
port = port[0].
|
|
1759
|
+
port = port[0].match(/\d+/)[0];
|
|
2348
1760
|
requestOptions.port = ~~port;
|
|
2349
1761
|
}
|
|
2350
1762
|
|
|
@@ -2376,7 +1788,7 @@ function SuperController(options) {
|
|
|
2376
1788
|
opt.contentDisposition += '; filename=' + filename;
|
|
2377
1789
|
}
|
|
2378
1790
|
|
|
2379
|
-
var ext = filename.match(/\.\w+$/)[0].
|
|
1791
|
+
var ext = filename.match(/\.\w+$/)[0].substring(1)
|
|
2380
1792
|
, contentType = null
|
|
2381
1793
|
, tmp = _(GINA_TMPDIR +'/'+ filename, true)
|
|
2382
1794
|
;
|
|
@@ -2394,11 +1806,32 @@ function SuperController(options) {
|
|
|
2394
1806
|
requestOptions.headers['content-type'] = contentType;
|
|
2395
1807
|
requestOptions.headers['content-disposition'] = opt.contentDisposition;
|
|
2396
1808
|
|
|
1809
|
+
if (
|
|
1810
|
+
typeof(local.req.headers['x-client-ip']) != 'undefined'
|
|
1811
|
+
&& local.req.headers['x-client-ip'] != requestOptions.headers['x-client-ip']
|
|
1812
|
+
) {
|
|
1813
|
+
requestOptions.headers['x-client-ip'] = local.req.headers['x-client-ip']
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
if (
|
|
1817
|
+
typeof(local.req.headers['x-ingress-ip']) != 'undefined'
|
|
1818
|
+
&& local.req.headers['x-ingress-ip'] != requestOptions.headers['x-ingress-ip']
|
|
1819
|
+
) {
|
|
1820
|
+
requestOptions.headers['x-ingress-ip'] = local.req.headers['x-ingress-ip']
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
if (
|
|
1824
|
+
typeof(local.req.headers['x-forwarded-for']) != 'undefined'
|
|
1825
|
+
&& local.req.headers['x-forwarded-for'] != requestOptions.headers['x-forwarded-for']
|
|
1826
|
+
) {
|
|
1827
|
+
requestOptions.headers['x-forwarded-for'] = local.req.headers['x-forwarded-for']
|
|
1828
|
+
}
|
|
1829
|
+
|
|
2397
1830
|
var browser = require(''+ scheme);
|
|
2398
|
-
//console.debug('requestOptions: \n', JSON.stringify(requestOptions, null,
|
|
1831
|
+
// console.debug('requestOptions: \n', JSON.stringify(requestOptions, null, 2));
|
|
2399
1832
|
|
|
2400
1833
|
browser
|
|
2401
|
-
.get(requestOptions, function(response) {
|
|
1834
|
+
.get(requestOptions, async function(response) {
|
|
2402
1835
|
|
|
2403
1836
|
local.res.setHeader('content-type', contentType + '; charset='+ local.options.conf.encoding);
|
|
2404
1837
|
local.res.setHeader('content-disposition', opt.contentDisposition);
|
|
@@ -2410,9 +1843,15 @@ function SuperController(options) {
|
|
|
2410
1843
|
// local.res.setHeader('pragma', 'must-revalidate');
|
|
2411
1844
|
|
|
2412
1845
|
|
|
2413
|
-
response.pipe(local.res);
|
|
1846
|
+
await response.pipe(local.res);
|
|
1847
|
+
if ( typeof(cb) != 'undefined' ) {
|
|
1848
|
+
cb(false)
|
|
1849
|
+
}
|
|
2414
1850
|
})
|
|
2415
1851
|
.on('error', function onDownloadError(err) {
|
|
1852
|
+
if ( typeof(cb) != 'undefined' ) {
|
|
1853
|
+
return cb(err)
|
|
1854
|
+
}
|
|
2416
1855
|
self.throwError(local.res, 500, err);
|
|
2417
1856
|
});
|
|
2418
1857
|
|
|
@@ -2659,7 +2098,8 @@ function SuperController(options) {
|
|
|
2659
2098
|
) {
|
|
2660
2099
|
return false
|
|
2661
2100
|
}
|
|
2662
|
-
|
|
2101
|
+
// by default
|
|
2102
|
+
self.isProcessingError = false;
|
|
2663
2103
|
|
|
2664
2104
|
var queryData = {}
|
|
2665
2105
|
, defaultOptions = local.query.options
|
|
@@ -2669,14 +2109,14 @@ function SuperController(options) {
|
|
|
2669
2109
|
|
|
2670
2110
|
// options must be used as a copy in case of multiple calls of self.query(options, ...)
|
|
2671
2111
|
options = merge(JSON.clone(options), defaultOptions);
|
|
2672
|
-
// options = merge(options, defaultOptions);
|
|
2673
2112
|
|
|
2674
|
-
for (
|
|
2113
|
+
for (let o in options) {//cleaning
|
|
2675
2114
|
if ( typeof(options[o]) == 'undefined' || options[o] == undefined) {
|
|
2676
2115
|
delete options[o]
|
|
2677
2116
|
}
|
|
2678
2117
|
}
|
|
2679
2118
|
|
|
2119
|
+
|
|
2680
2120
|
if (self.isCacheless() || self.isLocalScope() ) {
|
|
2681
2121
|
options.rejectUnauthorized = false;
|
|
2682
2122
|
}
|
|
@@ -2745,14 +2185,17 @@ function SuperController(options) {
|
|
|
2745
2185
|
if ( local.req != null && typeof(local.req.ginaHeaders) != 'undefined' ) {
|
|
2746
2186
|
// gina form headers
|
|
2747
2187
|
for (let h in local.req.ginaHeaders.form) {
|
|
2748
|
-
let k = h.
|
|
2188
|
+
let k = h.substring(0,1).toUpperCase() + h.substring(1);
|
|
2749
2189
|
options.headers['X-Gina-Form-' + k ] = local.req.ginaHeaders.form[h];
|
|
2750
2190
|
}
|
|
2751
2191
|
}
|
|
2752
2192
|
|
|
2753
|
-
var ctx
|
|
2754
|
-
, protocol
|
|
2755
|
-
, scheme
|
|
2193
|
+
var ctx = getContext()
|
|
2194
|
+
, protocol = null
|
|
2195
|
+
, scheme = null
|
|
2196
|
+
, isProxyHost = getContext('isProxyHost')
|
|
2197
|
+
, bundle = null
|
|
2198
|
+
, webroot = options.webroot || ctx.gina.config.envConf[ctx.bundle][ctx.env].server.webroot;// bundle servers's webroot by default
|
|
2756
2199
|
;
|
|
2757
2200
|
// cleanup options.path
|
|
2758
2201
|
if (/\:\/\//.test(options.path)) {
|
|
@@ -2769,11 +2212,16 @@ function SuperController(options) {
|
|
|
2769
2212
|
.replace(':'+port, '');
|
|
2770
2213
|
}
|
|
2771
2214
|
|
|
2215
|
+
// if ( typeof(options.protocol) == 'undefined' ) {
|
|
2216
|
+
// options.protocol = ctx.gina.config.envConf[ctx.bundle][ctx.env].server.protocol;
|
|
2217
|
+
// }
|
|
2218
|
+
|
|
2772
2219
|
// retrieve protocol & scheme: if empty, take the bundles protocol
|
|
2773
2220
|
protocol = options.protocol || ctx.gina.config.envConf[ctx.bundle][ctx.env].server.protocol;// bundle servers's protocol by default
|
|
2774
2221
|
protocol = protocol.match(/[.a-z 0-9]+/ig)[0];
|
|
2775
2222
|
scheme = options.scheme || ctx.gina.config.envConf[ctx.bundle][ctx.env].server.scheme;// bundle servers's scheme by default
|
|
2776
2223
|
scheme = scheme.match(/[a-z 0-9]+/ig)[0];
|
|
2224
|
+
|
|
2777
2225
|
// retrieve credentials
|
|
2778
2226
|
if ( typeof(options.ca) == 'undefined' || ! options.ca ) {
|
|
2779
2227
|
options.ca = ctx.gina.config.envConf[ctx.bundle][ctx.env].server.credentials.ca;
|
|
@@ -2782,24 +2230,18 @@ function SuperController(options) {
|
|
|
2782
2230
|
//retrieving dynamic host, hostname & port
|
|
2783
2231
|
if ( /\@/.test(options.hostname) ) {
|
|
2784
2232
|
|
|
2785
|
-
|
|
2786
|
-
|
|
2233
|
+
bundle = ( options.hostname.replace(/(.*)\:\/\//, '') ).split(/\@/)[0];
|
|
2787
2234
|
// No shorcut possible because conf.hostname might differ from user inputs
|
|
2788
2235
|
options.host = ctx.gina.config.envConf[bundle][ctx.env].host.replace(/(.*)\:\/\//, '').replace(/\:\d+/, '');
|
|
2789
2236
|
options.hostname = ctx.gina.config.envConf[bundle][ctx.env].hostname;
|
|
2790
2237
|
options.port = ctx.gina.config.envConf[bundle][ctx.env].server.port;
|
|
2791
|
-
|
|
2792
|
-
options.protocol = ctx.gina.config.envConf[bundle][ctx.env].server.protocol;
|
|
2238
|
+
options.protocol = options.protocol || ctx.gina.config.envConf[bundle][ctx.env].server.protocol;
|
|
2793
2239
|
options.scheme = ctx.gina.config.envConf[bundle][ctx.env].server.scheme;
|
|
2794
2240
|
|
|
2795
2241
|
// retrieve credentials
|
|
2796
2242
|
if ( typeof(options.ca) == 'undefined' || ! options.ca ) {
|
|
2797
2243
|
options.ca = ctx.gina.config.envConf[bundle][ctx.env].server.credentials.ca;
|
|
2798
2244
|
}
|
|
2799
|
-
|
|
2800
|
-
// might be != from the bundle requesting
|
|
2801
|
-
//options.protocol = ctx.gina.config.envConf[bundle][ctx.env].content.settings.server.protocol || ctx.gina.config.envConf[bundle][ctx.env].server.protocol;
|
|
2802
|
-
//options.scheme = ctx.gina.config.envConf[bundle][ctx.env].content.settings.server.scheme || ctx.gina.config.envConf[bundle][ctx.env].server.scheme;
|
|
2803
2245
|
}
|
|
2804
2246
|
|
|
2805
2247
|
if ( typeof(options.protocol) == 'undefined' ) {
|
|
@@ -2813,45 +2255,224 @@ function SuperController(options) {
|
|
|
2813
2255
|
|
|
2814
2256
|
|
|
2815
2257
|
// reformating scheme
|
|
2816
|
-
if( !/\:$/.test(options.scheme) )
|
|
2258
|
+
if( !/\:$/.test(options.scheme) ) {
|
|
2817
2259
|
options.scheme += ':';
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
if (isProxyHost) {
|
|
2263
|
+
// X-Forwarded-Host
|
|
2264
|
+
options.headers['x-forwarded-host'] = process.gina.PROXY_HOST;
|
|
2265
|
+
// X-Forwarded-Proto
|
|
2266
|
+
options.headers['x-forwarded-proto'] = process.gina.PROXY_SCHEME;
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
if ( ctx.gina.config.envConf[ctx.bundle][ctx.env].server.resolvers.length > 0 ) {
|
|
2270
|
+
var resolversColl = new Collection(ctx.gina.config.envConf[ctx.bundle][ctx.env].server.resolvers);
|
|
2271
|
+
options.nameservers = resolversColl.findOne({ scope: process.env.NODE_SCOPE}).nameservers;
|
|
2272
|
+
resolversColl = null;
|
|
2273
|
+
}
|
|
2818
2274
|
|
|
2819
2275
|
try {
|
|
2820
2276
|
options.queryData = queryData;
|
|
2277
|
+
|
|
2278
|
+
bundle = null;
|
|
2279
|
+
|
|
2280
|
+
// TODO - Add preferred communication method option: cCurl or HTTP
|
|
2281
|
+
// return handleCurlRequest(options, callback);
|
|
2282
|
+
|
|
2821
2283
|
var protocolVersion = ~~options.protocol.match(/\/(.*)$/)[1].replace(/\.\d+/, '');
|
|
2822
2284
|
var httpLib = options.protocol.match(/^(.*)\//)[1] + ( (protocolVersion >= 2) ? protocolVersion : '' );
|
|
2823
2285
|
if ( !/http2/.test(httpLib) && /https/.test(options.scheme) ) {
|
|
2824
2286
|
httpLib += 's';
|
|
2825
2287
|
}
|
|
2826
|
-
|
|
2827
2288
|
browser = require(''+ httpLib);
|
|
2828
|
-
|
|
2829
2289
|
if ( /http2/.test(httpLib) ) {
|
|
2830
2290
|
return handleHTTP2ClientRequest(browser, options, callback);
|
|
2831
2291
|
} else {
|
|
2832
2292
|
return handleHTTP1ClientRequest(browser, options, callback);
|
|
2833
2293
|
}
|
|
2834
2294
|
|
|
2835
|
-
|
|
2836
2295
|
} catch(err) {
|
|
2837
2296
|
if (callback) {
|
|
2838
2297
|
return callback(err)
|
|
2839
2298
|
}
|
|
2840
2299
|
self.emit('query#complete', err)
|
|
2841
2300
|
}
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
var handleCurlRequest = async function(opt, callback) {
|
|
2304
|
+
|
|
2305
|
+
|
|
2306
|
+
var body = null;
|
|
2307
|
+
// https://docs.couchbase.com/server/current/n1ql-rest-query/index.html#Request
|
|
2308
|
+
var cmd = [
|
|
2309
|
+
'$(which curl)'
|
|
2310
|
+
];
|
|
2311
|
+
|
|
2312
|
+
if (!opt.rejectUnauthorized) {
|
|
2313
|
+
// (SSL) This option explicitly allows curl to perform "insecure" SSL connections and transfers
|
|
2314
|
+
// same as --insecure
|
|
2315
|
+
cmd.splice(1,0,'-k');
|
|
2316
|
+
}
|
|
2317
|
+
|
|
2318
|
+
// method
|
|
2319
|
+
if ( !/get/i.test(opt.method) ) {
|
|
2320
|
+
cmd.splice(1,0,'-X '+ opt.method.toUpperCase() );
|
|
2321
|
+
}
|
|
2322
|
+
|
|
2323
|
+
|
|
2324
|
+
if ( /(post|put)/i.test(opt.method) && opt.queryData.length > 0) {
|
|
2325
|
+
cmd.push('-d '+ opt.queryData );
|
|
2326
|
+
body = Buffer.from(opt.queryData);
|
|
2327
|
+
opt.headers['content-length'] = body.length;
|
|
2328
|
+
} else if (
|
|
2329
|
+
/get/i.test(opt.method)
|
|
2330
|
+
&& typeof(opt.headers['content-length']) != 'undefined'
|
|
2331
|
+
) {
|
|
2332
|
+
delete opt.headers['content-length'];
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2335
|
+
if ( opt.headers.count() > 0) {
|
|
2336
|
+
for (let h in opt.headers) {
|
|
2337
|
+
cmd.splice(1,0,'-H "'+ h +': '+ opt.headers[h] +'"');
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2341
|
+
// resolvers
|
|
2342
|
+
if (opt.nameservers) {
|
|
2343
|
+
resolver.setServers(opt.nameservers);
|
|
2344
|
+
await resolver
|
|
2345
|
+
.resolve4(opt.host)
|
|
2346
|
+
.catch( function onResolverErr(e) {
|
|
2347
|
+
var infos = local.options, controllerName = infos.controller.substring(infos.controller.lastIndexOf('/'));
|
|
2348
|
+
var msg = 'Could not resolve with these `settings.server.resolvers`:\n'+ opt.nameservers.toString() +'\n' + e.stack+ '\nController Query Exception while catching back.\nBundle: '+ infos.bundle +'\nController File: /controllers'+ controllerName +'\nControl: this.'+ infos.control +'(...)\n\r';
|
|
2349
|
+
var exception = new Error(msg);
|
|
2350
|
+
exception.status = 500;
|
|
2351
|
+
return self.throwError(exception);
|
|
2352
|
+
})
|
|
2353
|
+
.then( function onResolved(ips) {
|
|
2354
|
+
if ( typeof(ips) == 'undefined' || !Array.isArray(ips) || !ips.length ) {
|
|
2355
|
+
var infos = local.options, controllerName = infos.controller.substring(infos.controller.lastIndexOf('/'));
|
|
2356
|
+
var e = new Error('`Unable to resolve ${opt.host}`');
|
|
2357
|
+
var msg = 'Please check`settings.server.resolvers`:\n'+ opt.nameservers.toString() +'\n'+ e.stack + 'Controller Query Exception while catching back.\nBundle: '+ infos.bundle +'\nController File: /controllers'+ controllerName +'\nControl: this.'+ infos.control +'(...)\n\r';
|
|
2358
|
+
var exception = new Error(msg);
|
|
2359
|
+
exception.status = 500;
|
|
2360
|
+
return self.throwError(exception);
|
|
2361
|
+
}
|
|
2362
|
+
for (let i=0, len=ips.length; i<len; i++) {
|
|
2363
|
+
// e.g.: --resolve www.example.com:443:127.0.0.1
|
|
2364
|
+
cmd.push('--resolve '+ opt.host +':'+ opt.port +':'+ ips[i]);
|
|
2365
|
+
}
|
|
2366
|
+
});
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
|
|
2842
2370
|
|
|
2371
|
+
|
|
2372
|
+
cmd.push('-v "'+ opt.hostname + opt.path +'"');
|
|
2373
|
+
|
|
2374
|
+
// Default maxBuffer is 200KB (=> 1024 * 200)
|
|
2375
|
+
// Setting it to 10MB - preventing: stdout maxBuffer length exceeded
|
|
2376
|
+
var maxBuffer = (1024 * 1024 * 10);
|
|
2377
|
+
exec(cmd.join(' '), { maxBuffer: maxBuffer }, function onResult(err, dataStr, infos) {
|
|
2378
|
+
var error = null;
|
|
2379
|
+
if (err) {
|
|
2380
|
+
try {
|
|
2381
|
+
// by default
|
|
2382
|
+
error = new Error('[ CONTROLLER ][ CURL#query ] request aborted\n'+ err.stack);
|
|
2383
|
+
if (
|
|
2384
|
+
typeof(err.message) != 'undefined'
|
|
2385
|
+
&& /Failed to connect/i.test(err.message)
|
|
2386
|
+
) {
|
|
2387
|
+
var port = getContext('gina').ports[opt.protocol][opt.scheme.replace(/\:/, '')][ opt.port ];
|
|
2388
|
+
error.accessPoint = port;
|
|
2389
|
+
error.message = 'Could not connect to [ ' + error.accessPoint + ' ].\nThe `'+port.split(/\@/)[0]+'` bundle is offline or unreachable.\n';
|
|
2390
|
+
}
|
|
2391
|
+
console.error(error.stack);
|
|
2392
|
+
if ( typeof(callback) != 'undefined' ) {
|
|
2393
|
+
callback(error)
|
|
2394
|
+
} else {
|
|
2395
|
+
self.emit('query#complete', error)
|
|
2396
|
+
}
|
|
2397
|
+
} catch (e) {
|
|
2398
|
+
// console.error(e.stack);
|
|
2399
|
+
var infos = local.options, controllerName = infos.controller.substring(infos.controller.lastIndexOf('/'));
|
|
2400
|
+
var msg = 'Controller Query Exception while catching back.\nBundle: '+ infos.bundle +'\nController File: /controllers'+ controllerName +'\nControl: this.'+ infos.control +'(...)\n\r' + e.stack;
|
|
2401
|
+
var exception = new Error(msg);
|
|
2402
|
+
exception.status = 500;
|
|
2403
|
+
self.throwError(exception);
|
|
2404
|
+
}
|
|
2405
|
+
return;
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
|
|
2409
|
+
try {
|
|
2410
|
+
let data = JSON.parse(dataStr);
|
|
2411
|
+
if ( typeof(data) == 'undefined' ) {
|
|
2412
|
+
data = {}
|
|
2413
|
+
}
|
|
2414
|
+
if ( typeof(callback) != 'undefined' ) {
|
|
2415
|
+
callback(err, data)
|
|
2416
|
+
} else {
|
|
2417
|
+
self.emit('query#complete', err, data)
|
|
2418
|
+
}
|
|
2419
|
+
} catch (e) {
|
|
2420
|
+
// _err.stack = '[ CONTROLLER ][ CURL#query ] onCallbackError: '+ e.stack;
|
|
2421
|
+
// console.error(e.stack);
|
|
2422
|
+
var infos = local.options, controllerName = infos.controller.substring(infos.controller.lastIndexOf('/'));
|
|
2423
|
+
var msg = 'Controller Query Exception while catching back.\nBundle: '+ infos.bundle +'\nController File: /controllers'+ controllerName +'\nControl: this.'+ infos.control +'(...)\n\r' + e.stack;
|
|
2424
|
+
var exception = new Error(msg);
|
|
2425
|
+
exception.status = 500;
|
|
2426
|
+
self.throwError(exception);
|
|
2427
|
+
return;
|
|
2428
|
+
}
|
|
2429
|
+
});
|
|
2843
2430
|
}
|
|
2844
2431
|
|
|
2432
|
+
var handleHTTP1ClientRequestv2 = function (browser, options, callback) {
|
|
2433
|
+
var agent = new browser.Agent({ keepAlive: true });
|
|
2434
|
+
var options = {
|
|
2435
|
+
host: options.host,
|
|
2436
|
+
port: options.port,
|
|
2437
|
+
path: options.path,
|
|
2438
|
+
method: 'GET',
|
|
2439
|
+
agent: agent
|
|
2440
|
+
};
|
|
2441
|
+
|
|
2442
|
+
var req = browser.request(options, function(res) {
|
|
2443
|
+
var str = "";
|
|
2444
|
+
var err = false;
|
|
2445
|
+
res.on('data', function (chunk) {
|
|
2446
|
+
str += chunk;
|
|
2447
|
+
});
|
|
2448
|
+
res.on('end', function () {
|
|
2449
|
+
// done
|
|
2450
|
+
return callback( err, data );
|
|
2451
|
+
});
|
|
2452
|
+
});
|
|
2453
|
+
req.write('');
|
|
2454
|
+
req.end();
|
|
2455
|
+
req.on('error', function(error) {
|
|
2456
|
+
err = error
|
|
2457
|
+
});
|
|
2458
|
+
};
|
|
2459
|
+
|
|
2845
2460
|
var handleHTTP1ClientRequest = function(browser, options, callback) {
|
|
2846
2461
|
|
|
2847
2462
|
var altOpt = JSON.clone(options);
|
|
2463
|
+
// var credentials = self.getConfig('settings').server.credentials;
|
|
2464
|
+
// options.ca = credentials.ca;
|
|
2465
|
+
// options.encKey = credentials.privateKey;
|
|
2466
|
+
// options.encCert = credentials.certificate;
|
|
2467
|
+
|
|
2848
2468
|
|
|
2849
2469
|
altOpt.protocol = options.scheme;
|
|
2850
2470
|
altOpt.hostname = options.host;
|
|
2851
2471
|
altOpt.port = options.port;
|
|
2472
|
+
altOpt.maxSockets = options.maxSockets || 1;
|
|
2852
2473
|
if ( typeof(altOpt.encKey) != 'undefined' ) {
|
|
2853
2474
|
try {
|
|
2854
|
-
altOpt.encKey = fs.readFileSync(
|
|
2475
|
+
altOpt.encKey = fs.readFileSync(altOpt.encKey);
|
|
2855
2476
|
} catch(err) {
|
|
2856
2477
|
self.emit('query#complete', err);
|
|
2857
2478
|
}
|
|
@@ -2862,7 +2483,7 @@ function SuperController(options) {
|
|
|
2862
2483
|
|
|
2863
2484
|
if ( typeof(altOpt.encCert) != 'undefined' ) {
|
|
2864
2485
|
try {
|
|
2865
|
-
altOpt.encCert = fs.readFileSync(
|
|
2486
|
+
altOpt.encCert = fs.readFileSync(altOpt.encCert);
|
|
2866
2487
|
} catch(err) {
|
|
2867
2488
|
self.emit('query#complete', err);
|
|
2868
2489
|
}
|
|
@@ -2871,6 +2492,11 @@ function SuperController(options) {
|
|
|
2871
2492
|
console.warn('[ CONTROLLER ][ HTTP/1.0#query ] options.encCert not found !');
|
|
2872
2493
|
}
|
|
2873
2494
|
|
|
2495
|
+
|
|
2496
|
+
delete altOpt.ca;
|
|
2497
|
+
delete altOpt.encKey;
|
|
2498
|
+
delete altOpt.encCert;
|
|
2499
|
+
|
|
2874
2500
|
altOpt.agent = new browser.Agent(altOpt);
|
|
2875
2501
|
|
|
2876
2502
|
var req = browser.request(altOpt, function(res) {
|
|
@@ -2930,7 +2556,7 @@ function SuperController(options) {
|
|
|
2930
2556
|
return;
|
|
2931
2557
|
}
|
|
2932
2558
|
} catch (e) {
|
|
2933
|
-
var infos = local.options, controllerName = infos.controller.
|
|
2559
|
+
var infos = local.options, controllerName = infos.controller.substring(infos.controller.lastIndexOf('/'));
|
|
2934
2560
|
var msg = 'Controller Query Exception while catching back.\nBundle: '+ infos.bundle +'\nController File: /controllers'+ controllerName +'\nControl: this.'+ infos.control +'(...)\n\r' + e.stack;
|
|
2935
2561
|
var exception = new Error(msg);
|
|
2936
2562
|
exception.status = 500;
|
|
@@ -3024,7 +2650,7 @@ function SuperController(options) {
|
|
|
3024
2650
|
cb(err, data)
|
|
3025
2651
|
}
|
|
3026
2652
|
} catch (e) {
|
|
3027
|
-
var infos = local.options, controllerName = infos.controller.
|
|
2653
|
+
var infos = local.options, controllerName = infos.controller.substring(infos.controller.lastIndexOf('/'));
|
|
3028
2654
|
var msg = 'Controller Query Exception while catching back.\nBundle: '+ infos.bundle +'\nController File: /controllers'+ controllerName +'\nControl: this.'+ infos.control +'(...)\n\r' + e.stack;
|
|
3029
2655
|
var exception = new Error(msg);
|
|
3030
2656
|
exception.status = 500;
|
|
@@ -3101,10 +2727,8 @@ function SuperController(options) {
|
|
|
3101
2727
|
delete options.queryData;
|
|
3102
2728
|
|
|
3103
2729
|
|
|
3104
|
-
|
|
3105
2730
|
const client = browser.connect(options.hostname, options);
|
|
3106
2731
|
|
|
3107
|
-
|
|
3108
2732
|
const {
|
|
3109
2733
|
HTTP2_HEADER_PROTOCOL,
|
|
3110
2734
|
HTTP2_HEADER_SCHEME,
|
|
@@ -3127,6 +2751,32 @@ function SuperController(options) {
|
|
|
3127
2751
|
options.headers['content-type'] = local.req.headers['content-type']
|
|
3128
2752
|
}
|
|
3129
2753
|
|
|
2754
|
+
if ( typeof(local.req.headers['x-client-ip']) != 'undefined' && local.req.headers['x-client-ip'] != options.headers['x-client-ip'] ) {
|
|
2755
|
+
options.headers['x-client-ip'] = local.req.headers['x-client-ip']
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2758
|
+
if ( typeof(local.req.headers['x-ingress-ip']) != 'undefined' && local.req.headers['x-ingress-ip'] != options.headers['x-ingress-ip'] ) {
|
|
2759
|
+
options.headers['x-ingress-ip'] = local.req.headers['x-ingress-ip']
|
|
2760
|
+
}
|
|
2761
|
+
|
|
2762
|
+
// x-forwarded-for check
|
|
2763
|
+
// console.debug('[ CONTROLLER ][ HTTP/2.0#query ] checking x-forwarded-for');
|
|
2764
|
+
if (
|
|
2765
|
+
// Previous proxies
|
|
2766
|
+
typeof(local.req.headers['x-forwarded-for']) != 'undefined'
|
|
2767
|
+
&& local.req.headers['x-forwarded-for'] != ""
|
|
2768
|
+
// current proxy
|
|
2769
|
+
&& typeof(local.req.headers['x-real-ip']) != 'undefined'
|
|
2770
|
+
) {
|
|
2771
|
+
// console.debug('[ CONTROLLER ][ HTTP/2.0#query ] options.headers', JSON.stringify(options.headers, null, 2));
|
|
2772
|
+
// console.debug('[ CONTROLLER ][ HTTP/2.0#query ] local.req.headers', JSON.stringify(local.req.headers, null, 2));
|
|
2773
|
+
var xForwardedFor = "" + local.req.headers['x-forwarded-for'];
|
|
2774
|
+
// Adding the current PI to the list
|
|
2775
|
+
xForwardedFor += ", "+local.req.headers['x-real-ip'];
|
|
2776
|
+
xForwardedFor = null;
|
|
2777
|
+
// console.debug('[ CONTROLLER ][ HTTP/2.0#query ] options.headers["x-forwarded-for"]', options.headers['x-forwarded-for']);
|
|
2778
|
+
}
|
|
2779
|
+
|
|
3130
2780
|
var headers = merge({
|
|
3131
2781
|
[HTTP2_HEADER_METHOD]: options[':method'],
|
|
3132
2782
|
[HTTP2_HEADER_PATH]: options[':path']
|
|
@@ -3134,7 +2784,11 @@ function SuperController(options) {
|
|
|
3134
2784
|
|
|
3135
2785
|
// merging with user options
|
|
3136
2786
|
for (var o in options) {
|
|
3137
|
-
if (
|
|
2787
|
+
if (
|
|
2788
|
+
!/^\:/.test(o)
|
|
2789
|
+
&& !/headers/.test(o)
|
|
2790
|
+
&& typeof(headers[o]) == 'undefined'
|
|
2791
|
+
) {
|
|
3138
2792
|
headers[o] = options[o]
|
|
3139
2793
|
}
|
|
3140
2794
|
}
|
|
@@ -3154,6 +2808,7 @@ function SuperController(options) {
|
|
|
3154
2808
|
}
|
|
3155
2809
|
|
|
3156
2810
|
|
|
2811
|
+
|
|
3157
2812
|
client.on('error', (error) => {
|
|
3158
2813
|
|
|
3159
2814
|
console.error( '`'+ options[':path']+ '` : '+ error.stack||error.message);
|
|
@@ -3289,7 +2944,7 @@ function SuperController(options) {
|
|
|
3289
2944
|
}
|
|
3290
2945
|
|
|
3291
2946
|
} catch (e) {
|
|
3292
|
-
var infos = local.options, controllerName = infos.controller.
|
|
2947
|
+
var infos = local.options, controllerName = infos.controller.substring(infos.controller.lastIndexOf('/'));
|
|
3293
2948
|
var msg = 'Controller Query Exception while catching back.\nBundle: '+ infos.bundle +'\nController File: /controllers'+ controllerName +'\nControl: this.'+ infos.control +'(...)\n\r' + e.stack;
|
|
3294
2949
|
var exception = new Error(msg);
|
|
3295
2950
|
exception.status = 500;
|
|
@@ -3367,7 +3022,7 @@ function SuperController(options) {
|
|
|
3367
3022
|
cb(err, data)
|
|
3368
3023
|
}
|
|
3369
3024
|
} catch (e) {
|
|
3370
|
-
var infos = local.options, controllerName = infos.controller.
|
|
3025
|
+
var infos = local.options, controllerName = infos.controller.substring(infos.controller.lastIndexOf('/'));
|
|
3371
3026
|
var msg = 'Controller Query Exception while catching back.\nBundle: '+ infos.bundle +'\nController File: /controllers'+ controllerName +'\nControl: this.'+ infos.control +'(...)\n\r' + e.stack;
|
|
3372
3027
|
var exception = new Error(msg);
|
|
3373
3028
|
exception.status = 500;
|
|
@@ -3502,11 +3157,11 @@ function SuperController(options) {
|
|
|
3502
3157
|
project = route.param.project;
|
|
3503
3158
|
} // TODO - add support for project pointer : getContext('gina').projects[project]
|
|
3504
3159
|
if (/\@(.*)$/.test(route.param.url)) {
|
|
3505
|
-
var targetedBundle = route.param.url.
|
|
3160
|
+
var targetedBundle = route.param.url.substring(route.param.url.lastIndexOf('@')+1);
|
|
3506
3161
|
hostname = targetedBundle +'@'+ project;
|
|
3507
3162
|
port = hostname;
|
|
3508
3163
|
var webroot = getContext('gina').config.envConf[targetedBundle][local.options.conf.env].server.webroot;
|
|
3509
|
-
path = (/\/$/.test(webroot)) ? webroot.
|
|
3164
|
+
path = (/\/$/.test(webroot)) ? webroot.substring(0, webroot.length-1) : webroot;
|
|
3510
3165
|
} else {
|
|
3511
3166
|
hostname = route.param.hostname;
|
|
3512
3167
|
port = route.param.port;
|
|
@@ -3560,24 +3215,28 @@ function SuperController(options) {
|
|
|
3560
3215
|
*
|
|
3561
3216
|
* */
|
|
3562
3217
|
this.getConfig = function(name) {
|
|
3218
|
+
var tmp = null;
|
|
3563
3219
|
if ( typeof(name) != 'undefined' ) {
|
|
3564
3220
|
try {
|
|
3565
|
-
//
|
|
3566
|
-
|
|
3567
|
-
//config = Object.freeze(local.options.conf.content[name]);
|
|
3568
|
-
//Object.seal(local.options.conf.content[name]);
|
|
3569
|
-
//Object.freeze(local.options.conf.content[name]);
|
|
3570
|
-
// if ( self.isCacheless() ) {
|
|
3571
|
-
// }
|
|
3572
|
-
return JSON.clone(local.options.conf.content[name]);
|
|
3221
|
+
// Needs to be read only
|
|
3222
|
+
tmp = JSON.clone(local.options.conf.content[name]);
|
|
3573
3223
|
} catch (err) {
|
|
3574
3224
|
return undefined;
|
|
3575
3225
|
}
|
|
3576
3226
|
} else {
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3227
|
+
tmp = JSON.clone(local.options.conf);
|
|
3228
|
+
}
|
|
3229
|
+
|
|
3230
|
+
if (
|
|
3231
|
+
getContext('isProxyHost')
|
|
3232
|
+
&& typeof(tmp.hostname) != 'undefined'
|
|
3233
|
+
) {
|
|
3234
|
+
tmp.hostname = process.gina.PROXY_HOSTNAME;
|
|
3235
|
+
tmp.host = process.gina.PROXY_HOST;
|
|
3236
|
+
// tmp.hostname = getContext('gina').config.envConf._proxyHostname
|
|
3237
|
+
// tmp.host = tmp.hostname.replace(/^(https|http)\:\/\//, '');
|
|
3580
3238
|
}
|
|
3239
|
+
return tmp;
|
|
3581
3240
|
}
|
|
3582
3241
|
|
|
3583
3242
|
/**
|
|
@@ -3687,45 +3346,64 @@ function SuperController(options) {
|
|
|
3687
3346
|
return rules;
|
|
3688
3347
|
}
|
|
3689
3348
|
|
|
3690
|
-
this.push = function(payload) {
|
|
3349
|
+
this.push = function(payload, option, callback) {
|
|
3691
3350
|
|
|
3692
3351
|
var req = local.req, res = local.res;
|
|
3693
3352
|
var method = req.method.toLowerCase();
|
|
3694
3353
|
// if no session defined, will push to all active clients
|
|
3354
|
+
// resuming current session
|
|
3695
3355
|
var sessionId = ( typeof(req[method].sessionID) != 'undefined' ) ? req[method].sessionID : null;
|
|
3696
|
-
|
|
3697
|
-
|
|
3356
|
+
// retrieve section if existing
|
|
3357
|
+
var section = ( typeof(req[method].section) != 'undefined' ) ? req[method].section : null;
|
|
3698
3358
|
|
|
3699
3359
|
if (!payload) {
|
|
3700
3360
|
payload = null;
|
|
3701
3361
|
if ( typeof(req[method]) != 'undefined' && typeof(req[method].payload) != 'undefined' ) {
|
|
3702
3362
|
if ( typeof(payload) == 'string' ) {
|
|
3703
|
-
payload = decodeURIComponent(req[method].payload)
|
|
3363
|
+
payload = decodeURIComponent(req[method].payload);
|
|
3364
|
+
payload = JSON.parse(payload);
|
|
3365
|
+
if ( section && typeof(payload.section) == 'undefined' ) {
|
|
3366
|
+
payload.section = section
|
|
3367
|
+
}
|
|
3368
|
+
payload = JSON.stringify(payload)
|
|
3704
3369
|
} else {
|
|
3370
|
+
if ( section && typeof(req[method].payload.section) == 'undefined' ) {
|
|
3371
|
+
req[method].payload.section = section
|
|
3372
|
+
}
|
|
3705
3373
|
payload = JSON.stringify(req[method].payload)
|
|
3706
3374
|
}
|
|
3707
3375
|
}
|
|
3708
3376
|
} else if ( typeof(payload) == 'object' ) {
|
|
3377
|
+
if ( section && typeof(payload.section) == 'undefined' ) {
|
|
3378
|
+
payload.section = section
|
|
3379
|
+
}
|
|
3709
3380
|
payload = JSON.stringify(payload)
|
|
3710
3381
|
}
|
|
3711
3382
|
|
|
3712
3383
|
try {
|
|
3713
3384
|
var clients = null;
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
clients.
|
|
3718
|
-
|
|
3385
|
+
clients = self.serverInstance.eio.clients;
|
|
3386
|
+
if ( clients ) {
|
|
3387
|
+
for (let s in clients) {
|
|
3388
|
+
if ( !clients[s].constructor.name == 'Socket' ) {
|
|
3389
|
+
continue;
|
|
3390
|
+
}
|
|
3719
3391
|
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3392
|
+
if (
|
|
3393
|
+
// session filter
|
|
3394
|
+
sessionId
|
|
3395
|
+
&& typeof(clients[s].sessionId) != 'undefined'
|
|
3396
|
+
&& clients[s].sessionId == sessionId
|
|
3397
|
+
||
|
|
3398
|
+
// send to all clients if no specific sessionId defined
|
|
3399
|
+
!sessionId
|
|
3400
|
+
) {
|
|
3401
|
+
clients[s].sendPacket("message", payload, options, callback);
|
|
3402
|
+
}
|
|
3725
3403
|
}
|
|
3726
3404
|
}
|
|
3727
3405
|
|
|
3728
|
-
res.end();
|
|
3406
|
+
// res.end();
|
|
3729
3407
|
} catch(err) {
|
|
3730
3408
|
self.throwError(err);
|
|
3731
3409
|
return;
|
|
@@ -3999,10 +3677,9 @@ function SuperController(options) {
|
|
|
3999
3677
|
//rootPath : self.executionPath,
|
|
4000
3678
|
// We don't want to keep original conf untouched
|
|
4001
3679
|
//conf : JSON.clone(conf),
|
|
4002
|
-
//instance: self.serverInstance,
|
|
4003
3680
|
//template: (routeHasViews) ? bundleConf.content.templates[templateName] : undefined,
|
|
4004
3681
|
//isUsingTemplate: local.isUsingTemplate,
|
|
4005
|
-
//
|
|
3682
|
+
//isCacheless: isCacheless,
|
|
4006
3683
|
path: null //, // user custom path : namespace should be ignored | left blank
|
|
4007
3684
|
//assets: {}
|
|
4008
3685
|
};
|
|
@@ -4228,11 +3905,11 @@ function SuperController(options) {
|
|
|
4228
3905
|
, ext = null
|
|
4229
3906
|
, isHtmlContent = false
|
|
4230
3907
|
, hasCustomErrorFile = false
|
|
4231
|
-
, eCode = code.toString().
|
|
3908
|
+
, eCode = code.toString().substring(0,1) + 'xx'
|
|
4232
3909
|
;
|
|
4233
|
-
var extArr = url.
|
|
3910
|
+
var extArr = url.substring(url.lastIndexOf('.')).match(/(\.[A-Za-z0-9]+)/);
|
|
4234
3911
|
if (extArr) {
|
|
4235
|
-
ext = extArr[0].
|
|
3912
|
+
ext = extArr[0].substring(1);
|
|
4236
3913
|
}
|
|
4237
3914
|
if ( !ext || /^(html|htm)$/i.test(ext) ) {
|
|
4238
3915
|
isHtmlContent = true;
|
|
@@ -4306,8 +3983,7 @@ function SuperController(options) {
|
|
|
4306
3983
|
|
|
4307
3984
|
local.req.routing = routeObj;
|
|
4308
3985
|
local.req.params.errorObject = errorObject;
|
|
4309
|
-
self.renderCustomError(local.req, res, local.next);
|
|
4310
|
-
return;
|
|
3986
|
+
return self.renderCustomError(local.req, res, local.next);
|
|
4311
3987
|
}
|
|
4312
3988
|
|
|
4313
3989
|
}
|
|
@@ -4390,7 +4066,7 @@ function SuperController(options) {
|
|
|
4390
4066
|
return next();
|
|
4391
4067
|
}
|
|
4392
4068
|
|
|
4393
|
-
if ( /http\/2/.test(protocol) ) {
|
|
4069
|
+
if ( stream && /http\/2/.test(protocol) ) {
|
|
4394
4070
|
return stream.end();
|
|
4395
4071
|
}
|
|
4396
4072
|
|