gina 0.1.6-alpha.16 → 0.1.6-alpha.161

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.
Files changed (410) hide show
  1. package/LICENSE +1 -1
  2. package/README-4Contributors.md +14 -8
  3. package/README.md +13 -4
  4. package/bin/cli +16 -2
  5. package/bin/gina +29 -1
  6. package/framework/{v0.1.6-alpha.16/lib/inherits → v0.1.6-alpha.161}/LICENSE +1 -1
  7. package/framework/v0.1.6-alpha.161/VERSION +1 -0
  8. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/asset/plugin/README.md +1 -0
  9. package/framework/v0.1.6-alpha.161/core/asset/plugin/dist/vendor/gina/css/gina.min.css.br +0 -0
  10. package/framework/v0.1.6-alpha.161/core/asset/plugin/dist/vendor/gina/css/gina.min.css.gz +0 -0
  11. package/framework/v0.1.6-alpha.161/core/asset/plugin/dist/vendor/gina/css/gina.min.css.map +1 -0
  12. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/asset/plugin/dist/vendor/gina/html/toolbar.html +1 -1
  13. package/framework/v0.1.6-alpha.161/core/asset/plugin/dist/vendor/gina/html/toolbar.html.br +0 -0
  14. package/framework/v0.1.6-alpha.161/core/asset/plugin/dist/vendor/gina/html/toolbar.html.gz +0 -0
  15. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/asset/plugin/dist/vendor/gina/js/gina.js +6444 -5613
  16. package/framework/v0.1.6-alpha.161/core/asset/plugin/dist/vendor/gina/js/gina.min.js +790 -0
  17. package/framework/v0.1.6-alpha.161/core/asset/plugin/dist/vendor/gina/js/gina.min.js.br +0 -0
  18. package/framework/v0.1.6-alpha.161/core/asset/plugin/dist/vendor/gina/js/gina.min.js.gz +0 -0
  19. package/framework/v0.1.6-alpha.161/core/asset/plugin/dist/vendor/gina/js/gina.min.js.map +8 -0
  20. package/framework/v0.1.6-alpha.161/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js +9 -0
  21. package/framework/v0.1.6-alpha.161/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js.br +0 -0
  22. package/framework/v0.1.6-alpha.161/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js.gz +0 -0
  23. package/framework/v0.1.6-alpha.161/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js.map +8 -0
  24. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/config.js +149 -57
  25. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/connectors/couchbase/index.js +108 -26
  26. package/framework/{v0.1.6-alpha.16/core/connectors/couchbase/lib/connector.v4.js → v0.1.6-alpha.161/core/connectors/couchbase/lib/connector.v3.js} +170 -69
  27. package/framework/v0.1.6-alpha.161/core/connectors/couchbase/lib/connector.v4.js +470 -0
  28. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/connectors/couchbase/lib/session-store.v4.js +5 -2
  29. package/framework/v0.1.6-alpha.161/core/content.encoding +9 -0
  30. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/controller/controller.js +847 -1274
  31. package/framework/v0.1.6-alpha.161/core/controller/controller.render-json.js +262 -0
  32. package/framework/v0.1.6-alpha.161/core/controller/controller.render-swig.js +1080 -0
  33. package/framework/v0.1.6-alpha.161/core/controller/controller.render-v1.js +911 -0
  34. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/controller/index.js +2 -2
  35. package/framework/v0.1.6-alpha.161/core/deps/busboy-1.6.0/.github/workflows/ci.yml +24 -0
  36. package/framework/v0.1.6-alpha.161/core/deps/busboy-1.6.0/.github/workflows/lint.yml +23 -0
  37. package/framework/v0.1.6-alpha.161/core/deps/busboy-1.6.0/README.md +191 -0
  38. package/framework/v0.1.6-alpha.161/core/deps/busboy-1.6.0/bench/bench-multipart-fields-100mb-big.js +149 -0
  39. package/framework/v0.1.6-alpha.161/core/deps/busboy-1.6.0/bench/bench-multipart-fields-100mb-small.js +143 -0
  40. package/framework/v0.1.6-alpha.161/core/deps/busboy-1.6.0/bench/bench-multipart-files-100mb-big.js +154 -0
  41. package/framework/v0.1.6-alpha.161/core/deps/busboy-1.6.0/bench/bench-multipart-files-100mb-small.js +148 -0
  42. package/framework/v0.1.6-alpha.161/core/deps/busboy-1.6.0/bench/bench-urlencoded-fields-100pairs-small.js +101 -0
  43. package/framework/v0.1.6-alpha.161/core/deps/busboy-1.6.0/bench/bench-urlencoded-fields-900pairs-small-alt.js +84 -0
  44. package/framework/v0.1.6-alpha.161/core/deps/busboy-1.6.0/lib/index.js +57 -0
  45. package/framework/v0.1.6-alpha.161/core/deps/busboy-1.6.0/lib/types/multipart.js +680 -0
  46. package/framework/v0.1.6-alpha.161/core/deps/busboy-1.6.0/lib/types/urlencoded.js +350 -0
  47. package/framework/v0.1.6-alpha.161/core/deps/busboy-1.6.0/lib/utils.js +596 -0
  48. package/framework/v0.1.6-alpha.161/core/deps/busboy-1.6.0/package.json +22 -0
  49. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/.travis.yml +4 -0
  50. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/LICENSE +21 -0
  51. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/example/bool.js +10 -0
  52. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/example/boolean_double.js +7 -0
  53. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/example/boolean_single.js +7 -0
  54. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/example/default_hash.js +8 -0
  55. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/example/default_singles.js +7 -0
  56. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/example/divide.js +8 -0
  57. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/example/line_count.js +20 -0
  58. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/example/line_count_options.js +29 -0
  59. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/example/line_count_wrap.js +29 -0
  60. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/example/nonopt.js +4 -0
  61. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/example/reflect.js +2 -0
  62. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/example/short.js +3 -0
  63. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/example/string.js +11 -0
  64. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/example/usage-options.js +19 -0
  65. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/example/xup.js +10 -0
  66. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/index.js +343 -0
  67. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/package.json +31 -0
  68. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/package.json.dist +39 -0
  69. package/framework/v0.1.6-alpha.161/core/deps/optimist-0.6.1/readme.markdown +513 -0
  70. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/HISTORY.md +498 -0
  71. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/LICENSE +7 -0
  72. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/README.md +88 -0
  73. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/bin/swig.js +161 -0
  74. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/bin/swig.js.dist +161 -0
  75. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/dist/swig.min.js +7 -0
  76. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/dist/swig.min.js.map +8 -0
  77. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/index.js +1 -0
  78. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/dateformatter.js +198 -0
  79. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/filters.js +630 -0
  80. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/lexer.js +306 -0
  81. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/loaders/filesystem.js +59 -0
  82. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/loaders/index.js +53 -0
  83. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/loaders/memory.js +63 -0
  84. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/parser.js +744 -0
  85. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/swig.js +740 -0
  86. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/tags/autoescape.js +37 -0
  87. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/tags/block.js +25 -0
  88. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/tags/else.js +25 -0
  89. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/tags/elseif.js +28 -0
  90. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/tags/extends.js +19 -0
  91. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/tags/filter.js +68 -0
  92. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/tags/for.js +130 -0
  93. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/tags/if.js +86 -0
  94. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/tags/import.js +91 -0
  95. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/tags/include.js +100 -0
  96. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/tags/index.js +16 -0
  97. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/tags/macro.js +79 -0
  98. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/tags/parent.js +51 -0
  99. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/tags/raw.js +23 -0
  100. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/tags/set.js +109 -0
  101. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/tags/spaceless.js +42 -0
  102. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/lib/utils.js +184 -0
  103. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/package.json +57 -0
  104. package/framework/v0.1.6-alpha.161/core/deps/swig-1.4.2/package.json.dist +61 -0
  105. package/framework/v0.1.6-alpha.161/core/deps/swig-client/swig.js +5031 -0
  106. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/dev/index.js +1 -1
  107. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/dev/lib/factory.js +1 -1
  108. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/gna.js +123 -23
  109. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/locales/index.js +3 -3
  110. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/locales/src/make.js +1 -1
  111. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/mime.types +1 -0
  112. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/model/entity.js +5 -5
  113. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/model/index.js +30 -26
  114. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/model/template/entityFactory.js +1 -1
  115. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/model/template/index.js +1 -1
  116. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/plugins/index.js +3 -3
  117. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/plugins/lib/file/package.json +2 -2
  118. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/plugins/lib/intl/package.json +2 -2
  119. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/plugins/lib/storage/package.json +2 -2
  120. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/plugins/lib/validator/package.json +2 -2
  121. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/plugins/lib/validator/src/form-validator.js +39 -27
  122. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/plugins/lib/validator/src/main.js +499 -120
  123. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/router.js +100 -49
  124. package/framework/v0.1.6-alpha.161/core/server.isaac.js +790 -0
  125. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/server.js +437 -160
  126. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/status.codes +1 -11
  127. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle/controllers/setup.js +2 -2
  128. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/command/gina.tpl +1 -1
  129. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/conf/env.json +28 -2
  130. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/conf/settings.json +4 -1
  131. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/conf/templates.json +4 -2
  132. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/console.js +1 -1
  133. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/context.js +30 -13
  134. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/data/package.json +2 -2
  135. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/data/src/main.js +1 -1
  136. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/dateFormat.js +1 -1
  137. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/index.js +1 -1
  138. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/json/package.json +2 -2
  139. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/json/src/main.js +7 -4
  140. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/path.js +32 -16
  141. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/plugins/package.json +2 -2
  142. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/plugins/src/api-error.js +2 -2
  143. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/plugins/src/main.js +1 -1
  144. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/prototypes.js +8 -1
  145. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/task.js +2 -2
  146. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/text.js +1 -1
  147. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/archiver/package.json +2 -2
  148. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/archiver/src/main.js +11 -11
  149. package/framework/v0.1.6-alpha.161/lib/cache/README.md +19 -0
  150. package/framework/v0.1.6-alpha.161/lib/cache/package.json +20 -0
  151. package/framework/v0.1.6-alpha.161/lib/cache/src/main.js +239 -0
  152. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/bundle/add.js +2 -1
  153. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/bundle/restart.js +2 -2
  154. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/bundle/start.js +26 -11
  155. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/env/get.js +1 -1
  156. package/framework/v0.1.6-alpha.161/lib/cmd/env/help.js +30 -0
  157. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/env/set.js +21 -0
  158. package/framework/v0.1.6-alpha.161/lib/cmd/framework/arguments.json +7 -0
  159. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/framework/build.js +1 -1
  160. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/framework/dot.js +21 -0
  161. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/framework/init.js +21 -3
  162. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/framework/link-node-modules.js +2 -3
  163. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/framework/link.js +3 -2
  164. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/framework/restart.js +3 -3
  165. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/framework/start.js +1 -1
  166. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/framework/tail.js +29 -12
  167. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/framework/version.js +15 -1
  168. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/helper.js +44 -15
  169. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/index.js +1 -1
  170. package/framework/v0.1.6-alpha.161/lib/cmd/minion/help.txt +18 -0
  171. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/port/reset.js +1 -1
  172. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/project/add.js +7 -2
  173. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/project/arguments.json +1 -0
  174. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/project/build.js +32 -7
  175. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/project/help.txt +4 -0
  176. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/project/list.js +1 -1
  177. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/protocol/list.js +71 -50
  178. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/collection/package.json +2 -2
  179. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/collection/src/main.js +62 -23
  180. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/config.js +1 -1
  181. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cron/package.json +2 -2
  182. package/framework/v0.1.6-alpha.161/lib/domain/dist/2025-03-14_13-41-20_UTC.dat +15754 -0
  183. package/framework/v0.1.6-alpha.161/lib/domain/dist/public_suffix_list.dat +15754 -0
  184. package/framework/v0.1.6-alpha.161/lib/domain/dist/public_suffix_list.dat.br +0 -0
  185. package/framework/v0.1.6-alpha.161/lib/domain/dist/public_suffix_list.dat.gz +0 -0
  186. package/framework/v0.1.6-alpha.161/lib/domain/exemples/backend.js +12 -0
  187. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/domain/package.json +2 -2
  188. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/domain/src/main.js +75 -13
  189. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/generator/index.js +1 -1
  190. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/index.js +3 -2
  191. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161/lib/inherits}/LICENSE +1 -1
  192. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/inherits/package.json +2 -2
  193. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/inherits/src/main.js +1 -1
  194. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/logger/package.json +2 -2
  195. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/logger/src/containers/file/index.js +2 -0
  196. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/logger/src/containers/mq/listener.js +10 -2
  197. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/logger/src/helper.js +1 -1
  198. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/logger/src/main.js +1 -1
  199. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/math/index.js +1 -1
  200. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/merge/package.json +2 -2
  201. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/model.js +3 -3
  202. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/proc.js +10 -2
  203. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/routing/package.json +2 -2
  204. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/routing/src/main.js +204 -35
  205. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/session-store.js +3 -3
  206. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/shell.js +7 -6
  207. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/swig-filters/package.json +2 -2
  208. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/swig-filters/src/main.js +98 -92
  209. package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/validator.js +2 -2
  210. package/framework/v0.1.6-alpha.161/package.json +11 -0
  211. package/package.json +3 -3
  212. package/resources/package.json.template +1 -1
  213. package/script/post_install.js +4 -4
  214. package/script/pre_install.js +3 -3
  215. package/utils/helper.js +38 -14
  216. package/framework/v0.1.6-alpha.16/VERSION +0 -1
  217. package/framework/v0.1.6-alpha.16/core/asset/plugin/dist/vendor/gina/css/gina.min.css.map +0 -1
  218. package/framework/v0.1.6-alpha.16/core/asset/plugin/dist/vendor/gina/js/gina.min.js +0 -766
  219. package/framework/v0.1.6-alpha.16/core/asset/plugin/dist/vendor/gina/js/gina.min.js.map +0 -8
  220. package/framework/v0.1.6-alpha.16/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js +0 -7
  221. package/framework/v0.1.6-alpha.16/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js.map +0 -8
  222. package/framework/v0.1.6-alpha.16/core/connectors/couchbase/lib/connector.v3.js +0 -432
  223. package/framework/v0.1.6-alpha.16/core/deps/busboy/.travis.yml +0 -17
  224. package/framework/v0.1.6-alpha.16/core/deps/busboy/README.md +0 -225
  225. package/framework/v0.1.6-alpha.16/core/deps/busboy/deps/encoding/encoding-indexes.js +0 -73
  226. package/framework/v0.1.6-alpha.16/core/deps/busboy/deps/encoding/encoding.js +0 -2391
  227. package/framework/v0.1.6-alpha.16/core/deps/busboy/lib/main.js +0 -89
  228. package/framework/v0.1.6-alpha.16/core/deps/busboy/lib/types/multipart.js +0 -328
  229. package/framework/v0.1.6-alpha.16/core/deps/busboy/lib/types/urlencoded.js +0 -214
  230. package/framework/v0.1.6-alpha.16/core/deps/busboy/lib/utils.js +0 -191
  231. package/framework/v0.1.6-alpha.16/core/deps/busboy/package.json +0 -69
  232. package/framework/v0.1.6-alpha.16/core/server.isaac.js +0 -480
  233. package/framework/v0.1.6-alpha.16/lib/domain/dist/public_suffix_list.dat +0 -14186
  234. package/framework/v0.1.6-alpha.16/package.json +0 -14
  235. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/AUTHORS +0 -0
  236. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/asset/html/nolayout.html +0 -0
  237. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/asset/html/static.html +0 -0
  238. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/asset/img/android-chrome-192x192.png +0 -0
  239. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/asset/img/android-chrome-512x512.png +0 -0
  240. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/asset/img/apple-touch-icon.png +0 -0
  241. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/asset/img/favicon-16x16.png +0 -0
  242. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/asset/img/favicon-32x32.png +0 -0
  243. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/asset/img/favicon.ico +0 -0
  244. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/asset/plugin/dist/vendor/gina/css/gina.min.css +0 -0
  245. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/asset/plugin/uuid.json +0 -0
  246. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/connectors/couchbase/lib/connector.js +0 -0
  247. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/connectors/couchbase/lib/connector.v2.js +0 -0
  248. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/connectors/couchbase/lib/n1ql.js +0 -0
  249. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/connectors/couchbase/lib/session-store.js +0 -0
  250. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/connectors/couchbase/lib/session-store.v2.js +0 -0
  251. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/connectors/couchbase/lib/session-store.v3.js +0 -0
  252. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/controller/controller.framework.js +0 -0
  253. /package/framework/{v0.1.6-alpha.16/core/deps/busboy → v0.1.6-alpha.161/core/deps/busboy-1.6.0}/LICENSE +0 -0
  254. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/deps/swig-client/swig-2.0.0.min.js +0 -0
  255. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/dev/lib/class.js +0 -0
  256. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/dev/lib/tools.js +0 -0
  257. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/locales/README.md +0 -0
  258. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/locales/currency.json +0 -0
  259. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/locales/dist/language/en.json +0 -0
  260. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/locales/dist/language/fr.json +0 -0
  261. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/locales/dist/region/en.json +0 -0
  262. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/locales/dist/region/fr.json +0 -0
  263. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/locales/src/resources/currency.csv +0 -0
  264. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/locales/src/resources/region.csv +0 -0
  265. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/locales/src/resources/region.mapping.json +0 -0
  266. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/plugins/README.md +0 -0
  267. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/plugins/lib/file/README.md +0 -0
  268. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/plugins/lib/file/build.json +0 -0
  269. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/plugins/lib/intl/README.md +0 -0
  270. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/plugins/lib/intl/build.json +0 -0
  271. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/plugins/lib/intl/src/main.js +0 -0
  272. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/plugins/lib/storage/README.md +0 -0
  273. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/plugins/lib/storage/build.json +0 -0
  274. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/plugins/lib/storage/src/main.js +0 -0
  275. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/plugins/lib/validator/README.md +0 -0
  276. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/plugins/lib/validator/build.json +0 -0
  277. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/server.express.js +0 -0
  278. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/_gitignore +0 -0
  279. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle/config/app.json +0 -0
  280. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle/config/routing.json +0 -0
  281. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle/config/settings.json +0 -0
  282. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle/config/settings.server.json +0 -0
  283. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle/config/templates.json +0 -0
  284. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle/controllers/controller.content.js +0 -0
  285. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle/controllers/controller.js +0 -0
  286. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle/index.js +0 -0
  287. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle_namespace/controllers/controller.js +0 -0
  288. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle_public/css/default.css +0 -0
  289. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle_public/css/vendor/readme.md +0 -0
  290. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle_public/favicon.ico +0 -0
  291. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle_public/js/vendor/readme.md +0 -0
  292. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle_public/readme.md +0 -0
  293. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle_templates/handlers/main.js +0 -0
  294. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle_templates/html/content/homepage.html +0 -0
  295. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle_templates/html/includes/error-msg-noscript.html +0 -0
  296. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle_templates/html/includes/error-msg-outdated-browser.html +0 -0
  297. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/boilerplate/bundle_templates/html/layouts/main.html +0 -0
  298. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/command/gina.bat.tpl +0 -0
  299. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/conf/manifest.json +0 -0
  300. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/conf/package.json +0 -0
  301. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/conf/statics.json +0 -0
  302. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/error/client/json/401.json +0 -0
  303. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/error/client/json/403.json +0 -0
  304. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/error/client/json/404.json +0 -0
  305. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/error/server/html/50x.html +0 -0
  306. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/error/server/json/500.json +0 -0
  307. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/error/server/json/503.json +0 -0
  308. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/core/template/extensions/logger/config.json +0 -0
  309. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/data/LICENSE +0 -0
  310. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/data/README.md +0 -0
  311. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/json/LICENSE +0 -0
  312. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/json/README.md +0 -0
  313. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/helpers/plugins/README.md +0 -0
  314. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/archiver/README.md +0 -0
  315. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/archiver/build.json +0 -0
  316. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/archiver/src/dep/jszip.min.js +0 -0
  317. /package/framework/{v0.1.6-alpha.16/lib/collection → v0.1.6-alpha.161/lib/cache}/build.json +0 -0
  318. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/aliases.json +0 -0
  319. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/bundle/arguments.json +0 -0
  320. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/bundle/copy.js +0 -0
  321. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/bundle/cp.js +0 -0
  322. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/bundle/help.js +0 -0
  323. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/bundle/help.txt +0 -0
  324. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/bundle/list.js +0 -0
  325. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/bundle/remove.js +0 -0
  326. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/bundle/rename.js +0 -0
  327. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/bundle/rm.js +0 -0
  328. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/bundle/status.js +0 -0
  329. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/bundle/stop.js +0 -0
  330. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/env/add.js +0 -0
  331. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/env/help.txt +0 -0
  332. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/env/link-dev.js +0 -0
  333. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/env/list.js +0 -0
  334. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/env/remove.js +0 -0
  335. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/env/rm.js +0 -0
  336. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/env/unset.js +0 -0
  337. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/env/use.js +0 -0
  338. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/framework/get.js +0 -0
  339. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/framework/help.js +0 -0
  340. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/framework/help.txt +0 -0
  341. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/framework/msg.json +0 -0
  342. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/framework/open.js +0 -0
  343. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/framework/set.js +0 -0
  344. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/framework/status.js +0 -0
  345. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/framework/stop.js +0 -0
  346. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/framework/update.js +0 -0
  347. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/gina-dev.1.md +0 -0
  348. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/gina-framework.1.md +0 -0
  349. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/gina.1.md +0 -0
  350. /package/framework/{v0.1.6-alpha.16/lib/cmd/env → v0.1.6-alpha.161/lib/cmd/minion}/help.js +0 -0
  351. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/msg.json +0 -0
  352. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/port/help.js +0 -0
  353. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/port/help.txt +0 -0
  354. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/port/inc/scan.js +0 -0
  355. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/port/list.js +0 -0
  356. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/port/set.js +0 -0
  357. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/project/help.js +0 -0
  358. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/project/import.js +0 -0
  359. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/project/move.js +0 -0
  360. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/project/remove.js +0 -0
  361. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/project/rename.js +0 -0
  362. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/project/restart.js +0 -0
  363. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/project/rm.js +0 -0
  364. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/project/start.js +0 -0
  365. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/project/status.js +0 -0
  366. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/project/stop.js +0 -0
  367. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/protocol/help.js +0 -0
  368. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/protocol/help.txt +0 -0
  369. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/protocol/set.js +0 -0
  370. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/scope/add.js +0 -0
  371. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/scope/help.js +0 -0
  372. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/scope/help.txt +0 -0
  373. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/scope/link-local.js +0 -0
  374. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/scope/link-production.js +0 -0
  375. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/scope/list.js +0 -0
  376. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/scope/remove.js +0 -0
  377. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/scope/rm.js +0 -0
  378. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/scope/use.js +0 -0
  379. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cmd/view/add.js +0 -0
  380. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/collection/README.md +0 -0
  381. /package/framework/{v0.1.6-alpha.16/lib/routing → v0.1.6-alpha.161/lib/collection}/build.json +0 -0
  382. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cron/README.md +0 -0
  383. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/cron/src/main.js +0 -0
  384. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/domain/LICENSE +0 -0
  385. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/domain/README.md +0 -0
  386. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/domain/exemples/frontend.html +0 -0
  387. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/inherits/README.md +0 -0
  388. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/inherits/example/inheriting_eventemitter.js +0 -0
  389. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/inherits/example/protected_inheritance.js +0 -0
  390. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/inherits/example/simple_inheritance.js +0 -0
  391. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/inherits/example/super_attribute_overridden_by_child_on_init.js +0 -0
  392. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/logger/README.md +0 -0
  393. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/logger/src/containers/default/index.js +0 -0
  394. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/logger/src/containers/file/lib/logrotator/README.md +0 -0
  395. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/logger/src/containers/file/lib/logrotator/index.js +0 -0
  396. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/logger/src/containers/mq/index.js +0 -0
  397. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/logger/src/containers/mq/speaker.js +0 -0
  398. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/merge/README.md +0 -0
  399. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/merge/example/merge.js +0 -0
  400. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/merge/example/merge_2_literal objects.js +0 -0
  401. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/merge/example/merge_and_preserve_first.js +0 -0
  402. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/merge/src/main.js +0 -0
  403. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/routing/README.md +0 -0
  404. /package/framework/{v0.1.6-alpha.16/lib/domain/exemples/backend.js → v0.1.6-alpha.161/lib/routing/build.json} +0 -0
  405. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/swig-filters/README.md +0 -0
  406. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/url/README.md +0 -0
  407. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/url/index.js +0 -0
  408. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/url/mocks.json +0 -0
  409. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/lib/url/routing.json +0 -0
  410. /package/framework/{v0.1.6-alpha.16 → v0.1.6-alpha.161}/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-2023 Rhinostone <contact@gina.io>
4
+ * Copyright (c) 2009-2026 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
- //var dns = require('dns');
19
- // var tls = require('tls');
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 swig = require('swig');
29
- // Swig 2
30
- // var swig = require('./../deps/swig-client/swig-2.0.0.min.js');
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
- } else {
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 Fix for none-developpement environnements (without cache)
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.substr(0, str.length-1), req.params[value.substr(1)]);
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.substr(0, str.length-1), value);
243
+ set(str.substring(0, str.length-1), value);
247
244
  } else {
248
- set(str.substr(0, str.length-1), value)
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" : process.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', self.isCacheless());
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
- var routing = local.options.conf.routing = ctx.config.envConf.routing; // all routes
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
- set('page.environment.hostname', ctx.config.envConf[options.conf.bundle][process.env.NODE_ENV].hostname);
358
- set('page.environment.rootDomain', ctx.config.envConf[options.conf.bundle][process.env.NODE_ENV].rootDomain);
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);
@@ -376,12 +499,29 @@ function SuperController(options) {
376
499
  set('page.view.namespace', namespace); // by default
377
500
  set('page.view.url', req.url);
378
501
  if ( local.options.template ) {
379
- set('page.view.layout', local.options.template.layout.replace(new RegExp(local.options.template.templates+'/'), ''));
502
+ set('page.view.layout', local.options.template.layout.replace(new RegExp(local.options.template.templates+'/'), '').split(/\//g).slice(1).join('/'));
380
503
  set('page.view.html.properties.mode.javascriptsDeferEnabled', local.options.template.javascriptsDeferEnabled);
381
504
  set('page.view.html.properties.mode.routeNameAsFilenameEnabled', local.options.template.routeNameAsFilenameEnabled);
382
505
  }
383
506
 
384
507
 
508
+ if ( /^true$/i.test(self.serverInstance._cacheIsEnabled) ) {
509
+ set('page.view.cacheIsEnabled', self.serverInstance._cacheIsEnabled);
510
+ set('page.view.cacheKey', "static:"+ local.req.url);
511
+ // Some routes might not have caching strategy
512
+ if ( typeof(local.req.routing.cache) != 'undefined' && local.req.routing.cache != null ) {
513
+ var cachingOption = ( typeof(local.req.routing.cache) == 'string' ) ? { type: local.req.routing.cache } : JSON.clone(local.req.routing.cache);
514
+ if ( typeof(cachingOption.ttl) == 'undefined' ) {
515
+ cachingOption.ttl = local.options.conf.server.cache.ttl
516
+ }
517
+ set('page.view.cacheType', cachingOption.type);
518
+ set('page.view.cacheTTL', cachingOption.ttl);
519
+ } else {
520
+ set('page.view.cacheType', 'Not configured for this route');
521
+ }
522
+ }
523
+
524
+
385
525
  var parameters = JSON.clone(req.getParams());
386
526
  parameters = merge(parameters, options.conf.content.routing[rule].param);
387
527
  // excluding default page properties
@@ -426,7 +566,7 @@ function SuperController(options) {
426
566
  // user locale
427
567
  options.conf.locale = new Collection(userLocales).findOne({ short: userCountryCode }) || {};
428
568
 
429
- //set('page.date.now', new Date().format("isoDateTime"));
569
+ // current date
430
570
  if ( typeof(options.conf.locale) == 'undefined' || !options.conf.locale ) {
431
571
  options.conf.locale = {}
432
572
  }
@@ -437,21 +577,16 @@ function SuperController(options) {
437
577
  set('page.view.lang', userCulture);
438
578
  }
439
579
 
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
580
 
446
581
  //TODO - detect when to use swig
447
582
  var dir = null;
448
583
  if (local.options.template || self.templates) {
449
- dir = local.options.template.templates || self.templates;
584
+ dir = local.options.template.html || self.templates;
450
585
 
451
586
  var swigOptions = {
452
587
  autoescape : ( typeof(local.options.autoescape) != 'undefined') ? local.options.autoescape : false,
453
588
  // `memory` is no working yet ... advanced rendering setup required
454
- // cache : (local.options.cacheless) ? false : 'memory'
589
+ // cache : (local.options.isCacheless) ? false : 'memory'
455
590
  cache : false
456
591
  };
457
592
  if (dir) {
@@ -470,6 +605,7 @@ function SuperController(options) {
470
605
  swig.setDefaultTZOffset(defaultTZOffset);
471
606
  defaultTZOffset = null;
472
607
 
608
+
473
609
  self.engine = swig;
474
610
 
475
611
  dir = null;
@@ -480,1256 +616,410 @@ function SuperController(options) {
480
616
  freeMemory([action, rule, ext, isWithoutLayout, namespace, ctx, version, routing, reverseRouting, forms, parameters, acceptLanguage, userCulture, userCultureCode, userLangCode, userCountryCode, locales, userLocales], false);
481
617
  }
482
618
 
483
- this.renderWithoutLayout = function (data, displayToolbar) {
619
+ var parseDataObject = function(o, obj, override) {
484
620
 
485
- // preventing multiple call of self.renderWithoutLayout() when controller is rendering from another required controller
486
- if (local.options.renderingStack.length > 1) {
487
- return false;
621
+ for (let i in o) {
622
+ if ( o[i] !== null && typeof(o[i]) == 'object' || override && o[i] !== null && typeof(o[i]) == 'object' ) {
623
+ parseDataObject(o[i], obj);
624
+ } else if (o[i] == '_content_'){
625
+ o[i] = obj
626
+ }
488
627
  }
489
628
 
490
- local.options.isWithoutLayout = true;
491
-
492
- self.render(data, displayToolbar);
629
+ return o
493
630
  }
494
631
 
495
632
  /**
496
- * Render HTML templates : Swig is the default template engine
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`
633
+ * Set data
506
634
  *
635
+ * @param {string} nave - variable name to set
636
+ * @param {string|object} value - value to set
637
+ * @param {boolean} [override]
507
638
  *
508
- * @param {object} userData
509
- * @param {boolean} [displayToolbar]
510
- * @param {object} [errOptions]
511
639
  * @returns {void}
512
640
  * */
513
- this.render = async function(userData, displayToolbar, errOptions) {
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
- }
641
+ var set = function(name, value, override) {
528
642
 
643
+ var override = ( typeof(override) != 'undefined' ) ? override : false;
529
644
 
530
- var data = null
531
- , layout = null
532
- , template = null
533
- , file = null
534
- , path = null
535
- , plugin = null
536
- // By default
537
- , isWithoutLayout = (localOptions.isWithoutLayout) ? true : false
538
- ;
645
+ if ( typeof(name) == 'string' && /\./.test(name) ) {
646
+ var keys = name.split(/\./g)
647
+ , newObj = {}
648
+ , str = '{'
649
+ , _count = 0;
539
650
 
540
- try {
541
- data = getData();
542
- // Display session
543
- if (
544
- typeof(local.req.session) != 'undefined'
545
- ) {
546
- if ( typeof(data.page.data) == 'undefined' ) {
547
- data.page.data = {};
548
- }
651
+ for (let k = 0, len = keys.length; k<len; ++k) {
652
+ str += "\""+ keys.splice(0,1)[0] + "\":{";
549
653
 
550
- if ( typeof(local.req.session.cookie._expires) != 'undefined' ) {
551
- var dateEnd = local.req.session.cookie._expires;
552
- var dateStart = ( typeof(local.req.session.lastModified) != 'undefined')
553
- ? new Date(local.req.session.lastModified)
554
- : new Date()
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
- };
654
+ ++_count;
655
+ if (k == len-1) {
656
+ str = str.substring(0, str.length-1);
657
+ str += "\"_content_\"";
658
+ for (let c = 0; c<_count; ++c) {
659
+ str += "}"
563
660
  }
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
661
  }
573
662
  }
574
663
 
575
- // in case `local.req.routing.param.file` has been changed on the fly
576
- if (
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, '');
664
+ newObj = parseDataObject(JSON.parse(str), value, override);
665
+ local.userData = merge(local.userData, newObj);
615
666
 
616
- path = path.replace(re, '');
617
- data.page.view.file = data.page.view.file.replace(re, '');
667
+ freeMemory([name, value, keys, newObj, str, _count], false);
618
668
 
619
- } else {
620
- data.page.view.path = path.replace('/'+ data.page.view.file, '');
621
- }
622
- re = null;
623
- } else {
624
- path = (!isRenderingCustomError && !/^(\.|\/|\\)/.test(file))
625
- ? _(localOptions.template.html +'/'+ file)
626
- : file
627
- }
628
- }
669
+ } else if ( typeof(local.userData[name]) == 'undefined' ) {
670
+ local.userData[name] = value.replace(/\\/g, '');
671
+ freeMemory([name, value], false)
672
+ }
673
+ }
629
674
 
630
- if (data.page.view.ext && !new RegExp(data.page.view.ext+ '$').test(file) ) {
631
- path += data.page.view.ext
632
- }
675
+ /**
676
+ * Get data
677
+ *
678
+ * @param {String} variable Data name to set
679
+ * @returns {Object | String} data Data object or String
680
+ * */
681
+ var get = function(variable) {
682
+ return local.userData[variable]
683
+ }
633
684
 
634
- data.page.view.path = path;
635
- } catch (dataErr) {
636
- return self.throwError(dataErr);
685
+ /**
686
+ * Set resources
687
+ *
688
+ * @param {object} template - template configuration
689
+ * */
690
+ var setResources = function(viewConf) {
691
+ if (!viewConf) {
692
+ 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
693
  }
638
694
 
639
- // isWithoutLayout from content
640
- var pageContentObj = new _(data.page.view.path);
641
- var _templateContent = fs.readFileSync(path).toString() || null;
642
- var hasLayoutInPath = /\{\%(\s+extends|extends)/.test(_templateContent) || false;
643
- var layoutPath = null;
644
-
695
+ var authority = ( typeof(local.req.headers['x-forwarded-proto']) != 'undefined' ) ? local.req.headers['x-forwarded-proto'] : local.options.conf.server.scheme;
696
+ authority += '://'+ local.req.headers.host;
697
+ var useWebroot = false;
645
698
  if (
646
- !isWithoutLayout
647
- && !isRenderingCustomError
648
- && pageContentObj.existsSync()
649
- && !hasLayoutInPath
699
+ !/^\/$/.test(local.options.conf.server.webroot)
700
+ && local.options.conf.server.webroot.length > 0
701
+ // && local.options.conf.hostname.replace(/\:\d+$/, '') == authority
650
702
  ) {
651
- isWithoutLayout = true;
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;
703
+ useWebroot = true
672
704
  }
673
- hasLayoutInPath = null;
674
- _templateContent = null;
705
+ authority = null;
675
706
 
676
- localOptions.debugMode = ( typeof(displayToolbar) == 'undefined' ) ? undefined : ( (/true/i.test(displayToolbar)) ? true : false ); // only active for dev env
707
+ var reURL = new RegExp('^'+ local.options.conf.server.webroot);
677
708
 
678
- // specific override
679
- if (
680
- self.isCacheless()
681
- && typeof(local.req[ local.req.method.toLowerCase() ]) != 'undefined'
682
- && typeof(local.req[ local.req.method.toLowerCase() ].debug) != 'undefined'
683
- ) {
684
- if ( !/^(true|false)$/i.test(local.req[ local.req.method.toLowerCase() ].debug) ) {
685
- console.warn('Detected wrong value for `debug`: '+ local.req[ local.req.method.toLowerCase() ].debug);
686
- console.warn('Switching `debug` to `true` as `cacheless` mode is enabled');
687
- local.req[ local.req.method.toLowerCase() ].debug = true;
688
- }
689
- localOptions.debugMode = ( /^true$/i.test(local.req[ local.req.method.toLowerCase() ].debug) ) ? true : false;
690
- } else if (
691
- self.isCacheless()
692
- && hasViews()
693
- && !isWithoutLayout
694
- && localOptions.debugMode == undefined
695
- ) {
696
- localOptions.debugMode = true;
697
- } else if ( localOptions.debugMode == undefined ) {
698
- localOptions.debugMode = self.isCacheless()
709
+ var cssStr = ''
710
+ , jsStr = ''
711
+ ;
712
+ //Get css
713
+ if( viewConf.stylesheets ) {
714
+ // cssStr = getNodeRes('css', viewConf.stylesheets, useWebroot, reURL);
715
+ // Fixed on 2025-03-08: ordered by route, making sure that _common could all be loaded first
716
+ var cssColl = new Collection(viewConf.stylesheets).orderBy({route: 'asc'})
717
+ cssStr = getNodeRes('css', cssColl, useWebroot, reURL);
718
+ cssColl = null;
719
+ }
720
+ //Get js
721
+ if( viewConf.javascripts ) {
722
+ // jsStr = getNodeRes('js', viewConf.javascripts, useWebroot, reURL);
723
+ // Fixed on 2025-03-08: ordered by route, making sure that _common could all be loaded first
724
+ var jsColl = new Collection(viewConf.javascripts).orderBy({route: 'asc'})
725
+ jsStr = getNodeRes('js', jsColl, useWebroot, reURL);
726
+ jsColl = null;
699
727
  }
700
728
 
701
- try {
702
-
703
- if (!userData) {
704
- userData = { page: { view: {}}}
705
- } else if ( userData && !userData['page']) {
729
+ set('page.view.stylesheets', cssStr);
730
+ set('page.view.scripts', jsStr);
706
731
 
707
- if ( typeof(data['page']['data']) == 'undefined' )
708
- data['page']['data'] = userData;
709
- else
710
- data['page']['data'] = (isRenderingCustomError) ? userData : merge( userData, data['page']['data'] );
711
- } else {
712
- data = (isRenderingCustomError) ? userData : merge(userData, data)
713
- }
732
+ reURL = null;
733
+ cssStr = null;
734
+ jsStr = null;
735
+ }
714
736
 
715
- template = localOptions.rule.replace('\@'+ localOptions.bundle, '');
716
- var localTemplateConf = localOptions.template;
717
- if ( isWithoutLayout ) {
718
- localTemplateConf = JSON.clone(localOptions.template);
719
- localTemplateConf.javascripts = new Collection(localTemplateConf.javascripts).find({ isCommon: false}, { isCommon: true, name: 'gina' });
720
- localTemplateConf.stylesheets = new Collection(localTemplateConf.stylesheets).find({ isCommon: false}, { isCommon: true, name: 'gina' });
721
- }
722
- setResources(localTemplateConf);
723
- // localTemplateConf = null;
737
+ /**
738
+ * Get node resources
739
+ *
740
+ * @param {string} type
741
+ * @param {string} resStr
742
+ * @param {array} resArr
743
+ * @param {boolean} useWebroot
744
+ * @param {object} reURL - RegExp for webroot
745
+ *
746
+ * @returns {object} content
747
+ *
748
+ * @private
749
+ * */
750
+ var getNodeRes = function(type, resArr, useWebroot, reURL) {
724
751
 
725
- // Allowing file & ext override
726
- if (
727
- typeof(local.req.routing.param.file) != 'undefined'
728
- && data.page.view.file !== local.req.routing.param.file
729
- ) {
730
- data.page.view.file = localOptions.file = local.req.routing.param.file
731
- }
732
- if (
733
- typeof(local.req.routing.param.ext) != 'undefined'
734
- && data.page.view.ext !== local.req.routing.param.ext
735
- ) {
736
- data.page.view.ext = localOptions.template.ext = local.req.routing.param.ext
737
- }
752
+ var r = 0
753
+ , rLen = resArr.length
754
+ , obj = null
755
+ , str = ''
756
+ , isProxyHost = getContext('isProxyHost')
757
+ , requestHost = ( /http\/2/.test(local.options.conf.server.protocol) )
758
+ ? local.req.headers[':host']
759
+ : local.req.headers.host
760
+ , hostname = ( typeof(requestHost) != 'undefined' && local.options.conf.host != requestHost)
761
+ ? local.options.conf.server.scheme +'://'+ requestHost
762
+ : local.options.conf.hostname
763
+ , scheme = hostname.match(/^(https|http)/)[0]
764
+ ;
765
+ var requestPort = (local.req.headers.port||local.req.headers[':port']);
766
+ var hostPort = local.options.conf.hostname.match(/(\:d+\/|\:\d+)$/);
767
+ hostPort = (hostPort) ? ~~(hostPort[0].replace(/\:/g, '')) : local.options.conf.port[local.options.conf.server.protocol][local.options.conf.server.scheme];
768
+ // Linking bundle B from bundle A wihtout proxy
769
+ var isSpecialCase = (
770
+ getContext('bundle') != local.options.conf.bundle
771
+ && requestPort != hostPort
772
+ && local.req.headers[':host'] != process.gina.PROXY_HOST
773
+ ) ? true : false;
738
774
 
739
- // file = (isRenderingCustomError) ? localOptions.file : data.page.view.file;
775
+ if (isSpecialCase) {
776
+ hostname = local.options.conf.hostname
777
+ }
740
778
 
741
- // pre-compiling variables
742
- data = merge(data, getData()); // needed !!
743
779
 
744
- if (typeof(data.page.data) == 'undefined' ) {
745
- data.page.data = {}
746
- }
780
+ if (
781
+ isProxyHost
782
+ && !isSpecialCase
783
+ ) {
747
784
 
785
+ hostname = scheme + '://'+ (local.req.headers.host||local.req.headers[':host']||process.gina.PROXY_HOST);
748
786
 
749
787
  if (
750
- !local.options.isRenderingCustomError
751
- && typeof(data.page.data.status) != 'undefined'
752
- && !/^2/.test(data.page.data.status)
753
- && typeof(data.page.data.error) != 'undefined'
788
+ !/^(80|443)$/.test(requestPort)
789
+ && !new RegExp(requestPort+'$').test(hostname)
754
790
  ) {
755
- // var statusCode = localOptions.conf.server.coreConfiguration.statusCodes;
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);
791
+ hostname += ':'+ requestPort;
768
792
  }
793
+ }
769
794
 
770
- // // making path thru [namespace &] file
771
- // if ( typeof(localOptions.namespace) != 'undefined' && localOptions.namespace ) {
772
- // // excepted for custom paths
773
- // var fileNamingConvention = file.replace(localOptions.namespace+'-', '');
774
- // if ( !/^(\.|\/|\\)/.test(file) && file != fileNamingConvention ) {
775
- // var _ext = data.page.view.ext;
776
-
777
- // 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 +'`');
778
- // 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);
779
- // file = ''+ file.replace(localOptions.namespace+'-', '');
780
- // }
781
-
782
-
783
- // // means that rule name === namespace -> pointing to root namespace dir
784
- // if (!file || file === localOptions.namespace) {
785
- // file = 'index'
786
- // }
787
- // path = (isRenderingCustomError) ? _(file) : _(localOptions.template.html +'/'+ localOptions.namespace + '/' + file)
788
- // } else {
789
- // if ( localOptions.path && !/(\?|\#)/.test(localOptions.path) ) {
790
- // path = _(localOptions.path);
791
- // var re = new RegExp( data.page.view.ext+'$');
792
- // if ( data.page.view.ext && re.test(data.page.view.file) ) {
793
- // data.page.view.path = path.replace('/'+ data.page.view.file, '');
794
-
795
- // path = path.replace(re, '');
796
- // data.page.view.file = data.page.view.file.replace(re, '');
797
-
798
- // } else {
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
-
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
- // }
795
+ switch(type){
796
+ case 'css':
797
+ for (; r < rLen; ++r) {
798
+ obj = resArr[r];
799
+ if (useWebroot && !reURL.test(obj.url) ) {
800
+ obj.url = local.options.conf.server.webroot + obj.url.substring(1);
801
+ }
802
+ // HTTP2 Push via Link
803
+ if (
804
+ /http\/2/.test(local.options.conf.server.protocol)
805
+ && !self.isCacheless()
806
+ ) {
807
+ local.options.template.h2Links += '<'+ obj.url +'>; as=style; rel=preload,'
808
+ }
809
+ // TODO - add support for cdn
810
+ if (!/\:\/\//.test(obj.url) ) {
811
+ obj.url = hostname + obj.url;
812
+ }
812
813
 
813
- // data.page.view.path = path;
814
+ if (obj.media) {
815
+ str += '\n\t\t<link href="'+ obj.url +'" media="'+ obj.media +'" rel="'+ obj.rel +'" type="'+ obj.type +'">';
816
+ } else {
817
+ str += '\n\t\t<link href="'+ obj.url +'" rel="'+ obj.rel +'" type="'+ obj.type +'">';
818
+ }
819
+ }
820
+ break;
814
821
 
815
- var dic = {}, msg = '';
816
- for (let d in data.page) {
817
- dic['page.'+d] = data.page[d]
818
- }
822
+ case 'js':
823
+ var deferMode = (local.options.template.javascriptsDeferEnabled) ? ' defer' : '';
819
824
 
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
-
1141
- if (isWithoutLayout) {
1142
- delete data.page.view.scripts;
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';
825
+ for (; r < rLen; ++r) {
826
+ obj = resArr[r];
827
+ if (useWebroot && !reURL.test(obj.url) ) {
828
+ obj.url = local.options.conf.server.webroot + obj.url.substring(1);
1190
829
  }
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>');
830
+ // HTTP2 Push via Link
831
+ if (
832
+ /http\/2/.test(local.options.conf.server.protocol)
833
+ && !self.isCacheless()
834
+ ) {
835
+ local.options.template.h2Links += '<'+ obj.url +'>; as=script; rel=preload,'
1197
836
  }
1198
- // ginaLoader cannot be deferred
1199
- if ( !localOptions.template.javascriptsExcluded || localOptions.template.javascriptsExcluded != '**' ) {
1200
- layout = layout.replace(/\<\/head\>/i, '\t'+ localOptions.template.ginaLoader +'\n</head>');
837
+ // TODO - add support for cdn
838
+ if (!/\:\/\//.test(obj.url) ) {
839
+ obj.url = hostname + obj.url;
1201
840
  }
1202
- }
1203
- }
1204
-
1205
841
 
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
842
 
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];
843
+ if ( /\/jquery\.(.*)\.(min\.js|js)$/i.test(obj.url) ) {
844
+ 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) +' .');
1254
845
  }
1255
- }
1256
-
1257
- local.res.setHeader('content-type', localOptions.conf.server.coreConfiguration.mime['html'] + '; charset='+ localOptions.conf.encoding );
1258
-
1259
- try {
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
- }
1275
-
1276
-
1277
-
1278
- // Only available for http/2.0 for now
1279
- if ( !self.isXMLRequest() && /http\/2/.test(localOptions.conf.server.protocol) ) {
1280
- var assets = null;
1281
- try {
1282
- // TODO - button in toolbar to empty url assets cache
1283
- if ( /** self.isCacheless() ||*/ typeof(localOptions.template.assets) == 'undefined' || typeof(localOptions.template.assets[local.req.url]) == 'undefined' ) {
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
- }
1289
-
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
-
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;
846
+ // Allow jQuery & other external plugins to be loaded in the HEAD section before gina
847
+ if (
848
+ obj.isExternalPlugin
849
+ ) {
850
+ local.options.template.externalPlugins.splice(1, 0, '\n\t\t<script'+ deferMode +' type="'+ obj.type +'" src="'+ obj.url +'"></script>');
1304
851
  }
1305
- }
1306
-
1307
- // Last compilation before rendering
1308
- // Now we can use `data` instead of `swigData`
1309
- layout = swig.compile(layout, mapping)(data);
1310
-
1311
- if ( !headersSent() ) {
1312
- if ( local.options.isRenderingCustomError ) {
1313
- local.options.isRenderingCustomError = false;
852
+ else {
853
+ // normal case
854
+ str += '\n\t\t<script'+ deferMode +' type="'+ obj.type +'" src="'+ obj.url +'"></script>';
1314
855
  }
1315
-
1316
- local.res.end(layout);
1317
- layout = null;
1318
856
  }
1319
-
1320
- console.info(local.req.method +' ['+local.res.statusCode +'] '+ local.req.url);
1321
-
1322
- if ( typeof(local.next) != 'undefined' ) {
1323
- return local.next();
1324
- }
1325
- return;
1326
- }
1327
-
1328
-
1329
- if ( typeof(local.req.params.errorObject) != 'undefined' ) {
1330
- return self.throwError(local.req.params.errorObject);
1331
- }
1332
- local.res.end('Unexpected controller error while trying to render.');
1333
-
1334
- if (typeof(local.next) != 'undefined') {
1335
- return local.next();
1336
- }
1337
-
1338
- return;
1339
-
1340
- } catch (err) {
1341
- return self.throwError(local.res, 500, err);
857
+ break;
1342
858
  }
1343
- }
1344
-
1345
-
1346
- this.isXMLRequest = function() {
1347
- return local.options.isXMLRequest;
1348
- }
859
+ r = null;
860
+ rLen = null;
861
+ obj = null;
1349
862
 
1350
- this.isWithCredentials = function() {
1351
- return ( /true/.test(local.options.withCredentials) ) ? true : false;
1352
- }
1353
863
 
1354
- this.isPopinContext = function() {
1355
- return (
1356
- typeof(local.req.headers['x-gina-popin-id']) != 'undefined'
1357
- || typeof(local.req.headers['x-gina-popin-name']) != 'undefined'
1358
- ) ? true : false;
864
+ return str;
1359
865
  }
1360
866
 
1361
867
  /**
1362
- * Render JSON
1363
- *
1364
- * @param {object|string} jsonObj
1365
- * @param {object} [req]
1366
- * @param {object} [res]
1367
- *
1368
- * @callback {function} [next]
1369
- *
868
+ * TODO - SuperController.setMeta()
1370
869
  * */
1371
- this.renderJSON = function(jsonObj) {
1372
-
1373
- // preventing multiple call of self.renderJSON() when controller is rendering from another required controller
1374
- if (local.options.renderingStack.length > 1) {
1375
- return false
1376
- }
1377
- if ( self.isProcessingError ) {
1378
- return;
1379
- }
1380
-
1381
- var request = local.req;
1382
- var response = local.res;
1383
- var next = local.next || null;
1384
- // var stream = null;
1385
- // if ( /http\/2/.test(local.options.conf.server.protocol) ) {
1386
- // stream = response.stream;
1387
- // }
1388
-
1389
- // Added on 2023-06-12
1390
- if ( headersSent(response) ) {
1391
- freeMemory([jsonObj, request, response, next]);
1392
- return;
1393
- }
1394
-
1395
- if (!jsonObj) {
1396
- jsonObj = {}
1397
- }
1398
-
1399
- try {
1400
- // just in case
1401
- if ( typeof(jsonObj) == 'string') {
1402
- jsonObj = JSON.parse(jsonObj)
1403
- }
1404
- var data = JSON.stringify(jsonObj);
1405
-
1406
- // if( typeof(local.options) != "undefined" && typeof(local.options.charset) != "undefined" ){
1407
- // response.setHeader("charset", local.options.charset);
1408
- // }
1409
-
1410
-
1411
- //catching errors
1412
- if (
1413
- typeof(jsonObj.errno) != 'undefined' && response.statusCode == 200
1414
- ||
1415
- typeof(jsonObj.status) != 'undefined' && jsonObj.status != 200
1416
- && typeof(local.options.conf.server.coreConfiguration.statusCodes[jsonObj.status]) != 'undefined'
1417
- ) {
1418
-
1419
- try {
1420
- response.statusCode = jsonObj.status;
1421
- response.statusMessage = local.options.conf.server.coreConfiguration.statusCodes[jsonObj.status];
1422
- } catch (err){
1423
- response.statusCode = 500;
1424
- response.statusMessage = err.stack;
1425
- }
1426
- }
1427
-
1428
-
1429
- // Internet Explorer override
1430
- if ( /msie/i.test(request.headers['user-agent']) ) {
1431
- response.setHeader('content-type', 'text/plain' + '; charset='+ local.options.conf.encoding)
1432
- } else {
1433
- response.setHeader('content-type', local.options.conf.server.coreConfiguration.mime['json'] + '; charset='+ local.options.conf.encoding)
1434
- }
1435
-
1436
- // if ( !headersSent(response) ) {
1437
- console.info(request.method +' ['+ response.statusCode +'] '+ request.url);
1438
-
1439
-
1440
- if ( local.options.isXMLRequest && self.isWithCredentials() ) {
1441
-
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
-
1450
- // required to close connection
1451
- setTimeout(function () {
1452
- response.end();
1453
- try {
1454
- response.headersSent = true;
1455
- } catch(err) {
1456
- // Ignoring warning
1457
- //console.warn(err);
1458
- }
1459
-
1460
- if ( next ) {
1461
- next()
1462
- }
870
+ // this.setMeta = function(metaName, metacontent) {
871
+ //
872
+ // }
1463
873
 
1464
- freeMemory([jsonObj, data, request, response, next]);
1465
- }, 200);
1466
874
 
1467
- // force completion
1468
- return
1469
- }
1470
- // normal case
1471
- response.end(JSON.stringify(jsonObj));
1472
- if (!headersSent(response)) {
1473
- try {
1474
- response.headersSent = true;
1475
- } catch(err) {
1476
- // Ignoring warning
1477
- //console.warn(err);
1478
- }
1479
- }
1480
- if ( next ) {
1481
- return next()
1482
- }
1483
875
 
1484
- freeMemory([jsonObj, data, request, response, next]);
1485
-
1486
- return;
1487
- // }
1488
- } catch (err) {
1489
- return self.throwError(response, 500, err);
1490
- }
876
+ var isValidURL = function(url){
877
+ // var re = /(http|ftp|https|sftp):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&amp;:\/~+#-]*[\w@?^=%&amp;\/~+#-])?/;
878
+ return (/(http|ftp|https|sftp):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&amp;:\/~+#-]*[\w@?^=%&amp;\/~+#-])?/.test(url)) ? true : false;
1491
879
  }
1492
880
 
881
+ this.renderWithoutLayout = function (data, displayToolbar) {
1493
882
 
1494
- this.renderTEXT = function(content) {
1495
-
1496
- // preventing multiple call of self.renderTEXT() when controller is rendering from another required controller
883
+ // preventing multiple call of self.renderWithoutLayout() when controller is rendering from another required controller
1497
884
  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
-
1522
- // if (typeof(options) != "undefined" && typeof(options.charset) !="undefined") {
1523
- // response.setHeader("charset", options.charset);
1524
- // }
1525
- if ( !response.getHeaders()['content-type'] ) {
1526
- response.setHeader('content-type', 'text/plain' + '; charset='+ local.options.conf.encoding);
885
+ return false;
1527
886
  }
1528
887
 
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
- }
888
+ local.options.isWithoutLayout = true;
1538
889
 
1539
- freeMemory([jsonObj, data, request, response, next]);
1540
- }
890
+ self.render(data, displayToolbar);
1541
891
  }
1542
892
 
1543
- var parseDataObject = function(o, obj, override) {
1544
893
 
1545
- for (let i in o) {
1546
- if ( o[i] !== null && typeof(o[i]) == 'object' || override && o[i] !== null && typeof(o[i]) == 'object' ) {
1547
- parseDataObject(o[i], obj);
1548
- } else if (o[i] == '_content_'){
1549
- o[i] = obj
1550
- }
1551
- }
894
+ var getData = function() {
895
+ return refToObj( local.userData )
896
+ }
1552
897
 
1553
- return o
898
+ if (this.isCacheless() ) {
899
+ delete require.cache[require.resolve( _(__dirname + '/controller.render-v1', true))];
900
+ delete require.cache[require.resolve( _(__dirname + '/controller.render-swig', true))];
1554
901
  }
1555
902
 
1556
903
  /**
1557
- * Set data
904
+ * Render HTML templates : Swig is the default template engine
1558
905
  *
1559
- * @param {string} nave - variable name to set
1560
- * @param {string|object} value - value to set
1561
- * @param {boolean} [override]
906
+ * Extend default filters
907
+ * - length
1562
908
  *
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
- }
1585
- }
1586
- }
1587
-
1588
- newObj = parseDataObject(JSON.parse(str), value, override);
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
909
+ * Available filters:
910
+ * - getWebroot()
911
+ * - getUrl()
1601
912
  *
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
913
+ * N.B.: Filters can be extended through your `<project>/src/<bundle>/controllers/setup.js`
1611
914
  *
1612
- * @param {object} template - template configuration
915
+ *
916
+ * @param {object} userData
917
+ * @param {boolean} [displayToolbar]
918
+ * @param {object} [errOptions]
919
+ * @returns {void}
1613
920
  * */
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
- }
921
+ this.render = require( _(__dirname + '/controller.render-swig', true) )({
922
+ self : self,
923
+ local : local,
924
+ getData : getData,
925
+ hasViews : hasViews,
926
+ setResources: setResources,
927
+ swig : swig,
928
+ SwigFilters : SwigFilters,
929
+ headersSent : headersSent
930
+ }); //(userData, displayToolbar, errOptions)
1618
931
 
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
932
 
1627
- var reURL = new RegExp('^'+ local.options.conf.server.webroot);
1628
933
 
1629
- var cssStr = '', jsStr = '';
934
+ this.isXMLRequest = function() {
935
+ return local.options.isXMLRequest;
936
+ }
1630
937
 
1631
- //Get css
1632
- if( viewConf.stylesheets ) {
1633
- cssStr = getNodeRes('css', viewConf.stylesheets, useWebroot, reURL)
1634
- }
1635
- //Get js
1636
- if( viewConf.javascripts ) {
1637
- jsStr = getNodeRes('js', viewConf.javascripts, useWebroot, reURL)
1638
- }
938
+ this.isWithCredentials = function() {
939
+ return ( /true/.test(local.options.withCredentials) ) ? true : false;
940
+ }
1639
941
 
1640
- set('page.view.stylesheets', cssStr);
1641
- set('page.view.scripts', jsStr);
942
+ this.isPopinContext = function() {
943
+ return (
944
+ typeof(local.req.headers['x-gina-popin-id']) != 'undefined'
945
+ || typeof(local.req.headers['x-gina-popin-name']) != 'undefined'
946
+ ) ? true : false;
947
+ }
1642
948
 
1643
- reURL = null;
1644
- cssStr = null;
1645
- jsStr = null;
949
+ if (this.isCacheless() ) {
950
+ delete require.cache[require.resolve( _(__dirname + '/controller.render-json', true))];
1646
951
  }
1647
952
 
1648
953
  /**
1649
- * Get node resources
954
+ * Render JSON
1650
955
  *
1651
- * @param {string} type
1652
- * @param {string} resStr
1653
- * @param {array} resArr
1654
- * @param {object} resObj
956
+ * @param {object|string} jsonObj
957
+ * @param {object} [req]
958
+ * @param {object} [res]
1655
959
  *
1656
- * @returns {object} content
960
+ * @callback {function} [next]
1657
961
  *
1658
- * @private
1659
962
  * */
1660
- var getNodeRes = function(type, resArr, useWebroot, reURL) {
963
+ this.renderJSON = require( _(__dirname + '/controller.render-json', true) )({
964
+ self : self,
965
+ local : local,
966
+ headersSent : headersSent,
967
+ freeMemory : freeMemory
968
+ }); //(jsonObj)
1661
969
 
1662
- var r = 0
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
- }
1684
970
 
1685
- if (obj.media)
1686
- str += '\n\t\t<link href="'+ obj.url +'" media="'+ obj.media +'" rel="'+ obj.rel +'" type="'+ obj.type +'">';
1687
- else
1688
- str += '\n\t\t<link href="'+ obj.url +'" rel="'+ obj.rel +'" type="'+ obj.type +'">';
1689
- }
1690
- break;
1691
971
 
1692
- case 'js':
1693
- var deferMode = (local.options.template.javascriptsDeferEnabled) ? ' defer' : '';
972
+ this.renderTEXT = function(content) {
1694
973
 
1695
- for (; r < rLen; ++r) {
1696
- obj = resArr[r];
1697
- if (useWebroot && !reURL.test(obj.url) ) {
1698
- obj.url = local.options.conf.server.webroot + obj.url.substr(1);
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;
974
+ // preventing multiple call of self.renderTEXT() when controller is rendering from another required controller
975
+ if (local.options.renderingStack.length > 1) {
976
+ return false
977
+ }
978
+ if ( self.isProcessingError ) {
979
+ return;
1707
980
  }
1708
- r = null;
1709
- rLen = null;
1710
- obj = null;
1711
981
 
982
+ var request = local.req;
983
+ var response = local.res;
984
+ var next = local.next || null;
985
+ // var stream = null;
986
+ // if ( /http\/2/.test(local.options.conf.server.protocol) ) {
987
+ // stream = response.stream;
988
+ // }
1712
989
 
1713
- return str;
1714
- }
990
+ // Added on 2023-06-12
991
+ if ( headersSent(response) ) {
992
+ freeMemory([content, request, response, next]);
993
+ return;
994
+ }
1715
995
 
1716
- /**
1717
- * TODO - SuperController.setMeta()
1718
- * */
1719
- // this.setMeta = function(metaName, metacontent) {
1720
- //
1721
- // }
996
+ if ( typeof(content) != "string" ) {
997
+ content = content.toString();
998
+ }
1722
999
 
1723
- var getData = function() {
1724
- return refToObj( local.userData )
1725
- }
1000
+ // if (typeof(options) != "undefined" && typeof(options.charset) !="undefined") {
1001
+ // response.setHeader("charset", options.charset);
1002
+ // }
1003
+ if ( !response.getHeaders()['content-type'] ) {
1004
+ response.setHeader('content-type', 'text/plain' + '; charset='+ local.options.conf.encoding);
1005
+ }
1726
1006
 
1007
+ if ( !headersSent() ) {
1008
+ console.info(request.method +' ['+response.statusCode +'] '+ request.url);
1009
+ response.end(content);
1010
+ try {
1011
+ response.headersSent = true
1012
+ } catch(err) {
1013
+ // Ignoring warning
1014
+ //console.warn(err);
1015
+ }
1727
1016
 
1728
- var isValidURL = function(url){
1729
- // var re = /(http|ftp|https|sftp):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&amp;:\/~+#-]*[\w@?^=%&amp;\/~+#-])?/;
1730
- return (/(http|ftp|https|sftp):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&amp;:\/~+#-]*[\w@?^=%&amp;\/~+#-])?/.test(url)) ? true : false;
1017
+ freeMemory([content, request, response, next]);
1018
+ }
1731
1019
  }
1732
1020
 
1021
+
1022
+
1733
1023
  /**
1734
1024
  * Set method - Override current method
1735
1025
  * E.g.: in case of redirect, to force PUT to GET
@@ -1797,7 +1087,7 @@ function SuperController(options) {
1797
1087
 
1798
1088
  if (
1799
1089
  staticProps.isStaticFilename && staticsArr.indexOf(url) > -1
1800
- || staticProps.isStaticFilename && staticsArr.indexOf( url.replace(url.substr(url.lastIndexOf('/')+1), '') ) > -1
1090
+ || staticProps.isStaticFilename && staticsArr.indexOf( url.replace(url.substring(url.lastIndexOf('/')+1), '') ) > -1
1801
1091
  || staticProps.isStaticFilename && staticsArr.indexOf(staticProps.firstLevel) > -1
1802
1092
  ) {
1803
1093
  staticProps = null;
@@ -1895,9 +1185,9 @@ function SuperController(options) {
1895
1185
  // ignoreWebRoot = false
1896
1186
  // } else
1897
1187
  if (typeof(res) === 'string' || typeof(res) === 'number' || typeof(res) === 'boolean') {
1898
- if ( /true|1/.test(res) ) {
1188
+ if ( /^(true|1)$/i.test(res) ) {
1899
1189
  ignoreWebRoot = true
1900
- } else if ( /false|0/.test(res) ) {
1190
+ } else if ( /^(false|0)$/i.test(res) ) {
1901
1191
  ignoreWebRoot = false
1902
1192
  } else {
1903
1193
  res = local.res;
@@ -1918,13 +1208,13 @@ function SuperController(options) {
1918
1208
 
1919
1209
  }
1920
1210
 
1921
- if ( req.substr(0,1) === '/') { // is relative (not checking if the URI is defined in the routing.json)
1922
- // if (wroot.substr(wroot.length-1,1) == '/') {
1923
- // wroot = wroot.substr(wroot.length-1,1).replace('/', '')
1211
+ if ( req.substring(0,1) === '/') { // is relative (not checking if the URI is defined in the routing.json)
1212
+ // if (wroot.substring(wroot.length-1,1) == '/') {
1213
+ // wroot = wroot.substring(wroot.length-1,1).replace('/', '')
1924
1214
  // }
1925
1215
 
1926
1216
  if ( /^\//.test(req) && !ignoreWebRoot )
1927
- req = req.substr(1);
1217
+ req = req.substring(1);
1928
1218
 
1929
1219
  rte = ( ignoreWebRoot != null && ignoreWebRoot ) ? req : wroot + req;
1930
1220
  // cleaning url in case of ?param=value
@@ -2015,11 +1305,32 @@ function SuperController(options) {
2015
1305
 
2016
1306
  if ( !self.forward404Unless(condition, req, res) ) { // forward to 404 if bad route
2017
1307
 
2018
- var isProxyHost = ( typeof(local.req.headers.host) != 'undefined' && local.options.conf.server.scheme +'://'+ local.req.headers.host != local.options.conf.hostname || typeof(local.req.headers[':authority']) != 'undefined' && local.options.conf.server.scheme +'://'+ local.req.headers[':authority'] != local.options.conf.hostname ) ? true : false;
2019
- var hostname = (isProxyHost) ? ctx.config.envConf[bundle][env].hostname.replace(/\:\d+$/, '') : ctx.config.envConf[bundle][env].hostname;
1308
+ var localRequestPort = local.req.headers.port || local.req.headers[':port'];
1309
+ var isProxyHost = (
1310
+ typeof(local.req.headers.host) != 'undefined'
1311
+ && typeof(localRequestPort) != 'undefined'
1312
+ && /^(80|443)$/.test(localRequestPort)
1313
+ && local.options.conf.server.scheme +'://'+ local.req.headers.host +':'+ localRequestPort != local.options.conf.hostname.replace(/\:\d+$/, '') +':'+ local.options.conf.server.port
1314
+ ||
1315
+ typeof(local.req.headers[':authority']) != 'undefined'
1316
+ && local.options.conf.server.scheme +'://'+ local.req.headers[':authority'] != local.options.conf.hostname
1317
+ ||
1318
+ typeof(local.req.headers.host) != 'undefined'
1319
+ && typeof(localRequestPort) != 'undefined'
1320
+ && /^(80|443)$/.test(localRequestPort)
1321
+ && req.headers.host == local.options.conf.host
1322
+ ||
1323
+ typeof(local.req.headers['x-nginx-proxy']) != 'undefined'
1324
+ && /^true$/i.test(local.req.headers['x-nginx-proxy'])
1325
+ ||
1326
+ typeof(process.gina.PROXY_HOSTNAME) != 'undefined'
1327
+ ) ? true : false;
1328
+
1329
+ // var isProxyHost = getContext('isProxyHost');
1330
+ var hostname = (isProxyHost)
1331
+ ? process.gina.PROXY_HOSTNAME
1332
+ : ctx.config.envConf[bundle][env].hostname;
2020
1333
 
2021
- // if ( !/\:\d+$/.test(req.headers.host) )
2022
- // hostname = hostname.replace(/\:\d+$/, '');
2023
1334
 
2024
1335
  if (route) { // will go with route first
2025
1336
 
@@ -2078,7 +1389,7 @@ function SuperController(options) {
2078
1389
  originalMethod && !/GET/i.test(originalMethod)
2079
1390
  ) { // trying to redirect using the wrong method ?
2080
1391
 
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.\nD\'ont panic :)\nSwitching request method to `GET` method instead.\n').message);
1392
+ 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
1393
  method = local.req.method = self.setRequestMethod('GET', conf);
2083
1394
  code = 303;
2084
1395
  }
@@ -2287,9 +1598,8 @@ function SuperController(options) {
2287
1598
  * @param {string} url - eg.: https://upload.wikimedia.org/wikipedia/fr/2/2f/Firefox_Old_Logo.png
2288
1599
  * @param {object} [options]
2289
1600
  *
2290
- *
2291
1601
  * */
2292
- this.downloadFromURL = function(url, options) {
1602
+ this.downloadFromURL = function(url, options, cb) {
2293
1603
 
2294
1604
  var defaultOptions = {
2295
1605
  // file name i you want to rename the file
@@ -2326,15 +1636,13 @@ function SuperController(options) {
2326
1636
 
2327
1637
  if ( /\:\/\//.test(url) ) {
2328
1638
  scheme = url.match(/^\w+\:/)[0];
2329
- scheme = scheme.substr(0, scheme.length-1);
1639
+ scheme = scheme.substring(0, scheme.length-1);
2330
1640
 
2331
1641
  if ( !/^http/.test(scheme) ) {
2332
1642
  self.throwError(local.res, 500, new Error('[ '+ scheme +' ] Scheme not supported. Ref.: `http` or `https` only'));
2333
1643
  return;
2334
1644
  }
2335
1645
 
2336
-
2337
-
2338
1646
  } else { // by default
2339
1647
  scheme = 'http';
2340
1648
  }
@@ -2342,9 +1650,10 @@ function SuperController(options) {
2342
1650
  requestOptions.scheme = scheme +':';
2343
1651
 
2344
1652
  //defining port
1653
+ // console.debug('[ CONTROLLER ][ HTTP/2.0#downloadFromURL ] defining port from: ', url);
2345
1654
  var port = url.match(/\:\d+\//) || null;
2346
1655
  if ( port != null ) {
2347
- port = port[0].substr(1, port[0].length-2);
1656
+ port = port[0].match(/\d+/)[0];
2348
1657
  requestOptions.port = ~~port;
2349
1658
  }
2350
1659
 
@@ -2376,7 +1685,7 @@ function SuperController(options) {
2376
1685
  opt.contentDisposition += '; filename=' + filename;
2377
1686
  }
2378
1687
 
2379
- var ext = filename.match(/\.\w+$/)[0].substr(1)
1688
+ var ext = filename.match(/\.\w+$/)[0].substring(1)
2380
1689
  , contentType = null
2381
1690
  , tmp = _(GINA_TMPDIR +'/'+ filename, true)
2382
1691
  ;
@@ -2394,11 +1703,32 @@ function SuperController(options) {
2394
1703
  requestOptions.headers['content-type'] = contentType;
2395
1704
  requestOptions.headers['content-disposition'] = opt.contentDisposition;
2396
1705
 
1706
+ if (
1707
+ typeof(local.req.headers['x-client-ip']) != 'undefined'
1708
+ && local.req.headers['x-client-ip'] != requestOptions.headers['x-client-ip']
1709
+ ) {
1710
+ requestOptions.headers['x-client-ip'] = local.req.headers['x-client-ip']
1711
+ }
1712
+
1713
+ if (
1714
+ typeof(local.req.headers['x-ingress-ip']) != 'undefined'
1715
+ && local.req.headers['x-ingress-ip'] != requestOptions.headers['x-ingress-ip']
1716
+ ) {
1717
+ requestOptions.headers['x-ingress-ip'] = local.req.headers['x-ingress-ip']
1718
+ }
1719
+
1720
+ if (
1721
+ typeof(local.req.headers['x-forwarded-for']) != 'undefined'
1722
+ && local.req.headers['x-forwarded-for'] != requestOptions.headers['x-forwarded-for']
1723
+ ) {
1724
+ requestOptions.headers['x-forwarded-for'] = local.req.headers['x-forwarded-for']
1725
+ }
1726
+
2397
1727
  var browser = require(''+ scheme);
2398
- //console.debug('requestOptions: \n', JSON.stringify(requestOptions, null, 4));
1728
+ // console.debug('requestOptions: \n', JSON.stringify(requestOptions, null, 2));
2399
1729
 
2400
1730
  browser
2401
- .get(requestOptions, function(response) {
1731
+ .get(requestOptions, async function(response) {
2402
1732
 
2403
1733
  local.res.setHeader('content-type', contentType + '; charset='+ local.options.conf.encoding);
2404
1734
  local.res.setHeader('content-disposition', opt.contentDisposition);
@@ -2410,9 +1740,15 @@ function SuperController(options) {
2410
1740
  // local.res.setHeader('pragma', 'must-revalidate');
2411
1741
 
2412
1742
 
2413
- response.pipe(local.res);
1743
+ await response.pipe(local.res);
1744
+ if ( typeof(cb) != 'undefined' ) {
1745
+ cb(false)
1746
+ }
2414
1747
  })
2415
1748
  .on('error', function onDownloadError(err) {
1749
+ if ( typeof(cb) != 'undefined' ) {
1750
+ return cb(err)
1751
+ }
2416
1752
  self.throwError(local.res, 500, err);
2417
1753
  });
2418
1754
 
@@ -2659,7 +1995,8 @@ function SuperController(options) {
2659
1995
  ) {
2660
1996
  return false
2661
1997
  }
2662
- self.isProcessingError = false; // by default
1998
+ // by default
1999
+ self.isProcessingError = false;
2663
2000
 
2664
2001
  var queryData = {}
2665
2002
  , defaultOptions = local.query.options
@@ -2669,14 +2006,14 @@ function SuperController(options) {
2669
2006
 
2670
2007
  // options must be used as a copy in case of multiple calls of self.query(options, ...)
2671
2008
  options = merge(JSON.clone(options), defaultOptions);
2672
- // options = merge(options, defaultOptions);
2673
2009
 
2674
- for (var o in options) {//cleaning
2010
+ for (let o in options) {//cleaning
2675
2011
  if ( typeof(options[o]) == 'undefined' || options[o] == undefined) {
2676
2012
  delete options[o]
2677
2013
  }
2678
2014
  }
2679
2015
 
2016
+
2680
2017
  if (self.isCacheless() || self.isLocalScope() ) {
2681
2018
  options.rejectUnauthorized = false;
2682
2019
  }
@@ -2745,14 +2082,17 @@ function SuperController(options) {
2745
2082
  if ( local.req != null && typeof(local.req.ginaHeaders) != 'undefined' ) {
2746
2083
  // gina form headers
2747
2084
  for (let h in local.req.ginaHeaders.form) {
2748
- let k = h.substr(0,1).toUpperCase() + h.substr(1);
2085
+ let k = h.substring(0,1).toUpperCase() + h.substring(1);
2749
2086
  options.headers['X-Gina-Form-' + k ] = local.req.ginaHeaders.form[h];
2750
2087
  }
2751
2088
  }
2752
2089
 
2753
- var ctx = getContext()
2754
- , protocol = null
2755
- , scheme = null
2090
+ var ctx = getContext()
2091
+ , protocol = null
2092
+ , scheme = null
2093
+ , isProxyHost = getContext('isProxyHost')
2094
+ , bundle = null
2095
+ , webroot = options.webroot || ctx.gina.config.envConf[ctx.bundle][ctx.env].server.webroot;// bundle servers's webroot by default
2756
2096
  ;
2757
2097
  // cleanup options.path
2758
2098
  if (/\:\/\//.test(options.path)) {
@@ -2769,11 +2109,16 @@ function SuperController(options) {
2769
2109
  .replace(':'+port, '');
2770
2110
  }
2771
2111
 
2112
+ // if ( typeof(options.protocol) == 'undefined' ) {
2113
+ // options.protocol = ctx.gina.config.envConf[ctx.bundle][ctx.env].server.protocol;
2114
+ // }
2115
+
2772
2116
  // retrieve protocol & scheme: if empty, take the bundles protocol
2773
2117
  protocol = options.protocol || ctx.gina.config.envConf[ctx.bundle][ctx.env].server.protocol;// bundle servers's protocol by default
2774
2118
  protocol = protocol.match(/[.a-z 0-9]+/ig)[0];
2775
2119
  scheme = options.scheme || ctx.gina.config.envConf[ctx.bundle][ctx.env].server.scheme;// bundle servers's scheme by default
2776
2120
  scheme = scheme.match(/[a-z 0-9]+/ig)[0];
2121
+
2777
2122
  // retrieve credentials
2778
2123
  if ( typeof(options.ca) == 'undefined' || ! options.ca ) {
2779
2124
  options.ca = ctx.gina.config.envConf[ctx.bundle][ctx.env].server.credentials.ca;
@@ -2782,24 +2127,18 @@ function SuperController(options) {
2782
2127
  //retrieving dynamic host, hostname & port
2783
2128
  if ( /\@/.test(options.hostname) ) {
2784
2129
 
2785
- var bundle = ( options.hostname.replace(/(.*)\:\/\//, '') ).split(/\@/)[0];
2786
-
2130
+ bundle = ( options.hostname.replace(/(.*)\:\/\//, '') ).split(/\@/)[0];
2787
2131
  // No shorcut possible because conf.hostname might differ from user inputs
2788
2132
  options.host = ctx.gina.config.envConf[bundle][ctx.env].host.replace(/(.*)\:\/\//, '').replace(/\:\d+/, '');
2789
2133
  options.hostname = ctx.gina.config.envConf[bundle][ctx.env].hostname;
2790
2134
  options.port = ctx.gina.config.envConf[bundle][ctx.env].server.port;
2791
-
2792
- options.protocol = ctx.gina.config.envConf[bundle][ctx.env].server.protocol;
2135
+ options.protocol = options.protocol || ctx.gina.config.envConf[bundle][ctx.env].server.protocol;
2793
2136
  options.scheme = ctx.gina.config.envConf[bundle][ctx.env].server.scheme;
2794
2137
 
2795
2138
  // retrieve credentials
2796
2139
  if ( typeof(options.ca) == 'undefined' || ! options.ca ) {
2797
2140
  options.ca = ctx.gina.config.envConf[bundle][ctx.env].server.credentials.ca;
2798
2141
  }
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
2142
  }
2804
2143
 
2805
2144
  if ( typeof(options.protocol) == 'undefined' ) {
@@ -2813,45 +2152,224 @@ function SuperController(options) {
2813
2152
 
2814
2153
 
2815
2154
  // reformating scheme
2816
- if( !/\:$/.test(options.scheme) )
2155
+ if( !/\:$/.test(options.scheme) ) {
2817
2156
  options.scheme += ':';
2157
+ }
2158
+
2159
+ if (isProxyHost) {
2160
+ // X-Forwarded-Host
2161
+ options.headers['x-forwarded-host'] = process.gina.PROXY_HOST;
2162
+ // X-Forwarded-Proto
2163
+ options.headers['x-forwarded-proto'] = process.gina.PROXY_SCHEME;
2164
+ }
2165
+
2166
+ if ( ctx.gina.config.envConf[ctx.bundle][ctx.env].server.resolvers.length > 0 ) {
2167
+ var resolversColl = new Collection(ctx.gina.config.envConf[ctx.bundle][ctx.env].server.resolvers);
2168
+ options.nameservers = resolversColl.findOne({ scope: process.env.NODE_SCOPE}).nameservers;
2169
+ resolversColl = null;
2170
+ }
2818
2171
 
2819
2172
  try {
2820
2173
  options.queryData = queryData;
2174
+
2175
+ bundle = null;
2176
+
2177
+ // TODO - Add preferred communication method option: cCurl or HTTP
2178
+ // return handleCurlRequest(options, callback);
2179
+
2821
2180
  var protocolVersion = ~~options.protocol.match(/\/(.*)$/)[1].replace(/\.\d+/, '');
2822
2181
  var httpLib = options.protocol.match(/^(.*)\//)[1] + ( (protocolVersion >= 2) ? protocolVersion : '' );
2823
2182
  if ( !/http2/.test(httpLib) && /https/.test(options.scheme) ) {
2824
2183
  httpLib += 's';
2825
2184
  }
2826
-
2827
2185
  browser = require(''+ httpLib);
2828
-
2829
2186
  if ( /http2/.test(httpLib) ) {
2830
2187
  return handleHTTP2ClientRequest(browser, options, callback);
2831
2188
  } else {
2832
2189
  return handleHTTP1ClientRequest(browser, options, callback);
2833
2190
  }
2834
2191
 
2835
-
2836
2192
  } catch(err) {
2837
2193
  if (callback) {
2838
2194
  return callback(err)
2839
2195
  }
2840
2196
  self.emit('query#complete', err)
2841
2197
  }
2198
+ }
2199
+
2200
+ var handleCurlRequest = async function(opt, callback) {
2201
+
2202
+
2203
+ var body = null;
2204
+ // https://docs.couchbase.com/server/current/n1ql-rest-query/index.html#Request
2205
+ var cmd = [
2206
+ '$(which curl)'
2207
+ ];
2208
+
2209
+ if (!opt.rejectUnauthorized) {
2210
+ // (SSL) This option explicitly allows curl to perform "insecure" SSL connections and transfers
2211
+ // same as --insecure
2212
+ cmd.splice(1,0,'-k');
2213
+ }
2214
+
2215
+ // method
2216
+ if ( !/get/i.test(opt.method) ) {
2217
+ cmd.splice(1,0,'-X '+ opt.method.toUpperCase() );
2218
+ }
2219
+
2220
+
2221
+ if ( /(post|put)/i.test(opt.method) && opt.queryData.length > 0) {
2222
+ cmd.push('-d '+ opt.queryData );
2223
+ body = Buffer.from(opt.queryData);
2224
+ opt.headers['content-length'] = body.length;
2225
+ } else if (
2226
+ /get/i.test(opt.method)
2227
+ && typeof(opt.headers['content-length']) != 'undefined'
2228
+ ) {
2229
+ delete opt.headers['content-length'];
2230
+ }
2231
+
2232
+ if ( opt.headers.count() > 0) {
2233
+ for (let h in opt.headers) {
2234
+ cmd.splice(1,0,'-H "'+ h +': '+ opt.headers[h] +'"');
2235
+ }
2236
+ }
2237
+
2238
+ // resolvers
2239
+ if (opt.nameservers) {
2240
+ resolver.setServers(opt.nameservers);
2241
+ await resolver
2242
+ .resolve4(opt.host)
2243
+ .catch( function onResolverErr(e) {
2244
+ var infos = local.options, controllerName = infos.controller.substring(infos.controller.lastIndexOf('/'));
2245
+ 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';
2246
+ var exception = new Error(msg);
2247
+ exception.status = 500;
2248
+ return self.throwError(exception);
2249
+ })
2250
+ .then( function onResolved(ips) {
2251
+ if ( typeof(ips) == 'undefined' || !Array.isArray(ips) || !ips.length ) {
2252
+ var infos = local.options, controllerName = infos.controller.substring(infos.controller.lastIndexOf('/'));
2253
+ var e = new Error('`Unable to resolve ${opt.host}`');
2254
+ 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';
2255
+ var exception = new Error(msg);
2256
+ exception.status = 500;
2257
+ return self.throwError(exception);
2258
+ }
2259
+ for (let i=0, len=ips.length; i<len; i++) {
2260
+ // e.g.: --resolve www.example.com:443:127.0.0.1
2261
+ cmd.push('--resolve '+ opt.host +':'+ opt.port +':'+ ips[i]);
2262
+ }
2263
+ });
2264
+ }
2265
+
2266
+
2267
+
2268
+
2269
+ cmd.push('-v "'+ opt.hostname + opt.path +'"');
2842
2270
 
2271
+ // Default maxBuffer is 200KB (=> 1024 * 200)
2272
+ // Setting it to 10MB - preventing: stdout maxBuffer length exceeded
2273
+ var maxBuffer = (1024 * 1024 * 10);
2274
+ exec(cmd.join(' '), { maxBuffer: maxBuffer }, function onResult(err, dataStr, infos) {
2275
+ var error = null;
2276
+ if (err) {
2277
+ try {
2278
+ // by default
2279
+ error = new Error('[ CONTROLLER ][ CURL#query ] request aborted\n'+ err.stack);
2280
+ if (
2281
+ typeof(err.message) != 'undefined'
2282
+ && /Failed to connect/i.test(err.message)
2283
+ ) {
2284
+ var port = getContext('gina').ports[opt.protocol][opt.scheme.replace(/\:/, '')][ opt.port ];
2285
+ error.accessPoint = port;
2286
+ error.message = 'Could not connect to [ ' + error.accessPoint + ' ].\nThe `'+port.split(/\@/)[0]+'` bundle is offline or unreachable.\n';
2287
+ }
2288
+ console.error(error.stack);
2289
+ if ( typeof(callback) != 'undefined' ) {
2290
+ callback(error)
2291
+ } else {
2292
+ self.emit('query#complete', error)
2293
+ }
2294
+ } catch (e) {
2295
+ // console.error(e.stack);
2296
+ var infos = local.options, controllerName = infos.controller.substring(infos.controller.lastIndexOf('/'));
2297
+ var msg = 'Controller Query Exception while catching back.\nBundle: '+ infos.bundle +'\nController File: /controllers'+ controllerName +'\nControl: this.'+ infos.control +'(...)\n\r' + e.stack;
2298
+ var exception = new Error(msg);
2299
+ exception.status = 500;
2300
+ self.throwError(exception);
2301
+ }
2302
+ return;
2303
+ }
2304
+
2305
+
2306
+ try {
2307
+ let data = JSON.parse(dataStr);
2308
+ if ( typeof(data) == 'undefined' ) {
2309
+ data = {}
2310
+ }
2311
+ if ( typeof(callback) != 'undefined' ) {
2312
+ callback(err, data)
2313
+ } else {
2314
+ self.emit('query#complete', err, data)
2315
+ }
2316
+ } catch (e) {
2317
+ // _err.stack = '[ CONTROLLER ][ CURL#query ] onCallbackError: '+ e.stack;
2318
+ // console.error(e.stack);
2319
+ var infos = local.options, controllerName = infos.controller.substring(infos.controller.lastIndexOf('/'));
2320
+ var msg = 'Controller Query Exception while catching back.\nBundle: '+ infos.bundle +'\nController File: /controllers'+ controllerName +'\nControl: this.'+ infos.control +'(...)\n\r' + e.stack;
2321
+ var exception = new Error(msg);
2322
+ exception.status = 500;
2323
+ self.throwError(exception);
2324
+ return;
2325
+ }
2326
+ });
2843
2327
  }
2844
2328
 
2329
+ var handleHTTP1ClientRequestv2 = function (browser, options, callback) {
2330
+ var agent = new browser.Agent({ keepAlive: true });
2331
+ var options = {
2332
+ host: options.host,
2333
+ port: options.port,
2334
+ path: options.path,
2335
+ method: 'GET',
2336
+ agent: agent
2337
+ };
2338
+
2339
+ var req = browser.request(options, function(res) {
2340
+ var str = "";
2341
+ var err = false;
2342
+ res.on('data', function (chunk) {
2343
+ str += chunk;
2344
+ });
2345
+ res.on('end', function () {
2346
+ // done
2347
+ return callback( err, data );
2348
+ });
2349
+ });
2350
+ req.write('');
2351
+ req.end();
2352
+ req.on('error', function(error) {
2353
+ err = error
2354
+ });
2355
+ };
2356
+
2845
2357
  var handleHTTP1ClientRequest = function(browser, options, callback) {
2846
2358
 
2847
2359
  var altOpt = JSON.clone(options);
2360
+ // var credentials = self.getConfig('settings').server.credentials;
2361
+ // options.ca = credentials.ca;
2362
+ // options.encKey = credentials.privateKey;
2363
+ // options.encCert = credentials.certificate;
2364
+
2848
2365
 
2849
2366
  altOpt.protocol = options.scheme;
2850
2367
  altOpt.hostname = options.host;
2851
2368
  altOpt.port = options.port;
2369
+ altOpt.maxSockets = options.maxSockets || 1;
2852
2370
  if ( typeof(altOpt.encKey) != 'undefined' ) {
2853
2371
  try {
2854
- altOpt.encKey = fs.readFileSync(options.encKey);
2372
+ altOpt.encKey = fs.readFileSync(altOpt.encKey);
2855
2373
  } catch(err) {
2856
2374
  self.emit('query#complete', err);
2857
2375
  }
@@ -2862,7 +2380,7 @@ function SuperController(options) {
2862
2380
 
2863
2381
  if ( typeof(altOpt.encCert) != 'undefined' ) {
2864
2382
  try {
2865
- altOpt.encCert = fs.readFileSync(options.encCert);
2383
+ altOpt.encCert = fs.readFileSync(altOpt.encCert);
2866
2384
  } catch(err) {
2867
2385
  self.emit('query#complete', err);
2868
2386
  }
@@ -2871,6 +2389,11 @@ function SuperController(options) {
2871
2389
  console.warn('[ CONTROLLER ][ HTTP/1.0#query ] options.encCert not found !');
2872
2390
  }
2873
2391
 
2392
+
2393
+ delete altOpt.ca;
2394
+ delete altOpt.encKey;
2395
+ delete altOpt.encCert;
2396
+
2874
2397
  altOpt.agent = new browser.Agent(altOpt);
2875
2398
 
2876
2399
  var req = browser.request(altOpt, function(res) {
@@ -2930,7 +2453,7 @@ function SuperController(options) {
2930
2453
  return;
2931
2454
  }
2932
2455
  } catch (e) {
2933
- var infos = local.options, controllerName = infos.controller.substr(infos.controller.lastIndexOf('/'));
2456
+ var infos = local.options, controllerName = infos.controller.substring(infos.controller.lastIndexOf('/'));
2934
2457
  var msg = 'Controller Query Exception while catching back.\nBundle: '+ infos.bundle +'\nController File: /controllers'+ controllerName +'\nControl: this.'+ infos.control +'(...)\n\r' + e.stack;
2935
2458
  var exception = new Error(msg);
2936
2459
  exception.status = 500;
@@ -3024,7 +2547,7 @@ function SuperController(options) {
3024
2547
  cb(err, data)
3025
2548
  }
3026
2549
  } catch (e) {
3027
- var infos = local.options, controllerName = infos.controller.substr(infos.controller.lastIndexOf('/'));
2550
+ var infos = local.options, controllerName = infos.controller.substring(infos.controller.lastIndexOf('/'));
3028
2551
  var msg = 'Controller Query Exception while catching back.\nBundle: '+ infos.bundle +'\nController File: /controllers'+ controllerName +'\nControl: this.'+ infos.control +'(...)\n\r' + e.stack;
3029
2552
  var exception = new Error(msg);
3030
2553
  exception.status = 500;
@@ -3101,10 +2624,8 @@ function SuperController(options) {
3101
2624
  delete options.queryData;
3102
2625
 
3103
2626
 
3104
-
3105
2627
  const client = browser.connect(options.hostname, options);
3106
2628
 
3107
-
3108
2629
  const {
3109
2630
  HTTP2_HEADER_PROTOCOL,
3110
2631
  HTTP2_HEADER_SCHEME,
@@ -3127,6 +2648,32 @@ function SuperController(options) {
3127
2648
  options.headers['content-type'] = local.req.headers['content-type']
3128
2649
  }
3129
2650
 
2651
+ if ( typeof(local.req.headers['x-client-ip']) != 'undefined' && local.req.headers['x-client-ip'] != options.headers['x-client-ip'] ) {
2652
+ options.headers['x-client-ip'] = local.req.headers['x-client-ip']
2653
+ }
2654
+
2655
+ if ( typeof(local.req.headers['x-ingress-ip']) != 'undefined' && local.req.headers['x-ingress-ip'] != options.headers['x-ingress-ip'] ) {
2656
+ options.headers['x-ingress-ip'] = local.req.headers['x-ingress-ip']
2657
+ }
2658
+
2659
+ // x-forwarded-for check
2660
+ // console.debug('[ CONTROLLER ][ HTTP/2.0#query ] checking x-forwarded-for');
2661
+ if (
2662
+ // Previous proxies
2663
+ typeof(local.req.headers['x-forwarded-for']) != 'undefined'
2664
+ && local.req.headers['x-forwarded-for'] != ""
2665
+ // current proxy
2666
+ && typeof(local.req.headers['x-real-ip']) != 'undefined'
2667
+ ) {
2668
+ // console.debug('[ CONTROLLER ][ HTTP/2.0#query ] options.headers', JSON.stringify(options.headers, null, 2));
2669
+ // console.debug('[ CONTROLLER ][ HTTP/2.0#query ] local.req.headers', JSON.stringify(local.req.headers, null, 2));
2670
+ var xForwardedFor = "" + local.req.headers['x-forwarded-for'];
2671
+ // Adding the current PI to the list
2672
+ xForwardedFor += ", "+local.req.headers['x-real-ip'];
2673
+ xForwardedFor = null;
2674
+ // console.debug('[ CONTROLLER ][ HTTP/2.0#query ] options.headers["x-forwarded-for"]', options.headers['x-forwarded-for']);
2675
+ }
2676
+
3130
2677
  var headers = merge({
3131
2678
  [HTTP2_HEADER_METHOD]: options[':method'],
3132
2679
  [HTTP2_HEADER_PATH]: options[':path']
@@ -3134,7 +2681,11 @@ function SuperController(options) {
3134
2681
 
3135
2682
  // merging with user options
3136
2683
  for (var o in options) {
3137
- if (!/^\:/.test(o) && !/headers/.test(o) && typeof(headers[o]) == 'undefined' ) {
2684
+ if (
2685
+ !/^\:/.test(o)
2686
+ && !/headers/.test(o)
2687
+ && typeof(headers[o]) == 'undefined'
2688
+ ) {
3138
2689
  headers[o] = options[o]
3139
2690
  }
3140
2691
  }
@@ -3154,6 +2705,7 @@ function SuperController(options) {
3154
2705
  }
3155
2706
 
3156
2707
 
2708
+
3157
2709
  client.on('error', (error) => {
3158
2710
 
3159
2711
  console.error( '`'+ options[':path']+ '` : '+ error.stack||error.message);
@@ -3289,7 +2841,7 @@ function SuperController(options) {
3289
2841
  }
3290
2842
 
3291
2843
  } catch (e) {
3292
- var infos = local.options, controllerName = infos.controller.substr(infos.controller.lastIndexOf('/'));
2844
+ var infos = local.options, controllerName = infos.controller.substring(infos.controller.lastIndexOf('/'));
3293
2845
  var msg = 'Controller Query Exception while catching back.\nBundle: '+ infos.bundle +'\nController File: /controllers'+ controllerName +'\nControl: this.'+ infos.control +'(...)\n\r' + e.stack;
3294
2846
  var exception = new Error(msg);
3295
2847
  exception.status = 500;
@@ -3367,7 +2919,7 @@ function SuperController(options) {
3367
2919
  cb(err, data)
3368
2920
  }
3369
2921
  } catch (e) {
3370
- var infos = local.options, controllerName = infos.controller.substr(infos.controller.lastIndexOf('/'));
2922
+ var infos = local.options, controllerName = infos.controller.substring(infos.controller.lastIndexOf('/'));
3371
2923
  var msg = 'Controller Query Exception while catching back.\nBundle: '+ infos.bundle +'\nController File: /controllers'+ controllerName +'\nControl: this.'+ infos.control +'(...)\n\r' + e.stack;
3372
2924
  var exception = new Error(msg);
3373
2925
  exception.status = 500;
@@ -3502,11 +3054,11 @@ function SuperController(options) {
3502
3054
  project = route.param.project;
3503
3055
  } // TODO - add support for project pointer : getContext('gina').projects[project]
3504
3056
  if (/\@(.*)$/.test(route.param.url)) {
3505
- var targetedBundle = route.param.url.substr(route.param.url.lastIndexOf('@')+1);
3057
+ var targetedBundle = route.param.url.substring(route.param.url.lastIndexOf('@')+1);
3506
3058
  hostname = targetedBundle +'@'+ project;
3507
3059
  port = hostname;
3508
3060
  var webroot = getContext('gina').config.envConf[targetedBundle][local.options.conf.env].server.webroot;
3509
- path = (/\/$/.test(webroot)) ? webroot.substr(0, webroot.length-1) : webroot;
3061
+ path = (/\/$/.test(webroot)) ? webroot.substring(0, webroot.length-1) : webroot;
3510
3062
  } else {
3511
3063
  hostname = route.param.hostname;
3512
3064
  port = route.param.port;
@@ -3560,24 +3112,28 @@ function SuperController(options) {
3560
3112
  *
3561
3113
  * */
3562
3114
  this.getConfig = function(name) {
3115
+ var tmp = null;
3563
3116
  if ( typeof(name) != 'undefined' ) {
3564
3117
  try {
3565
- // needs to be read only
3566
- //config = JSON.clone(local.options.conf.content[name]);
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]);
3118
+ // Needs to be read only
3119
+ tmp = JSON.clone(local.options.conf.content[name]);
3573
3120
  } catch (err) {
3574
3121
  return undefined;
3575
3122
  }
3576
3123
  } else {
3577
- // config = JSON.stringify(local.options.conf);
3578
- // return JSON.parse(config)
3579
- return JSON.clone(local.options.conf);
3124
+ tmp = JSON.clone(local.options.conf);
3125
+ }
3126
+
3127
+ if (
3128
+ getContext('isProxyHost')
3129
+ && typeof(tmp.hostname) != 'undefined'
3130
+ ) {
3131
+ tmp.hostname = process.gina.PROXY_HOSTNAME;
3132
+ tmp.host = process.gina.PROXY_HOST;
3133
+ // tmp.hostname = getContext('gina').config.envConf._proxyHostname
3134
+ // tmp.host = tmp.hostname.replace(/^(https|http)\:\/\//, '');
3580
3135
  }
3136
+ return tmp;
3581
3137
  }
3582
3138
 
3583
3139
  /**
@@ -3687,45 +3243,64 @@ function SuperController(options) {
3687
3243
  return rules;
3688
3244
  }
3689
3245
 
3690
- this.push = function(payload) {
3246
+ this.push = function(payload, option, callback) {
3691
3247
 
3692
3248
  var req = local.req, res = local.res;
3693
3249
  var method = req.method.toLowerCase();
3694
3250
  // if no session defined, will push to all active clients
3251
+ // resuming current session
3695
3252
  var sessionId = ( typeof(req[method].sessionID) != 'undefined' ) ? req[method].sessionID : null;
3696
-
3697
- // resume current session
3253
+ // retrieve section if existing
3254
+ var section = ( typeof(req[method].section) != 'undefined' ) ? req[method].section : null;
3698
3255
 
3699
3256
  if (!payload) {
3700
3257
  payload = null;
3701
3258
  if ( typeof(req[method]) != 'undefined' && typeof(req[method].payload) != 'undefined' ) {
3702
3259
  if ( typeof(payload) == 'string' ) {
3703
- payload = decodeURIComponent(req[method].payload)
3260
+ payload = decodeURIComponent(req[method].payload);
3261
+ payload = JSON.parse(payload);
3262
+ if ( section && typeof(payload.section) == 'undefined' ) {
3263
+ payload.section = section
3264
+ }
3265
+ payload = JSON.stringify(payload)
3704
3266
  } else {
3267
+ if ( section && typeof(req[method].payload.section) == 'undefined' ) {
3268
+ req[method].payload.section = section
3269
+ }
3705
3270
  payload = JSON.stringify(req[method].payload)
3706
3271
  }
3707
3272
  }
3708
3273
  } else if ( typeof(payload) == 'object' ) {
3274
+ if ( section && typeof(payload.section) == 'undefined' ) {
3275
+ payload.section = section
3276
+ }
3709
3277
  payload = JSON.stringify(payload)
3710
3278
  }
3711
3279
 
3712
3280
  try {
3713
3281
  var clients = null;
3714
- if (sessionId) {
3715
- clients = self.serverInstance.eio.getClientsBySessionId(sessionId);
3716
- if (clients)
3717
- clients.send(payload);
3718
- }
3282
+ clients = self.serverInstance.eio.clients;
3283
+ if ( clients ) {
3284
+ for (let s in clients) {
3285
+ if ( !clients[s].constructor.name == 'Socket' ) {
3286
+ continue;
3287
+ }
3719
3288
 
3720
- // send to all clients if no specific sessionId defined
3721
- if (!sessionId) {
3722
- clients = self.serverInstance.eio.clients;
3723
- for (var id in clients) {
3724
- clients[id].send(payload)
3289
+ if (
3290
+ // session filter
3291
+ sessionId
3292
+ && typeof(clients[s].sessionId) != 'undefined'
3293
+ && clients[s].sessionId == sessionId
3294
+ ||
3295
+ // send to all clients if no specific sessionId defined
3296
+ !sessionId
3297
+ ) {
3298
+ clients[s].sendPacket("message", payload, options, callback);
3299
+ }
3725
3300
  }
3726
3301
  }
3727
3302
 
3728
- res.end();
3303
+ // res.end();
3729
3304
  } catch(err) {
3730
3305
  self.throwError(err);
3731
3306
  return;
@@ -3999,10 +3574,9 @@ function SuperController(options) {
3999
3574
  //rootPath : self.executionPath,
4000
3575
  // We don't want to keep original conf untouched
4001
3576
  //conf : JSON.clone(conf),
4002
- //instance: self.serverInstance,
4003
3577
  //template: (routeHasViews) ? bundleConf.content.templates[templateName] : undefined,
4004
3578
  //isUsingTemplate: local.isUsingTemplate,
4005
- //cacheless: cacheless,
3579
+ //isCacheless: isCacheless,
4006
3580
  path: null //, // user custom path : namespace should be ignored | left blank
4007
3581
  //assets: {}
4008
3582
  };
@@ -4219,20 +3793,20 @@ function SuperController(options) {
4219
3793
  return res.end(errOutput);
4220
3794
  } else {
4221
3795
 
4222
-
4223
- console.error(req.method +' ['+ errorObject.status +'] '+ req.url + '\n'+ (errorObject.stack||errorObject.message));
4224
-
3796
+ if ( errorObject && errorObject != 'null' && /object/i.test(typeof(errorObject)) ) {
3797
+ console.error(req.method +' [ '+ errorObject.status +' ] '+ req.url + '\n'+ (errorObject.stack||errorObject.message) );
3798
+ }
4225
3799
 
4226
3800
  // intercept none HTML mime types
4227
3801
  var url = decodeURI(local.req.url) /// avoid %20
4228
3802
  , ext = null
4229
3803
  , isHtmlContent = false
4230
3804
  , hasCustomErrorFile = false
4231
- , eCode = code.toString().substr(0,1) + 'xx'
3805
+ , eCode = code.toString().substring(0,1) + 'xx'
4232
3806
  ;
4233
- var extArr = url.substr(url.lastIndexOf('.')).match(/(\.[A-Za-z0-9]+)/);
3807
+ var extArr = url.substring(url.lastIndexOf('.')).match(/(\.[A-Za-z0-9]+)/);
4234
3808
  if (extArr) {
4235
- ext = extArr[0].substr(1);
3809
+ ext = extArr[0].substring(1);
4236
3810
  }
4237
3811
  if ( !ext || /^(html|htm)$/i.test(ext) ) {
4238
3812
  isHtmlContent = true;
@@ -4306,8 +3880,7 @@ function SuperController(options) {
4306
3880
 
4307
3881
  local.req.routing = routeObj;
4308
3882
  local.req.params.errorObject = errorObject;
4309
- self.renderCustomError(local.req, res, local.next);
4310
- return;
3883
+ return self.renderCustomError(local.req, res, local.next);
4311
3884
  }
4312
3885
 
4313
3886
  }
@@ -4355,13 +3928,13 @@ function SuperController(options) {
4355
3928
  } else {
4356
3929
  // Generic error
4357
3930
  var title = null, message = null, stack = null;;
4358
- if ( typeof(errorObject) != 'undefined' && errorObject && typeof(errorObject.error) != 'undefined' ) {
3931
+ if ( errorObject && typeof(errorObject) != 'undefined' && errorObject && typeof(errorObject.error) != 'undefined' ) {
4359
3932
  title = errorObject.error
4360
3933
  }
4361
- if (typeof(errorObject) != 'undefined' && errorObject && typeof(errorObject.message) != 'undefined' ) {
3934
+ if (errorObject && typeof(errorObject) != 'undefined' && errorObject && typeof(errorObject.message) != 'undefined' ) {
4362
3935
  message = errorObject.message
4363
3936
  }
4364
- if (typeof(errorObject) != 'undefined' && errorObject && typeof(errorObject.stack) != 'undefined' ) {
3937
+ if (errorObject && typeof(errorObject) != 'undefined' && errorObject && typeof(errorObject.stack) != 'undefined' ) {
4365
3938
  stack = errorObject.stack
4366
3939
  }
4367
3940
 
@@ -4390,7 +3963,7 @@ function SuperController(options) {
4390
3963
  return next();
4391
3964
  }
4392
3965
 
4393
- if ( /http\/2/.test(protocol) ) {
3966
+ if ( stream && /http\/2/.test(protocol) ) {
4394
3967
  return stream.end();
4395
3968
  }
4396
3969