gina 0.1.1-alpha.15 → 0.1.1-alpha.150

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/AUTHORS +2 -1
  2. package/README.md +170 -19
  3. package/bin/cli +129 -55
  4. package/bin/cli-debug +4 -4
  5. package/bin/cmd +40 -18
  6. package/bin/gina +40 -34
  7. package/{framework/v0.1.1-alpha.15/core/template/command/gina.bat.tpl → bin/gina.bat} +0 -0
  8. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/AUTHORS +0 -0
  9. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/LICENSE +0 -0
  10. package/framework/v0.1.1-alpha.150/VERSION +1 -0
  11. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/asset/html/nolayout.html +0 -0
  12. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/asset/html/static.html +0 -0
  13. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/asset/img/android-chrome-192x192.png +0 -0
  14. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/asset/img/android-chrome-512x512.png +0 -0
  15. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/asset/img/apple-touch-icon.png +0 -0
  16. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/asset/img/favicon-16x16.png +0 -0
  17. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/asset/img/favicon-32x32.png +0 -0
  18. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/asset/img/favicon.ico +0 -0
  19. package/framework/{v0.1.1-alpha.15/core/asset/js → v0.1.1-alpha.150/core/asset}/plugin/dist/gina.js +109 -106
  20. package/framework/{v0.1.1-alpha.15/core/asset/js → v0.1.1-alpha.150/core/asset}/plugin/dist/gina.js.map +0 -0
  21. package/framework/{v0.1.1-alpha.15/core/asset/js → v0.1.1-alpha.150/core/asset}/plugin/dist/gina.min.css +0 -0
  22. package/framework/{v0.1.1-alpha.15/core/asset/js → v0.1.1-alpha.150/core/asset}/plugin/dist/gina.min.css.map +0 -0
  23. package/framework/v0.1.1-alpha.150/core/asset/plugin/dist/gina.min.js +739 -0
  24. package/framework/v0.1.1-alpha.150/core/asset/plugin/dist/gina.min.js.map +8 -0
  25. package/framework/{v0.1.1-alpha.15/core/asset/js → v0.1.1-alpha.150/core/asset}/plugin/dist/gina.onload.min.js +0 -0
  26. package/framework/{v0.1.1-alpha.15/core/asset/js → v0.1.1-alpha.150/core/asset}/plugin/dist/gina.onload.min.js.map +0 -0
  27. package/framework/v0.1.1-alpha.150/core/asset/plugin/dist/toolbar/css/toolbar-min.css +1 -0
  28. package/framework/v0.1.1-alpha.150/core/asset/plugin/dist/toolbar/css/toolbar.css +3 -0
  29. package/framework/v0.1.1-alpha.150/core/asset/plugin/dist/toolbar/css/toolbar.css.map +1 -0
  30. package/framework/v0.1.1-alpha.150/core/asset/plugin/dist/toolbar/js/jquery-3.1.0.min.js +4 -0
  31. package/framework/v0.1.1-alpha.150/core/asset/plugin/dist/toolbar/main.js +1542 -0
  32. package/framework/v0.1.1-alpha.150/core/asset/plugin/dist/toolbar/toolbar.html +251 -0
  33. package/framework/{v0.1.1-alpha.15/core/asset/js → v0.1.1-alpha.150/core/asset}/plugin/readme.md +6 -6
  34. package/framework/{v0.1.1-alpha.15/core/asset/js → v0.1.1-alpha.150/core/asset}/plugin/uuid.json +0 -0
  35. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/config.js +28 -13
  36. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/connectors/couchbase/index.js +310 -215
  37. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/connectors/couchbase/lib/connector.js +6 -4
  38. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/connectors/couchbase/lib/connector.v2.js +47 -47
  39. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/connectors/couchbase/lib/connector.v3.js +0 -0
  40. package/framework/v0.1.1-alpha.150/core/connectors/couchbase/lib/connector.v4.js +377 -0
  41. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/connectors/couchbase/lib/n1ql.js +3 -2
  42. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/connectors/couchbase/lib/session-store.js +6 -5
  43. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/connectors/couchbase/lib/session-store.v2.js +0 -0
  44. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/connectors/couchbase/lib/session-store.v3.js +0 -0
  45. package/framework/v0.1.1-alpha.150/core/connectors/couchbase/lib/session-store.v4.js +362 -0
  46. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/controller/controller.framework.js +0 -0
  47. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/controller/controller.js +686 -675
  48. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/controller/index.js +0 -0
  49. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/deps/busboy/.travis.yml +0 -0
  50. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/deps/busboy/LICENSE +0 -0
  51. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/deps/busboy/README.md +0 -0
  52. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/deps/busboy/deps/encoding/encoding-indexes.js +0 -0
  53. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/deps/busboy/deps/encoding/encoding.js +0 -0
  54. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/deps/busboy/lib/main.js +0 -0
  55. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/deps/busboy/lib/types/multipart.js +0 -0
  56. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/deps/busboy/lib/types/urlencoded.js +0 -0
  57. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/deps/busboy/lib/utils.js +0 -0
  58. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/deps/busboy/package.json +0 -0
  59. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/deps/swig-client/swig-2.0.0.min.js +0 -0
  60. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/dev/index.js +0 -0
  61. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/dev/lib/class.js +0 -0
  62. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/dev/lib/factory.js +0 -0
  63. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/dev/lib/tools.js +0 -0
  64. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/gna.js +2 -3
  65. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/locales/README.md +0 -0
  66. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/locales/currency.json +0 -0
  67. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/locales/dist/language/en.json +0 -0
  68. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/locales/dist/language/fr.json +0 -0
  69. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/locales/dist/region/en.json +0 -0
  70. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/locales/dist/region/fr.json +0 -0
  71. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/locales/index.js +0 -0
  72. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/locales/src/make.js +0 -0
  73. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/locales/src/resources/currency.csv +0 -0
  74. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/locales/src/resources/region.csv +0 -0
  75. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/locales/src/resources/region.mapping.json +0 -0
  76. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/mime.types +0 -0
  77. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/model/entity.js +80 -60
  78. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/model/index.js +4 -4
  79. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/model/template/entityFactory.js +0 -0
  80. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/model/template/index.js +0 -0
  81. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/plugins/README.md +0 -0
  82. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/plugins/index.js +0 -0
  83. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/plugins/lib/file/README.md +0 -0
  84. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/plugins/lib/file/build.json +0 -0
  85. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/plugins/lib/file/package.json +0 -0
  86. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/plugins/lib/intl/README.md +0 -0
  87. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/plugins/lib/intl/build.json +0 -0
  88. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/plugins/lib/intl/package.json +0 -0
  89. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/plugins/lib/intl/src/main.js +0 -0
  90. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/plugins/lib/storage/README.md +0 -0
  91. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/plugins/lib/storage/build.json +0 -0
  92. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/plugins/lib/storage/package.json +0 -0
  93. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/plugins/lib/storage/src/main.js +0 -0
  94. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/plugins/lib/validator/README.md +0 -0
  95. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/plugins/lib/validator/build.json +0 -0
  96. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/plugins/lib/validator/package.json +0 -0
  97. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/plugins/lib/validator/src/form-validator.js +0 -0
  98. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/plugins/lib/validator/src/main.js +0 -0
  99. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/router.js +91 -78
  100. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/server.express.js +0 -0
  101. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/server.isaac.js +117 -108
  102. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/server.js +2 -1
  103. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/status.codes +0 -0
  104. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/boilerplate/bundle/config/app.json +0 -0
  105. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/boilerplate/bundle/config/routing.json +0 -0
  106. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/boilerplate/bundle/config/settings.json +0 -0
  107. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/boilerplate/bundle/config/settings.server.json +0 -0
  108. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/boilerplate/bundle/config/templates.json +4 -4
  109. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/boilerplate/bundle/controllers/controller.content.js +0 -0
  110. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/boilerplate/bundle/controllers/controller.js +0 -0
  111. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/boilerplate/bundle/controllers/setup.js +0 -0
  112. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/boilerplate/bundle/index.js +0 -0
  113. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/boilerplate/bundle_namespace/controllers/controller.js +0 -0
  114. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/boilerplate/bundle_public/css/default.css +0 -0
  115. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/boilerplate/bundle_public/css/vendor/readme.md +0 -0
  116. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/boilerplate/bundle_public/favicon.ico +0 -0
  117. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/boilerplate/bundle_public/js/vendor/readme.md +0 -0
  118. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/boilerplate/bundle_public/readme.md +0 -0
  119. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/boilerplate/bundle_templates/handlers/main.js +0 -0
  120. package/framework/v0.1.1-alpha.150/core/template/boilerplate/bundle_templates/html/content/homepage.html +8 -0
  121. package/framework/v0.1.1-alpha.150/core/template/boilerplate/bundle_templates/html/includes/error-msg-noscript.html +11 -0
  122. package/framework/v0.1.1-alpha.150/core/template/boilerplate/bundle_templates/html/includes/error-msg-outdated-browser.html +8 -0
  123. package/framework/{v0.1.1-alpha.15/core/template/boilerplate/bundle_templates/html/layout → v0.1.1-alpha.150/core/template/boilerplate/bundle_templates/html/layouts}/main.html +10 -3
  124. package/framework/v0.1.1-alpha.150/core/template/command/gina.bat.tpl +8 -0
  125. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/command/gina.tpl +0 -0
  126. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/conf/env.json +0 -0
  127. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/conf/manifest.json +0 -0
  128. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/conf/package.json +0 -0
  129. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/conf/settings.json +0 -0
  130. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/conf/statics.json +3 -3
  131. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/conf/templates.json +2 -2
  132. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/error/client/json/401.json +0 -0
  133. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/error/client/json/403.json +0 -0
  134. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/error/client/json/404.json +0 -0
  135. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/error/server/html/50x.html +0 -0
  136. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/error/server/json/500.json +0 -0
  137. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/error/server/json/503.json +0 -0
  138. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/core/template/extensions/logger/config.json +0 -0
  139. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/helpers/console.js +0 -0
  140. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/helpers/context.js +144 -4
  141. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/helpers/dateFormat.js +3 -1
  142. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/helpers/index.js +9 -4
  143. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/helpers/json/README.md +0 -0
  144. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/helpers/json/package.json +0 -0
  145. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/helpers/json/src/main.js +0 -0
  146. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/helpers/path.js +142 -88
  147. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/helpers/plugins/README.md +0 -0
  148. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/helpers/plugins/package.json +0 -0
  149. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/helpers/plugins/src/api-error.js +23 -23
  150. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/helpers/plugins/src/main.js +0 -0
  151. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/helpers/prototypes.js +35 -36
  152. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/helpers/task.js +21 -14
  153. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/helpers/text.js +0 -0
  154. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/archiver/README.md +0 -0
  155. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/archiver/build.json +0 -0
  156. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/archiver/package.json +0 -0
  157. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/archiver/src/dep/jszip.min.js +0 -0
  158. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/archiver/src/main.js +0 -0
  159. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/aliases.json +4 -1
  160. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/bundle/add.js +43 -17
  161. package/framework/v0.1.1-alpha.150/lib/cmd/bundle/arguments.json +6 -0
  162. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/bundle/copy.js +0 -0
  163. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/bundle/cp.js +0 -0
  164. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/bundle/help.js +0 -0
  165. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/bundle/help.txt +2 -2
  166. package/framework/v0.1.1-alpha.150/lib/cmd/bundle/list.js +176 -0
  167. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/bundle/remove.js +22 -22
  168. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/bundle/rename.js +0 -0
  169. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/bundle/restart.js +0 -0
  170. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/bundle/rm.js +0 -0
  171. package/framework/v0.1.1-alpha.150/lib/cmd/bundle/start.js +420 -0
  172. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/bundle/status.js +0 -0
  173. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/bundle/stop.js +93 -74
  174. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/env/add.js +0 -0
  175. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/env/get.js +0 -0
  176. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/env/help.js +0 -0
  177. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/env/help.txt +0 -0
  178. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/env/link-dev.js +0 -0
  179. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/env/list.js +0 -0
  180. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/env/remove.js +0 -0
  181. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/env/rm.js +0 -0
  182. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/env/set.js +0 -0
  183. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/env/unset.js +0 -0
  184. package/framework/{v0.1.1-alpha.15/lib/cmd/scope → v0.1.1-alpha.150/lib/cmd/env}/use.js +21 -1
  185. package/framework/v0.1.1-alpha.150/lib/cmd/framework/build.js +85 -0
  186. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/framework/dot.js +0 -0
  187. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/framework/get.js +0 -0
  188. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/framework/help.js +0 -0
  189. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/framework/help.txt +0 -0
  190. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/framework/init.js +70 -16
  191. package/framework/v0.1.1-alpha.150/lib/cmd/framework/link-node-modules.js +86 -0
  192. package/framework/v0.1.1-alpha.150/lib/cmd/framework/link.js +94 -0
  193. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/framework/msg.json +0 -0
  194. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/framework/open.js +15 -0
  195. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/framework/restart.js +53 -25
  196. package/framework/v0.1.1-alpha.150/lib/cmd/framework/set.js +264 -0
  197. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/framework/start.js +35 -12
  198. package/framework/v0.1.1-alpha.150/lib/cmd/framework/status.js +138 -0
  199. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/framework/stop.js +44 -28
  200. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/framework/tail.js +113 -61
  201. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/framework/update.js +0 -0
  202. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/framework/version.js +12 -3
  203. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/gina-dev.1.md +0 -0
  204. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/gina-framework.1.md +0 -0
  205. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/gina.1.md +0 -0
  206. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/helper.js +74 -5
  207. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/index.js +21 -21
  208. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/msg.json +0 -0
  209. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/port/help.js +0 -0
  210. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/port/help.txt +0 -0
  211. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/port/inc/scan.js +32 -17
  212. package/framework/v0.1.1-alpha.150/lib/cmd/port/list.js +446 -0
  213. package/framework/v0.1.1-alpha.150/lib/cmd/port/reset.js +426 -0
  214. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/port/set.js +0 -0
  215. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/project/add.js +145 -121
  216. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/project/arguments.json +0 -0
  217. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/project/build.js +0 -0
  218. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/project/help.js +0 -0
  219. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/project/help.txt +0 -0
  220. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/project/import.js +0 -0
  221. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/project/list.js +0 -0
  222. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/project/move.js +0 -0
  223. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/project/remove.js +17 -17
  224. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/project/rename.js +0 -0
  225. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/project/restart.js +0 -0
  226. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/project/rm.js +0 -0
  227. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/project/start.js +0 -0
  228. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/project/status.js +0 -0
  229. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/project/stop.js +0 -0
  230. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/protocol/help.js +0 -0
  231. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/protocol/help.txt +0 -0
  232. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/protocol/list.js +0 -0
  233. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/protocol/set.js +239 -201
  234. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/scope/help.js +0 -0
  235. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/scope/help.txt +0 -0
  236. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/scope/link-local.js +0 -0
  237. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/scope/list.js +0 -0
  238. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/scope/remove.js +0 -0
  239. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/scope/rm.js +0 -0
  240. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/scope/set.js +0 -0
  241. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/scope/unset.js +0 -0
  242. package/framework/{v0.1.1-alpha.15/lib/cmd/env → v0.1.1-alpha.150/lib/cmd/scope}/use.js +0 -0
  243. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cmd/view/add.js +34 -9
  244. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/collection/README.md +0 -0
  245. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/collection/build.json +0 -0
  246. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/collection/package.json +0 -0
  247. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/collection/src/main.js +0 -0
  248. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/config.js +0 -0
  249. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cron/README.md +0 -0
  250. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cron/package.json +0 -0
  251. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/cron/src/main.js +0 -0
  252. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/generator/index.js +0 -0
  253. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/index.js +0 -0
  254. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/inherits/LICENSE +0 -0
  255. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/inherits/README.md +0 -0
  256. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/inherits/example/inheriting_eventemitter.js +0 -0
  257. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/inherits/example/protected_inheritance.js +0 -0
  258. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/inherits/example/simple_inheritance.js +0 -0
  259. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/inherits/example/super_attribute_overridden_by_child_on_init.js +0 -0
  260. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/inherits/package.json +0 -0
  261. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/inherits/src/main.js +0 -0
  262. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/logger/README.md +0 -0
  263. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/logger/package.json +0 -0
  264. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/logger/src/containers/default/index.js +13 -2
  265. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/logger/src/containers/file/index.js +105 -14
  266. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/logger/src/containers/file/lib/logrotator/README.md +0 -0
  267. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/logger/src/containers/file/lib/logrotator/index.js +0 -0
  268. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/logger/src/containers/mq/index.js +2 -1
  269. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/logger/src/containers/mq/listener.js +16 -14
  270. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/logger/src/containers/mq/speaker.js +32 -3
  271. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/logger/src/helper.js +19 -0
  272. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/logger/src/main.js +4 -1
  273. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/math/index.js +0 -0
  274. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/merge/README.md +0 -0
  275. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/merge/example/merge.js +0 -0
  276. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/merge/example/merge_2_literal objects.js +0 -0
  277. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/merge/example/merge_and_preserve_first.js +0 -0
  278. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/merge/package.json +0 -0
  279. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/merge/src/main.js +0 -0
  280. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/model.js +0 -0
  281. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/proc.js +69 -45
  282. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/routing/README.md +0 -0
  283. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/routing/build.json +0 -0
  284. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/routing/package.json +0 -0
  285. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/routing/src/main.js +0 -0
  286. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/session-store.js +0 -0
  287. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/shell.js +3 -3
  288. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/swig-filters/README.md +0 -0
  289. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/swig-filters/package.json +0 -0
  290. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/swig-filters/src/main.js +54 -51
  291. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/url/README.md +0 -0
  292. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/url/index.js +0 -0
  293. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/url/mocks.json +0 -0
  294. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/url/routing.json +0 -0
  295. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/url/test.js +0 -0
  296. package/framework/{v0.1.1-alpha.15 → v0.1.1-alpha.150}/lib/validator.js +0 -0
  297. package/framework/v0.1.1-alpha.150/package.json +14 -0
  298. package/package.json +30 -21
  299. package/resources/home/main.json +19 -1
  300. package/resources/home/settings.json +5 -0
  301. package/resources/home/user/extensions/logger/default/config.json +1 -1
  302. package/resources/package.json.template +28 -17
  303. package/script/post_install.js +398 -120
  304. package/script/post_publish.js +185 -0
  305. package/script/pre_install.js +424 -76
  306. package/script/prepare_version.js +151 -21
  307. package/utils/helper.js +230 -44
  308. package/utils/prototypes.js +9 -9
  309. package/utils/prototypes.json_clone.js +31 -31
  310. package/doc/framework/cli/doc.json +0 -9
  311. package/doc/framework/index.md +0 -60
  312. package/framework/v0.1.1-alpha.15/VERSION +0 -1
  313. package/framework/v0.1.1-alpha.15/core/asset/js/plugin/dist/gina.min.js +0 -736
  314. package/framework/v0.1.1-alpha.15/core/asset/js/plugin/dist/gina.min.js.map +0 -56
  315. package/framework/v0.1.1-alpha.15/core/template/boilerplate/bundle_templates/html/homepage.html +0 -4
  316. package/framework/v0.1.1-alpha.15/lib/cmd/bundle/arguments.json +0 -4
  317. package/framework/v0.1.1-alpha.15/lib/cmd/bundle/list.js +0 -129
  318. package/framework/v0.1.1-alpha.15/lib/cmd/bundle/start.js +0 -394
  319. package/framework/v0.1.1-alpha.15/lib/cmd/framework/set.js +0 -161
  320. package/framework/v0.1.1-alpha.15/lib/cmd/framework/status.js +0 -72
  321. package/framework/v0.1.1-alpha.15/lib/cmd/port/list.js +0 -176
  322. package/framework/v0.1.1-alpha.15/package.json +0 -14
@@ -44,9 +44,9 @@ function SuperController(options) {
44
44
 
45
45
  //public
46
46
  this.name = 'SuperController';
47
- this.engine = {};
48
-
49
-
47
+ this.engine = {};
48
+
49
+
50
50
  var self = this;
51
51
  //private
52
52
  var local = {
@@ -68,16 +68,16 @@ function SuperController(options) {
68
68
  if ( typeof(SuperController.initialized) != 'undefined' ) {
69
69
  return getInstance()
70
70
  } else {
71
-
71
+
72
72
  SuperController.instance = self;
73
-
74
-
73
+
74
+
75
75
  if (local.options) {
76
76
  SuperController.instance._options = local.options;
77
77
  }
78
-
78
+
79
79
  SuperController.initialized = true;
80
-
80
+
81
81
  }
82
82
  }
83
83
 
@@ -85,46 +85,46 @@ function SuperController(options) {
85
85
  local.options = SuperController.instance._options = options;
86
86
  // 2022-03-07 Fix for none-developpement environnements (without cache)
87
87
  self._options = local.options;
88
-
88
+
89
89
  return SuperController.instance;
90
90
  }
91
91
 
92
92
  var hasViews = function() {
93
93
  return ( typeof(local.options.template) != 'undefined' ) ? true : false;
94
94
  }
95
-
95
+
96
96
  /**
97
97
  * isHttp2
98
98
  * Returns `true` if server configured for HTTP/2
99
- *
99
+ *
100
100
  * @returns {boolean} isHttp2
101
101
  */
102
102
  var isHttp2 = function() {
103
- var options = local.options;
103
+ var options = local.options;
104
104
  var protocolVersion = ~~options.conf.server.protocol.match(/\/(.*)$/)[1].replace(/\.\d+/, '');
105
105
  var httpLib = options.conf.server.protocol.match(/^(.*)\//)[1] + ( (protocolVersion >= 2) ? protocolVersion : '' );
106
-
107
-
106
+
107
+
108
108
  return /http2/.test(httpLib)
109
109
  }
110
110
  /**
111
111
  * isSecured
112
112
  * Returns `true` if server configured to handle a HTTPS exchanges
113
- *
113
+ *
114
114
  * @returns {boolean} isSecured
115
115
  */
116
116
  var isSecured = function() {
117
117
  return /https/.test(local.options.conf.server.scheme)
118
118
  }
119
-
119
+
120
120
  this.getRequestObject = function() {
121
121
  return local.req;
122
122
  }
123
-
123
+
124
124
  this.getResponseObject = function() {
125
125
  return local.res;
126
126
  }
127
-
127
+
128
128
  this.getNextCallback = function() {
129
129
  return local.next;
130
130
  }
@@ -146,7 +146,7 @@ function SuperController(options) {
146
146
  local.options = SuperController.instance._options = options;
147
147
  local.options.renderingStack = (local.options.renderingStack) ? local.options.renderingStack : [];
148
148
  local.options.isRenderingCustomError = (local.options.isRenderingCustomError) ? local.options.isRenderingCustomError : false;
149
-
149
+
150
150
 
151
151
  // N.B.: Avoid setting `page` properties as much as possible from the routing.json
152
152
  // It will be easier for the framework if set from the controller.
@@ -169,12 +169,12 @@ function SuperController(options) {
169
169
  // var data = { page: { view: { title: "My Title"}}};
170
170
  // self.render(data)
171
171
  // }
172
-
172
+
173
173
  if ( typeof(options.conf.content.routing[options.rule].param) != 'undefined' ) {
174
174
  var str = 'page.'
175
175
  , p = options.conf.content.routing[options.rule].param
176
176
  ;
177
-
177
+
178
178
  for (var key in p) {
179
179
  if ( p.hasOwnProperty(key) && !/^(control)$/.test(key) ) {
180
180
  str += key + '.';
@@ -217,19 +217,19 @@ function SuperController(options) {
217
217
 
218
218
 
219
219
  if ( typeof(local.options.template) != 'undefined' && local.options.template ) {
220
- if (
221
- typeof(local.options.template.ext) != 'undefined'
222
- && local.options.template.ext
220
+ if (
221
+ typeof(local.options.template.ext) != 'undefined'
222
+ && local.options.template.ext
223
223
  && local.options.template.ext != ''
224
224
  ) {
225
225
  ext = local.options.template.ext
226
226
  }
227
-
227
+
228
228
  if ( !/\./.test(ext) ) {
229
229
  ext = '.' + ext;
230
230
  local.options.template.ext = ext
231
231
  }
232
-
232
+
233
233
  if (
234
234
  typeof(local.options.template.layout) == 'undefined'
235
235
  || /^false$/.test(local.options.template.layout)
@@ -238,27 +238,27 @@ function SuperController(options) {
238
238
  isWithoutLayout = true;
239
239
  }
240
240
  }
241
-
242
-
241
+
242
+
243
243
  if ( hasViews() ) {
244
244
 
245
245
  if ( typeof(local.options.file) == 'undefined') {
246
246
  local.options.file = 'index'
247
247
  }
248
-
248
+
249
249
  if ( typeof(local.options.isWithoutLayout) == 'undefined' || !isWithoutLayout ) {
250
250
  local.options.isWithoutLayout = false;
251
251
  }
252
-
252
+
253
253
  rule = local.options.rule;
254
254
  namespace = local.options.namespace || 'default';
255
-
256
-
255
+
256
+
257
257
  set('page.view.file', local.options.file);
258
258
  set('page.view.title', rule.replace(new RegExp('@' + options.conf.bundle), ''));
259
259
  set('page.view.namespace', namespace);
260
- }
261
-
260
+ }
261
+
262
262
 
263
263
  var ctx = getContext('gina');
264
264
  // new declaration && overrides
@@ -270,6 +270,8 @@ function SuperController(options) {
270
270
  "middleware" : ctx.middleware
271
271
  };
272
272
 
273
+ set('page.environment.allocated memory', (require('v8').getHeapStatistics().heap_size_limit / (1024 * 1024 * 1024)).toFixed(2) +' GB');
274
+
273
275
  set('page.environment.gina', version.number);
274
276
  set('page.environment.gina pid', GINA_PID);
275
277
  set('page.environment.nodejs', version.nodejs +' '+ version.platform +' '+ version.arch);
@@ -277,18 +279,18 @@ function SuperController(options) {
277
279
  set('page.environment.env', process.env.NODE_ENV);
278
280
  set('page.environment.envIsDev', self.isCacheless());
279
281
  set('page.environment.date.now', new Date().format("isoDateTime"));
280
-
281
-
282
+
283
+
282
284
  var routing = local.options.conf.routing = ctx.config.envConf.routing; // all routes
283
285
  set('page.environment.routing', escape(JSON.stringify(routing))); // export for GFF
284
286
  //reverseRouting
285
287
  var reverseRouting = local.options.conf.reverseRouting = ctx.config.envConf.reverseRouting; // all routes
286
288
  set('page.environment.reverseRouting', escape(JSON.stringify(reverseRouting))); // export for GFF
287
-
289
+
288
290
  var forms = local.options.conf.forms = options.conf.content.forms // all forms
289
291
  set('page.environment.forms', escape(JSON.stringify(forms))); // export for GFF
290
292
  set('page.forms', options.conf.content.forms);
291
-
293
+
292
294
  set('page.environment.hostname', ctx.config.envConf[options.conf.bundle][process.env.NODE_ENV].hostname);
293
295
  set('page.environment.webroot', options.conf.server.webroot);
294
296
  set('page.environment.bundle', options.conf.bundle);
@@ -298,14 +300,14 @@ function SuperController(options) {
298
300
  set('page.environment.port', options.conf.server.port);
299
301
  set('page.environment.debugPort', options.conf.server.debugPort);
300
302
  set('page.environment.pid', process.pid);
301
-
302
-
303
+
304
+
303
305
  set('page.view.ext', ext);
304
306
  set('page.view.control', action);
305
307
  set('page.view.controller', local.options.controller.replace(options.conf.bundlesPath, ''), true);
306
308
  if (typeof (local.options.controlRequired) != 'undefined' ) {
307
309
  set('page.view.controlRequired', local.options.controlRequired);
308
- }
310
+ }
309
311
  set('page.view.method', local.options.method);
310
312
  set('page.view.namespace', namespace); // by default
311
313
  set('page.view.url', req.url);
@@ -314,12 +316,12 @@ function SuperController(options) {
314
316
  set('page.view.html.properties.mode.javascriptsDeferEnabled', local.options.template.javascriptsDeferEnabled);
315
317
  set('page.view.html.properties.mode.routeNameAsFilenameEnabled', local.options.template.routeNameAsFilenameEnabled);
316
318
  }
317
-
318
-
319
+
320
+
319
321
  var parameters = JSON.clone(req.getParams());
320
322
  parameters = merge(parameters, options.conf.content.routing[rule].param);
321
323
  // excluding default page properties
322
- delete parameters[0];
324
+ delete parameters[0];
323
325
  delete parameters.file;
324
326
  delete parameters.control;
325
327
  delete parameters.title;
@@ -329,7 +331,7 @@ function SuperController(options) {
329
331
 
330
332
  set('page.view.route', rule);
331
333
 
332
-
334
+
333
335
  var acceptLanguage = GINA_CULTURE; // by default : language-COUNTRY
334
336
  if ( typeof(req.headers['accept-language']) != 'undefined' ) {
335
337
  acceptLanguage = req.headers['accept-language']
@@ -348,8 +350,8 @@ function SuperController(options) {
348
350
 
349
351
  try {
350
352
  userLocales = locales.findOne({ lang: userLangCode }).content;
351
- } catch (err) {
352
- //var defaultRegion = (local.options.conf.content.settings.region) ? local.options.conf.content.settings.region.shortCode
353
+ } catch (err) {
354
+ //var defaultRegion = (local.options.conf.content.settings.region) ? local.options.conf.content.settings.region.shortCode
353
355
  console.warn('language code `'+ userLangCode +'` not handled by current locales setup: replacing by default: `'+ local.options.conf.content.settings.region.shortCode +'`');
354
356
  userLocales = locales.findOne({ lang: local.options.conf.content.settings.region.shortCode }).content // by default
355
357
  }
@@ -359,7 +361,7 @@ function SuperController(options) {
359
361
 
360
362
  // user locale
361
363
  options.conf.locale = new Collection(userLocales).findOne({ short: userCountryCode }) || {};
362
-
364
+
363
365
  //set('page.date.now', new Date().format("isoDateTime"));
364
366
  if ( typeof(options.conf.locale) == 'undefined' || !options.conf.locale ) {
365
367
  options.conf.locale = {}
@@ -370,17 +372,17 @@ function SuperController(options) {
370
372
  set('page.view.locale', options.conf.locale);
371
373
  set('page.view.lang', userCulture);
372
374
  }
373
-
375
+
374
376
  if ( !getContext('isProxyHost') ) {
375
377
  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;
376
378
  setContext('isProxyHost', isProxyHost);
377
379
  }
378
-
380
+
379
381
  //TODO - detect when to use swig
380
382
  var dir = null;
381
383
  if (local.options.template || self.templates) {
382
384
  dir = local.options.template.templates || self.templates;
383
-
385
+
384
386
  var swigOptions = {
385
387
  autoescape : ( typeof(local.options.autoescape) != 'undefined') ? local.options.autoescape : false,
386
388
  // `memory` is no working yet ... advanced rendering setup required
@@ -401,11 +403,11 @@ function SuperController(options) {
401
403
  // preserve the same timezone as the system
402
404
  var defaultTZOffset = new Date().getTimezoneOffset();
403
405
  swig.setDefaultTZOffset(defaultTZOffset);
404
-
406
+
405
407
  self.engine = swig;
406
408
  }
407
409
  }
408
-
410
+
409
411
  this.renderWithoutLayout = function (data, displayToolbar) {
410
412
 
411
413
  // preventing multiple call of self.renderWithoutLayout() when controller is rendering from another required controller
@@ -414,7 +416,7 @@ function SuperController(options) {
414
416
  }
415
417
 
416
418
  local.options.isWithoutLayout = true;
417
-
419
+
418
420
  self.render(data, displayToolbar);
419
421
  }
420
422
 
@@ -444,47 +446,47 @@ function SuperController(options) {
444
446
  ) ? true : false;
445
447
  if (isRenderingCustomError)
446
448
  delete userData.isRenderingCustomError;
447
-
449
+
448
450
  var localOptions = (errOptions) ? errOptions : local.options;
449
451
  localOptions.renderingStack.push( self.name );
450
452
  // preventing multiple call of self.render() when controller is rendering from another required controller
451
453
  if ( localOptions.renderingStack.length > 1 && !isRenderingCustomError ) {
452
454
  return false
453
455
  }
454
-
455
-
456
+
457
+
456
458
  var data = null
457
459
  , layout = null
458
460
  , template = null
459
461
  , file = null
460
462
  , path = null
461
463
  , plugin = null
462
- , isWithoutLayout = (localOptions.isWithoutLayout) ? true : false
464
+ , isWithoutLayout = (localOptions.isWithoutLayout) ? true : false
463
465
  ;
464
-
466
+
465
467
  localOptions.debugMode = ( typeof(displayToolbar) == 'undefined' ) ? undefined : ( (/true/i.test(displayToolbar)) ? true : false ); // only active for dev env
466
-
468
+
467
469
  // specific override
468
470
  if (
469
471
  self.isCacheless()
470
- && typeof(local.req[ local.req.method.toLowerCase() ]) != 'undefined'
471
- && typeof(local.req[ local.req.method.toLowerCase() ].debug) != 'undefined'
472
+ && typeof(local.req[ local.req.method.toLowerCase() ]) != 'undefined'
473
+ && typeof(local.req[ local.req.method.toLowerCase() ].debug) != 'undefined'
472
474
  ) {
473
475
  localOptions.debugMode = ( /true/i.test(local.req[ local.req.method.toLowerCase() ].debug) ) ? true : false;
474
- } else if (
475
- self.isCacheless()
476
+ } else if (
477
+ self.isCacheless()
476
478
  && hasViews()
477
- && !isWithoutLayout
478
- && localOptions.debugMode == undefined
479
+ && !isWithoutLayout
480
+ && localOptions.debugMode == undefined
479
481
  ) {
480
482
  localOptions.debugMode = true;
481
483
  } else if ( localOptions.debugMode == undefined ) {
482
484
  localOptions.debugMode = self.isCacheless()
483
485
  }
484
-
486
+
485
487
  try {
486
488
  data = getData();
487
-
489
+
488
490
  if (!userData) {
489
491
  userData = { page: { view: {}}}
490
492
  } else if ( userData && !userData['page']) {
@@ -502,7 +504,7 @@ function SuperController(options) {
502
504
  if ( isWithoutLayout ) {
503
505
  localTemplateConf = JSON.clone(localOptions.template);
504
506
  localTemplateConf.javascripts = new Collection(localTemplateConf.javascripts).find({ isCommon: false}, { isCommon: true, name: 'gina' });
505
- localTemplateConf.stylesheets = new Collection(localTemplateConf.stylesheets).find({ isCommon: false}, { isCommon: true, name: 'gina' });
507
+ localTemplateConf.stylesheets = new Collection(localTemplateConf.stylesheets).find({ isCommon: false}, { isCommon: true, name: 'gina' });
506
508
  }
507
509
  setResources(localTemplateConf);
508
510
  // Allowing file & ext override
@@ -512,13 +514,13 @@ function SuperController(options) {
512
514
  ) {
513
515
  data.page.view.file = localOptions.file = local.req.routing.param.file
514
516
  }
515
- if (
516
- typeof(local.req.routing.param.ext) != 'undefined'
517
+ if (
518
+ typeof(local.req.routing.param.ext) != 'undefined'
517
519
  && data.page.view.ext !== local.req.routing.param.ext
518
520
  ) {
519
521
  data.page.view.ext = localOptions.template.ext = local.req.routing.param.ext
520
522
  }
521
-
523
+
522
524
  file = (isRenderingCustomError) ? localOptions.file : data.page.view.file;
523
525
 
524
526
  // pre-compiling variables
@@ -527,13 +529,13 @@ function SuperController(options) {
527
529
  if (typeof(data.page.data) == 'undefined' ) {
528
530
  data.page.data = {}
529
531
  }
530
-
531
532
 
532
- if (
533
+
534
+ if (
533
535
  !local.options.isRenderingCustomError
534
- && typeof(data.page.data.status) != 'undefined'
535
- && !/^2/.test(data.page.data.status)
536
- && typeof(data.page.data.error) != 'undefined'
536
+ && typeof(data.page.data.status) != 'undefined'
537
+ && !/^2/.test(data.page.data.status)
538
+ && typeof(data.page.data.error) != 'undefined'
537
539
  ) {
538
540
  var statusCode = localOptions.conf.server.coreConfiguration.statusCodes;
539
541
  var errorObject = {
@@ -555,7 +557,7 @@ function SuperController(options) {
555
557
  // excepted for custom paths
556
558
  if ( !/^(\.|\/|\\)/.test(file) )
557
559
  file = ''+ file.replace(localOptions.namespace+'-', '');
558
-
560
+
559
561
  // means that rule name === namespace -> pointing to root namespace dir
560
562
  if (!file || file === localOptions.namespace) {
561
563
  file = 'index'
@@ -593,14 +595,14 @@ function SuperController(options) {
593
595
  dic['page.'+d] = data.page[d]
594
596
  }
595
597
 
596
-
598
+
597
599
 
598
600
  // please, do not start with a slashe when including...
599
601
  // ex.:
600
602
  // /html/inc/_partial.html (BAD)
601
603
  // html/inc/_partial.html (GOOD)
602
604
  // ./html/namespace/page.html (GOOD)
603
-
605
+
604
606
  if ( !fs.existsSync(path) ) {
605
607
  msg = 'could not open "'+ path +'"' +
606
608
  '\n1) The requested file does not exists in your templates/html (check your template directory). Can you find: '+path +
@@ -614,32 +616,32 @@ function SuperController(options) {
614
616
  self.throwError(err);
615
617
  return;
616
618
  }
617
-
618
- var isProxyHost = (
619
- typeof(local.req.headers.host) != 'undefined'
620
- && localOptions.conf.server.scheme +'://'+ local.req.headers.host != localOptions.conf.hostname
621
- || typeof(local.req.headers[':authority']) != 'undefined'
622
- && localOptions.conf.server.scheme +'://'+ local.req.headers[':authority'] != localOptions.conf.hostname
619
+
620
+ var isProxyHost = (
621
+ typeof(local.req.headers.host) != 'undefined'
622
+ && localOptions.conf.server.scheme +'://'+ local.req.headers.host != localOptions.conf.hostname
623
+ || typeof(local.req.headers[':authority']) != 'undefined'
624
+ && localOptions.conf.server.scheme +'://'+ local.req.headers[':authority'] != localOptions.conf.hostname
623
625
  ) ? true : false;
624
- // setup swig default filters
626
+ // setup swig default filters
625
627
  var filters = SwigFilters({
626
628
  options : JSON.clone(localOptions),
627
629
  isProxyHost : isProxyHost,
628
630
  throwError : self.throwError,
629
631
  req : local.req,
630
- res : local.res
632
+ res : local.res
631
633
  });
632
634
 
633
635
  try {
634
-
636
+
635
637
  // Extends default `length` filter
636
638
  swig.setFilter('length', filters.length);
637
639
 
638
-
640
+
639
641
 
640
642
  // Allows you to get a bundle web root
641
643
  swig.setFilter('getWebroot', filters.getWebroot);
642
-
644
+
643
645
  swig.setFilter('getUrl', filters.getUrl);
644
646
 
645
647
  } catch (err) {
@@ -651,10 +653,10 @@ function SuperController(options) {
651
653
  self.throwError(local.res, 500, new Error('template compilation exception encoutered: [ '+path+' ]\n'+(err.stack||err.message)));
652
654
  return;
653
655
  }
654
-
655
-
656
-
657
- var layoutPath = null
656
+
657
+
658
+
659
+ var layoutPath = null
658
660
  , assets = null
659
661
  , mapping = null
660
662
  , XHRData = null
@@ -665,26 +667,26 @@ function SuperController(options) {
665
667
  , isWithSwigLayout = null
666
668
  , isUsingGinaLayout = (!isWithoutLayout && typeof(localOptions.template.layout) != 'undefined' && fs.existsSync(local.options.template.layout)) ? true : false
667
669
  ;
668
-
670
+
669
671
  if ( isWithoutLayout || isUsingGinaLayout ) {
670
672
  layoutPath = (isWithoutLayout) ? localOptions.template.noLayout : localOptions.template.layout;
671
673
  // user layout override
672
674
  if ( isUsingGinaLayout && !isWithoutLayout ) {
673
675
  layoutPath = localOptions.template.layout;
674
- }
676
+ }
675
677
  if (isWithoutLayout) {
676
678
  data.page.view.layout = layoutPath;
677
- }
679
+ }
678
680
  } else { // without layout case
679
-
681
+
680
682
  // by default
681
683
  layoutPath = localOptions.template.layout;
682
684
  if ( !/^\//.test(layoutPath)) {
683
685
  layoutPath = localOptions.template.templates +'/'+ layoutPath;
684
686
  }
685
687
  // default layout
686
- if (
687
- !isWithoutLayout && !fs.existsSync(layoutPath) && layoutPath == localOptions.template.templates +'/index.html'
688
+ if (
689
+ !isWithoutLayout && !fs.existsSync(layoutPath) && layoutPath == localOptions.template.templates +'/index.html'
688
690
  ) {
689
691
  console.warn('Layout '+ local.options.template.layout +' not found, replacing with `nolayout`: '+ localOptions.template.noLayout);
690
692
  layoutPath = localOptions.template.noLayout
@@ -703,26 +705,26 @@ function SuperController(options) {
703
705
  self.throwError(err);
704
706
  return;
705
707
  }
706
-
708
+
707
709
  }
708
-
709
-
710
+
711
+
710
712
  var isLoadingPartial = false;
711
- try {
713
+ try {
712
714
  assets = {assets:"${assets}"};
713
-
715
+
714
716
  /**
715
717
  * retrieve template & layout
716
- * */
717
- var tpl = null;
718
+ * */
719
+ var tpl = null;
718
720
  // tpl = fs.readFileSync(path).toString();
719
- // layout = fs.readFileSync(layoutPath).toString();
720
-
721
+ // layout = fs.readFileSync(layoutPath).toString();
722
+
721
723
  await Promise.all([
722
724
  readFile(layoutPath),
723
725
  readFile(path)
724
726
  ])
725
- .then(([_layout, _tpl]) => {
727
+ .then(([_layout, _tpl]) => {
726
728
  layout = _layout.toString();
727
729
  tpl = _tpl.toString();
728
730
  })
@@ -730,30 +732,30 @@ function SuperController(options) {
730
732
  console.error(error.message);
731
733
  return;
732
734
  });
733
-
734
-
735
+
736
+
735
737
  // mappin conf
736
738
  mapping = { filename: path };
737
739
  if (isRenderingCustomError) {
738
740
  // TODO - Test if there is a block call `gina-error` in the layout & replace block name from tpl
739
-
741
+
740
742
  if ( !/\{\%(\s+extends|extends)/.test(tpl) ) {
741
743
  tpl = "\n{% extends '"+ layoutPath +"' %}\n" + tpl;
742
744
  }
743
745
  if (!/\{\% block content/.test(tpl)) {
744
746
  // TODO - test if lyout has <body>
745
747
  tpl = '{% block content %}<p>If you view this message you didn’t define a content block in your template.</p>{% endblock %}' + tpl;
746
- }
747
-
748
+ }
749
+
748
750
  tpl = tpl.replace(/\{\{ page\.content \}\}/g, '');
749
751
  }
750
-
752
+
751
753
  if ( isWithoutLayout || isWithSwigLayout) {
752
- layout = tpl;
754
+ layout = tpl;
753
755
  } else if (isUsingGinaLayout) {
754
756
  mapping = { filename: path };
755
757
  if ( /(\{\{|\{\{\s+)page\.content/.test(layout) ) {
756
-
758
+
757
759
  if ( /\{\%(\s+extends|extends)/.test(tpl) ) {
758
760
  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');
759
761
  self.throwError(local.res, 500, err);
@@ -761,9 +763,9 @@ function SuperController(options) {
761
763
  }
762
764
  layout = layout.replace('{{ page.content }}', tpl);
763
765
  } else {
764
- layout = layout.replace(/\<\/body\>/i, '\t'+tpl+'\n</body>');
766
+ layout = layout.replace(/\<\/body\>/i, '\t'+tpl+'\n</body>');
765
767
  }
766
-
768
+
767
769
  } else {
768
770
  tpl = tpl.replace('{{ page.view.layout }}', data.page.view.layout);
769
771
  if (/\<\/body\>/i.test(layout)) {
@@ -771,78 +773,78 @@ function SuperController(options) {
771
773
  }
772
774
  else {
773
775
  layout += tpl;
774
- }
776
+ }
775
777
  }
776
-
778
+
777
779
  // precompilation needed in case of `extends` or in order to display the toolbar
778
- if ( hasViews() && self.isCacheless() || /\{\%(\s+extends|extends)/.test(layout) ) {
780
+ if ( hasViews() && self.isCacheless() || /\{\%(\s+extends|extends)/.test(layout) ) {
779
781
  layout = swig.compile(layout, mapping)(data);
780
782
  }
781
- //dic['page.content'] = layout;
782
-
783
+ //dic['page.content'] = layout;
784
+
783
785
  } catch(err) {
784
786
  err.stack = 'Exception, bad syntax or undefined data found: start investigating in '+ mapping.filename +'\n' + err.stack;
785
787
  self.throwError(local.res, 500, err);
786
788
  return
787
789
  }
788
-
789
- isLoadingPartial = (
790
- !/\<html/i.test(layout)
791
- || !/\<head/i.test(layout)
792
- || !/\<body/i.test(layout)
790
+
791
+ isLoadingPartial = (
792
+ !/\<html/i.test(layout)
793
+ || !/\<head/i.test(layout)
794
+ || !/\<body/i.test(layout)
793
795
  ) ? true : false;
794
-
796
+
795
797
  // if (isLoadingPartial) {
796
798
  // console.warn('----------------> loading partial `'+ path);
797
799
  // }
798
-
799
- isDeferModeEnabled = localOptions.template.javascriptsDeferEnabled || localOptions.conf.content.templates._common.javascriptsDeferEnabled || false;
800
-
800
+
801
+ isDeferModeEnabled = localOptions.template.javascriptsDeferEnabled || localOptions.conf.content.templates._common.javascriptsDeferEnabled || false;
802
+
801
803
  // iframe case - without HTML TAG
802
804
  if (!self.isXMLRequest() && !/\<html/.test(layout) ) {
803
805
  layout = '<html>\n\t<head></head>\n\t<body class="gina-iframe-body">\n\t\t'+ layout +'\n\t</body>\n</html>';
804
- }
805
-
806
+ }
807
+
806
808
  // adding stylesheets
807
809
  if (!isWithoutLayout && data.page.view.stylesheets && !/\{\{\s+(page\.view\.stylesheets)\s+\}\}/.test(layout) ) {
808
810
  layout = layout.replace(/\<\/head\>/i, '\n\t{{ page.view.stylesheets }}\n</head>')
809
811
  }
810
-
812
+
811
813
  if (hasViews() && isWithoutLayout) {
812
814
  // $.getScript(...)
813
815
  //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;
814
816
  //var hostname = (isProxyHost) ? localOptions.conf.hostname.replace(/\:\d+$/, '') : localOptions.conf.hostname;
815
-
816
-
817
-
817
+
818
+
819
+
818
820
  var scripts = data.page.view.scripts;
819
821
  scripts = scripts.replace(/\s+\<script/g, '\n<script');
820
-
822
+
821
823
  if (!isProxyHost) {
822
824
  var webroot = data.page.environment.webroot;
823
825
  scripts = scripts.replace(/src\=\"\/(.*)\"/g, 'src="'+ webroot +'$1"');
824
826
  //stylesheets = stylesheets.replace(/href\=\"\/(.*)\"/g, 'href="'+ webroot +'$1"')
825
827
  }
826
-
828
+
827
829
  // iframe case - without HTML TAG
828
- if (self.isXMLRequest() || !/\<html/.test(layout) ) {
829
- layout += scripts;
830
- //layout += stylesheets;
831
- }
832
-
830
+ if (self.isXMLRequest() || !/\<html/.test(layout) ) {
831
+ layout += scripts;
832
+ //layout += stylesheets;
833
+ }
834
+
833
835
  }
834
836
 
835
837
  // adding plugins
836
-
837
-
838
+
839
+
838
840
  if (
839
- hasViews() && self.isCacheless() && !isWithoutLayout
840
- && localOptions.debugMode
841
- ||
842
- hasViews() && self.isCacheless() && !isWithoutLayout
843
- && typeof(localOptions.debugMode) == 'undefined'
844
- ||
845
- hasViews() && localOptions.debugMode
841
+ hasViews() && self.isCacheless() && !isWithoutLayout
842
+ && localOptions.debugMode
843
+ ||
844
+ hasViews() && self.isCacheless() && !isWithoutLayout
845
+ && typeof(localOptions.debugMode) == 'undefined'
846
+ ||
847
+ hasViews() && localOptions.debugMode
846
848
  ) {
847
849
 
848
850
  layout = ''
@@ -852,52 +854,52 @@ function SuperController(options) {
852
854
  + '{%- set ginaDataInspector.view.stylesheets = "ignored-by-toolbar" -%}'
853
855
  + layout
854
856
  ;
855
-
857
+
856
858
  plugin = '\t'
857
859
  + '{# Gina Toolbar #}'
858
860
  + '{%- set userDataInspector = JSON.clone(page) -%}'
859
861
  + '{%- set userDataInspector.view.scripts = "ignored-by-toolbar" -%}'
860
862
  + '{%- set userDataInspector.view.stylesheets = "ignored-by-toolbar" -%}'
861
863
  + '{%- set userDataInspector.view.assets = '+ JSON.stringify(assets) +' -%}'
862
- + '{%- include "'+ getPath('gina').core +'/asset/js/plugin/src/gina/toolbar/toolbar.html" with { gina: ginaDataInspector, user: userDataInspector } -%}'
863
- + '{# END Gina Toolbar #}'
864
+ + '{%- include "'+ getPath('gina').core +'/asset/plugin/dist/toolbar/toolbar.html" with { gina: ginaDataInspector, user: userDataInspector } -%}'// jshint ignore:line
865
+ + '{# END Gina Toolbar #}'
864
866
  ;
865
-
867
+
866
868
 
867
869
  if (isWithoutLayout && localOptions.debugMode || localOptions.debugMode ) {
868
870
 
869
871
  XHRData = '\t<input type="hidden" id="gina-without-layout-xhr-data" value="'+ encodeURIComponent(JSON.stringify(data.page.data)) +'">\n\r';
870
-
872
+
871
873
  layout = layout.replace(/<\/body>/i, XHRData + '\n\t</body>');
872
874
  }
873
-
875
+
874
876
  if (self.isCacheless() || localOptions.debugMode ) {
875
877
  layout = layout.replace(/<\/body>/i, plugin + '\n\t</body>');
876
878
  }
877
-
879
+
878
880
  // adding javascripts
879
- layout.replace('{{ page.view.scripts }}', '');
881
+ layout.replace('{{ page.view.scripts }}', '');
880
882
  // placed in the HEAD excepted when rendering a partial or when `isDeferModeEnabled` == true
881
883
  if (isLoadingPartial) {
882
884
  layout += '\t{{ page.view.scripts }}';
883
885
  } else {
884
886
  if ( isDeferModeEnabled ) {
885
887
  layout = layout.replace(/\<\/head\>/i, '\t{{ page.view.scripts }}\n\t</head>');
886
- } else { // placed in the BODY
888
+ } else { // placed in the BODY
887
889
  layout = layout.replace(/\<\/body\>/i, '\t{{ page.view.scripts }}\n</body>');
888
890
  }
889
891
  }
890
-
892
+
891
893
  // ginaLoader cannot be deferred
892
894
  if ( !localOptions.template.javascriptsExcluded || localOptions.template.javascriptsExcluded != '**' ) {
893
- layout = layout.replace(/\<\/head\>/i, '\t'+ localOptions.template.ginaLoader +'\n</head>');
895
+ layout = layout.replace(/\<\/head\>/i, '\t'+ localOptions.template.ginaLoader +'\n</head>');
894
896
  }
895
897
 
896
898
  } else if ( hasViews() && self.isCacheless() && self.isXMLRequest() ) {
897
-
898
- if (isWithoutLayout) {
899
+
900
+ if (isWithoutLayout) {
899
901
  delete data.page.view.scripts;
900
- delete data.page.view.stylesheets;
902
+ delete data.page.view.stylesheets;
901
903
  }
902
904
  // means that we don't want GFF context or we already have it loaded
903
905
  viewInfos = JSON.clone(data.page.view);
@@ -911,38 +913,38 @@ function SuperController(options) {
911
913
  layout += XHRData + XHRView;
912
914
 
913
915
  } else { // other envs like prod ...
914
-
916
+
915
917
  // adding javascripts
916
918
  // cleanup first
917
- layout.replace('{{ page.view.scripts }}', '');
919
+ layout.replace('{{ page.view.scripts }}', '');
918
920
  // placed in the HEAD excepted when rendering a partial or when `isDeferModeEnabled` == true
919
921
  // if (isLoadingPartial) {
920
922
  // layout += '\t{{ page.view.scripts }}';
921
923
  // } else {
922
924
  // if ( isDeferModeEnabled ) {
923
925
  // layout = layout.replace(/\<\/head\>/i, '\t{{ page.view.scripts }}\n\t</head>');
924
- // } else { // placed in the BODY
926
+ // } else { // placed in the BODY
925
927
  // layout = layout.replace(/\<\/body\>/i, '\t{{ page.view.scripts }}\n</body>');
926
928
  // }
927
929
  // }
928
-
930
+
929
931
  // // ginaLoader cannot be deferred
930
932
  // if ( !localOptions.template.javascriptsExcluded || localOptions.template.javascriptsExcluded != '**' ) {
931
- // layout = layout.replace(/\<\/head\>/i, '\t'+ localOptions.template.ginaLoader +'\n</head>');
933
+ // layout = layout.replace(/\<\/head\>/i, '\t'+ localOptions.template.ginaLoader +'\n</head>');
932
934
  // }
933
-
935
+
934
936
  // adding javascripts
935
937
  layout.replace('{{ page.view.scripts }}', '');
936
- if (isLoadingPartial) {
938
+ if (isLoadingPartial) {
937
939
  layout += '\t{{ page.view.scripts }}\n';
938
940
  if ( !localOptions.template.javascriptsExcluded || localOptions.template.javascriptsExcluded != '**' ) {
939
941
  layout += '\t'+ localOptions.template.ginaLoader +'\n';
940
942
  }
941
943
  } else {
942
- if ( isDeferModeEnabled && /\<\/head\>/i.test(layout) ) { // placed in the HEAD
944
+ if ( isDeferModeEnabled && /\<\/head\>/i.test(layout) ) { // placed in the HEAD
943
945
  layout = layout.replace(/\<\/head\>/i, '\t{{ page.view.scripts }}\n\t</head>');
944
-
945
- } else { // placed in the BODY
946
+
947
+ } else { // placed in the BODY
946
948
  layout = layout.replace(/\<\/body\>/i, '\t{{ page.view.scripts }}\n</body>');
947
949
  }
948
950
  // ginaLoader cannot be deferred
@@ -951,20 +953,20 @@ function SuperController(options) {
951
953
  }
952
954
  }
953
955
  }
954
-
955
-
956
+
957
+
956
958
  layout = whisper(dic, layout, /\{{ ([a-zA-Z.]+) \}}/g );
957
959
  dic['page.content'] = layout;
958
960
  /**
959
961
  // special case for template without layout in debug mode - dev only
960
962
  if ( hasViews() && localOptions.debugMode && self.isCacheless() && !/\{\# Gina Toolbar \#\}/.test(layout) ) {
961
- try {
962
-
963
- layout = layout.replace(/<\/body>/i, plugin + '\n\t</body>');
963
+ try {
964
+
965
+ layout = layout.replace(/<\/body>/i, plugin + '\n\t</body>');
964
966
  layout = whisper(dic, layout, /\{{ ([a-zA-Z.]+) \}}/g );
965
967
  //swig.invalidateCache();
966
968
  layout = swig.compile(layout, mapping)(data);
967
-
969
+
968
970
 
969
971
  } catch (err) {
970
972
  filename = localOptions.template.html;
@@ -972,7 +974,7 @@ function SuperController(options) {
972
974
  self.throwError(local.res, 500, new Error('Compilation error encountered while trying to process template `'+ filename + '`\n'+(err.stack||err.message)));
973
975
  return;
974
976
  }
975
- }
977
+ }
976
978
  else if (hasViews() && localOptions.debugMode && self.isCacheless()) {
977
979
  try {
978
980
  //layout = whisper(dic, layout, /\{{ ([a-zA-Z.]+) \}}/g );
@@ -983,9 +985,9 @@ function SuperController(options) {
983
985
  self.throwError(local.res, 500, new Error('Compilation error encountered while trying to process template `'+ filename + '`\n'+(err.stack||err.message)));
984
986
  return;
985
987
  }
986
- }
987
- */
988
-
988
+ }
989
+ */
990
+
989
991
 
990
992
  if ( !local.res.headersSent ) {
991
993
  local.res.statusCode = ( typeof(localOptions.conf.server.coreConfiguration.statusCodes[data.page.data.status]) != 'undefined' ) ? data.page.data.status : 200; // by default
@@ -1004,62 +1006,63 @@ function SuperController(options) {
1004
1006
  }
1005
1007
 
1006
1008
  local.res.setHeader('content-type', localOptions.conf.server.coreConfiguration.mime['html'] + '; charset='+ localOptions.conf.encoding );
1007
-
1009
+
1008
1010
  try {
1009
-
1011
+
1010
1012
  // escape special chars
1011
1013
  var blacklistRe = new RegExp('[\<\>]', 'g');
1012
1014
  // DO NOT REPLACE IT BY JSON.clone() !!!!
1013
-
1015
+
1014
1016
  data.page.data = JSON.parse(JSON.stringify(data.page.data).replace(blacklistRe, '\$&'));
1015
-
1017
+
1016
1018
  } catch (err) {
1017
1019
  filename = localOptions.template.html;
1018
1020
  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: '' );
1019
1021
  self.throwError(local.res, 500, new Error('Controller::render(...) compilation error encountered while trying to process template `'+ filename + '`\n' + (err.stack||err.message||err) ));
1020
1022
  return;
1021
1023
  }
1022
-
1023
-
1024
+
1025
+
1024
1026
  // Only available for http/2.0 for now
1025
1027
  if ( !self.isXMLRequest() && /http\/2/.test(localOptions.conf.server.protocol) ) {
1026
1028
  try {
1027
- // TODO - button in toolbar to empty url assets cache
1029
+ // TODO - button in toolbar to empty url assets cache
1028
1030
  if ( /** self.isCacheless() ||*/ typeof(localOptions.template.assets) == 'undefined' || typeof(localOptions.template.assets[local.req.url]) == 'undefined' ) {
1029
1031
  // assets string -> object
1030
1032
  //assets = self.serverInstance.getAssets(localOptions.conf, layout.toString(), swig, data);
1031
1033
  assets = self.serverInstance.getAssets(localOptions.conf, layout, swig, data);
1032
1034
  localOptions.template.assets = JSON.parse(assets);
1033
1035
  }
1034
-
1036
+
1035
1037
  // only for toolbar - TODO hasToolbar()
1036
1038
  if (
1037
1039
  self.isCacheless() && hasViews() && !isWithoutLayout
1038
1040
  || hasViews() && localOptions.debugMode
1039
- || self.isCacheless() && hasViews() && self.isXMLRequest()
1040
- ) {
1041
- layout = layout.replace('{"assets":"${assets}"}', assets );
1041
+ || self.isCacheless() && hasViews() && self.isXMLRequest()
1042
+ ) {
1043
+ layout = layout.replace('{"assets":"${assets}"}', assets );
1042
1044
  }
1043
-
1045
+
1044
1046
  } catch (err) {
1045
1047
  self.throwError(local.res, 500, new Error('Controller::render(...) calling getAssets(...) \n' + (err.stack||err.message||err) ));
1046
1048
  return;
1047
1049
  }
1048
1050
  }
1049
-
1050
- // Last compilation before rendering
1051
- layout = swig.compile(layout, mapping)(data);
1052
-
1051
+
1052
+ // Last compilation before rendering
1053
+ layout = swig.compile(layout, mapping)(data);
1054
+
1053
1055
  if ( !local.res.headersSent ) {
1054
1056
  if ( local.options.isRenderingCustomError ) {
1055
1057
  local.options.isRenderingCustomError = false;
1056
1058
  }
1059
+
1057
1060
  local.res.end(layout);
1058
- }
1059
-
1061
+ }
1062
+
1060
1063
  console.info(local.req.method +' ['+local.res.statusCode +'] '+ local.req.url);
1061
-
1062
- } else if (typeof(local.next) != 'undefined') {
1064
+
1065
+ } else if (typeof(local.next) != 'undefined') {
1063
1066
  // local.next();
1064
1067
  return local.next();
1065
1068
  } else {
@@ -1075,7 +1078,7 @@ function SuperController(options) {
1075
1078
  return;
1076
1079
  }
1077
1080
  }
1078
-
1081
+
1079
1082
 
1080
1083
  this.isXMLRequest = function() {
1081
1084
  return local.options.isXMLRequest;
@@ -1102,21 +1105,21 @@ function SuperController(options) {
1102
1105
  return false
1103
1106
  }
1104
1107
  if ( self.isProcessingError ) {
1105
- return;
1108
+ return;
1106
1109
  }
1107
1110
 
1108
1111
  var request = local.req;
1109
1112
  var response = local.res;
1110
1113
  var next = local.next || null;
1111
1114
  // var stream = null;
1112
- // if ( /http\/2/.test(local.options.conf.server.protocol) ) {
1113
- // stream = response.stream;
1115
+ // if ( /http\/2/.test(local.options.conf.server.protocol) ) {
1116
+ // stream = response.stream;
1114
1117
  // }
1115
1118
 
1116
1119
  if (!jsonObj) {
1117
1120
  jsonObj = {}
1118
1121
  }
1119
-
1122
+
1120
1123
  try {
1121
1124
  // just in case
1122
1125
  if ( typeof(jsonObj) == 'string') {
@@ -1126,7 +1129,7 @@ function SuperController(options) {
1126
1129
  // if( typeof(local.options) != "undefined" && typeof(local.options.charset) != "undefined" ){
1127
1130
  // response.setHeader("charset", local.options.charset);
1128
1131
  // }
1129
-
1132
+
1130
1133
 
1131
1134
  //catching errors
1132
1135
  if (
@@ -1164,17 +1167,17 @@ function SuperController(options) {
1164
1167
  } else {
1165
1168
  len = data.length
1166
1169
  }
1167
-
1170
+
1168
1171
  if (!response.headersSent)
1169
1172
  response.setHeader("content-length", len);
1170
-
1171
-
1173
+
1174
+
1172
1175
  // if (stream && !stream.destroyed) {
1173
1176
  // //stream.respond(header);
1174
1177
  // stream.end(data);
1175
1178
  // } else {
1176
1179
  response.write(data);
1177
-
1180
+
1178
1181
  // required to close connection
1179
1182
  setTimeout(function () {
1180
1183
  response.end();
@@ -1184,17 +1187,17 @@ function SuperController(options) {
1184
1187
  // Ignoring warning
1185
1188
  //console.warn(err);
1186
1189
  }
1187
-
1190
+
1188
1191
  if ( next ) {
1189
1192
  next()
1190
1193
  }
1191
1194
  }, 200);
1192
-
1193
-
1194
-
1195
+
1196
+
1197
+
1195
1198
  return // force completion
1196
1199
  // }
1197
-
1200
+
1198
1201
 
1199
1202
  } else { // normal case
1200
1203
  response.end(JSON.stringify(jsonObj));
@@ -1209,7 +1212,7 @@ function SuperController(options) {
1209
1212
  if ( next ) {
1210
1213
  next()
1211
1214
  }
1212
-
1215
+
1213
1216
  return;
1214
1217
  }
1215
1218
  }
@@ -1324,24 +1327,24 @@ function SuperController(options) {
1324
1327
  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));
1325
1328
  return;
1326
1329
  }
1327
-
1330
+
1328
1331
  var authority = ( typeof(local.req.headers['x-forwarded-proto']) != 'undefined' ) ? local.req.headers['x-forwarded-proto'] : local.options.conf.server.scheme;
1329
1332
  authority += '://'+ local.req.headers.host;
1330
1333
  var useWebroot = false;
1331
1334
  if ( !/^\/$/.test(local.options.conf.server.webroot) && local.options.conf.server.webroot.length > 0 && local.options.conf.hostname.replace(/\:\d+$/, '') == authority ) {
1332
1335
  useWebroot = true
1333
1336
  }
1334
-
1337
+
1335
1338
  var reURL = new RegExp('^'+ local.options.conf.server.webroot);
1336
1339
 
1337
1340
  var cssStr = '', jsStr = '';
1338
-
1341
+
1339
1342
  //Get css
1340
1343
  if( viewConf.stylesheets ) {
1341
1344
  cssStr = getNodeRes('css', viewConf.stylesheets, useWebroot, reURL)
1342
1345
  }
1343
1346
  //Get js
1344
- if( viewConf.javascripts ) {
1347
+ if( viewConf.javascripts ) {
1345
1348
  jsStr = getNodeRes('js', viewConf.javascripts, useWebroot, reURL)
1346
1349
  }
1347
1350
 
@@ -1362,7 +1365,7 @@ function SuperController(options) {
1362
1365
  * @private
1363
1366
  * */
1364
1367
  var getNodeRes = function(type, resArr, useWebroot, reURL) {
1365
-
1368
+
1366
1369
  var r = 0
1367
1370
  , rLen = resArr.length
1368
1371
  , obj = null
@@ -1370,7 +1373,7 @@ function SuperController(options) {
1370
1373
  ;
1371
1374
  switch(type){
1372
1375
  case 'css':
1373
- for (; r < rLen; ++r) {
1376
+ for (; r < rLen; ++r) {
1374
1377
  obj = resArr[r];
1375
1378
  if (useWebroot && !reURL.test(obj.url) ) {
1376
1379
  obj.url = local.options.conf.server.webroot + obj.url.substr(1);
@@ -1378,32 +1381,32 @@ function SuperController(options) {
1378
1381
  // TODO - add support for cdn
1379
1382
  if (!/\:\/\//.test(obj.url) ) {
1380
1383
  obj.url = local.options.conf.hostname + obj.url;
1381
- }
1382
-
1384
+ }
1385
+
1383
1386
  if (obj.media)
1384
- str += '\n\t\t<link href="'+ obj.url +'" media="'+ obj.media +'" rel="'+ obj.rel +'" type="'+ obj.type +'">';
1387
+ str += '\n\t\t<link href="'+ obj.url +'" media="'+ obj.media +'" rel="'+ obj.rel +'" type="'+ obj.type +'">';
1385
1388
  else
1386
- str += '\n\t\t<link href="'+ obj.url +'" rel="'+ obj.rel +'" type="'+ obj.type +'">';
1389
+ str += '\n\t\t<link href="'+ obj.url +'" rel="'+ obj.rel +'" type="'+ obj.type +'">';
1387
1390
  }
1388
-
1391
+
1389
1392
  return str;
1390
1393
  break;
1391
1394
 
1392
1395
  case 'js':
1393
1396
  var deferMode = (local.options.template.javascriptsDeferEnabled) ? ' defer' : '';
1394
-
1397
+
1395
1398
  for (; r < rLen; ++r) {
1396
1399
  obj = resArr[r];
1397
1400
  if (useWebroot && !reURL.test(obj.url) ) {
1398
1401
  obj.url = local.options.conf.server.webroot + obj.url.substr(1);
1399
1402
  }
1400
- // TODO - add support for cdn
1403
+ // TODO - add support for cdn
1401
1404
  if (!/\:\/\//.test(obj.url) ) {
1402
1405
  obj.url = local.options.conf.hostname + obj.url;
1403
1406
  }
1404
- str += '\n\t\t<script'+ deferMode +' type="'+ obj.type +'" src="'+ obj.url +'"></script>'
1407
+ str += '\n\t\t<script'+ deferMode +' type="'+ obj.type +'" src="'+ obj.url +'"></script>'
1405
1408
  }
1406
-
1409
+
1407
1410
  return str;
1408
1411
  break;
1409
1412
  }
@@ -1419,17 +1422,17 @@ function SuperController(options) {
1419
1422
  var getData = function() {
1420
1423
  return refToObj( local.userData )
1421
1424
  }
1422
-
1425
+
1423
1426
 
1424
1427
  var isValidURL = function(url){
1425
1428
  var re = /(http|ftp|https|sftp):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&amp;:\/~+#-]*[\w@?^=%&amp;\/~+#-])?/;
1426
1429
  return (re.test(url)) ? true : false
1427
1430
  }
1428
-
1431
+
1429
1432
  /**
1430
- * Set method - Override current method
1433
+ * Set method - Override current method
1431
1434
  * E.g.: in case of redirect, to force PUT to GET
1432
- *
1435
+ *
1433
1436
  * @param {string} requestMethod - GET, POST, PUT, DELETE
1434
1437
  */
1435
1438
  var localRequestMethod = null, localRequestMethodParams = null;
@@ -1438,66 +1441,66 @@ function SuperController(options) {
1438
1441
  if ( /http\/2/i.test(conf.server.protocolShort) ) {
1439
1442
  local.req.headers[':method'] = local.req.method.toUpperCase()
1440
1443
  }
1441
-
1444
+
1442
1445
  localRequestMethod = local.req.method = local.req.routing.method = requestMethod.toUpperCase();
1443
-
1446
+
1444
1447
  local.res.setHeader('access-control-allow-methods', localRequestMethod);
1445
-
1446
- return localRequestMethod;
1448
+
1449
+ return localRequestMethod;
1447
1450
  }
1448
-
1451
+
1449
1452
  this.getRequestMethod = function() {
1450
1453
  return localRequestMethod;
1451
1454
  }
1452
-
1455
+
1453
1456
  this.setRequestMethodParams = function(params) {
1454
1457
  localRequestMethodParams = local.req[local.req.method.toLowerCase()] = localRequestMethodParams = params
1455
1458
  }
1456
-
1459
+
1457
1460
  this.getRequestMethodParams = function() {
1458
1461
  return (localRequestMethodParams) ? localRequestMethodParams : local.req[local.req.method.toLowerCase()]
1459
1462
  }
1460
-
1463
+
1461
1464
  /**
1462
1465
  * isStaticRoute
1463
1466
  * Trying to determine if url is a `statics` ressource
1464
- *
1467
+ *
1465
1468
  * @param {string} url
1466
1469
  * @param {string} method
1467
- *
1470
+ *
1468
1471
  * @returns {boolean} isStaticRoute
1469
1472
  */
1470
1473
  var isStaticRoute = function(url, method, bundle, env, conf) {
1471
-
1474
+
1472
1475
  if ( !/get/i.test(method) ) {
1473
1476
  return false
1474
1477
  }
1475
-
1478
+
1476
1479
  // priority to statics - this portion of code has been duplicated to Server.js
1477
-
1480
+
1478
1481
  var staticsArr = conf[bundle][env].publicResources;
1479
1482
  var staticProps = {
1480
1483
  firstLevel : '/' + url.split(/\//g)[1] + '/',
1481
1484
  // to be considered as a stativ content, url must content at least 2 caracters after last `.`: .js, .html are ok
1482
1485
  isStaticFilename : /(\.([A-Za-z0-9]+){2}|\/)$/.test(url)
1483
- };
1484
-
1486
+ };
1487
+
1485
1488
  // handle resources from public with webroot in url
1486
1489
  if ( staticProps.isStaticFilename && conf[bundle][env].server.webroot != '/' && staticProps.firstLevel == conf[bundle][env].server.webroot ) {
1487
1490
  var matchedFirstInUrl = url.replace(conf[bundle][env].server.webroot, '').match(/[A-Za-z0-9_-]+\/?/);
1488
1491
  if ( matchedFirstInUrl && matchedFirstInUrl.length > 0 ) {
1489
1492
  staticProps.firstLevel = conf[bundle][env].server.webroot + matchedFirstInUrl[0]
1490
- }
1493
+ }
1491
1494
  }
1492
-
1493
- if (
1494
- staticProps.isStaticFilename && staticsArr.indexOf(url) > -1
1495
- || staticProps.isStaticFilename && staticsArr.indexOf( url.replace(url.substr(url.lastIndexOf('/')+1), '') ) > -1
1495
+
1496
+ if (
1497
+ staticProps.isStaticFilename && staticsArr.indexOf(url) > -1
1498
+ || staticProps.isStaticFilename && staticsArr.indexOf( url.replace(url.substr(url.lastIndexOf('/')+1), '') ) > -1
1496
1499
  || staticProps.isStaticFilename && staticsArr.indexOf(staticProps.firstLevel) > -1
1497
1500
  ) {
1498
1501
  return true
1499
1502
  }
1500
-
1503
+
1501
1504
  return false;
1502
1505
  }
1503
1506
 
@@ -1506,7 +1509,7 @@ function SuperController(options) {
1506
1509
  *
1507
1510
  * TODO - improve redirect based on `utils.routing`
1508
1511
  * e.g.: self.redirect('project-get', { companyId: companyId, clientId: clientId, id: projectId }, true)
1509
- *
1512
+ *
1510
1513
  * How to avoid redirect inside popin context
1511
1514
  * N.B.: When you are in a popin context, add an `id` to your template tag so it can be ignored by the default PopinHandler
1512
1515
  * E.g.: id="delete-link" -> <a href="#" id="delete-link">delete</a>
@@ -1553,10 +1556,10 @@ function SuperController(options) {
1553
1556
  * `ignoreWebRoot` behaves the like set to `false` by default
1554
1557
  *
1555
1558
  * N.B.: Gina will tell browsers not to cache redirections if you are using `dev` environement
1556
- *
1559
+ *
1557
1560
  * Trobleshouting:
1558
1561
  * ---------------
1559
- *
1562
+ *
1560
1563
  * Redirecting to a popin from the controller while posting from a form
1561
1564
  * If this does not work, like doing a real redirect, this
1562
1565
  * only means that the ID you are using for the form might be
@@ -1567,7 +1570,7 @@ function SuperController(options) {
1567
1570
  * @param {object} [params] TODO
1568
1571
  *
1569
1572
  * @callback [ next ]
1570
- * */
1573
+ * */
1571
1574
  this.redirect = function(req, res, next) {
1572
1575
  var conf = self.getConfig();
1573
1576
  var bundle = conf.bundle;
@@ -1579,14 +1582,14 @@ function SuperController(options) {
1579
1582
  var ignoreWebRoot = null, isRelative = false;
1580
1583
  var originalUrl = null;
1581
1584
  var method = null;
1582
- var originalMethod = null;
1585
+ var originalMethod = null;
1583
1586
 
1584
1587
  if ( typeof(req) === 'string' ) {
1585
1588
 
1586
1589
  // if ( typeof(res) == 'undefined') {
1587
1590
  // // nothing to do
1588
1591
  // ignoreWebRoot = false
1589
- // } else
1592
+ // } else
1590
1593
  if (typeof(res) === 'string' || typeof(res) === 'number' || typeof(res) === 'boolean') {
1591
1594
  if ( /true|1/.test(res) ) {
1592
1595
  ignoreWebRoot = true
@@ -1608,26 +1611,26 @@ function SuperController(options) {
1608
1611
  ignoreWebRoot = false;
1609
1612
  }
1610
1613
  }
1611
-
1614
+
1612
1615
  }
1613
1616
 
1614
1617
  if ( req.substr(0,1) === '/') { // is relative (not checking if the URI is defined in the routing.json)
1615
1618
  // if (wroot.substr(wroot.length-1,1) == '/') {
1616
1619
  // wroot = wroot.substr(wroot.length-1,1).replace('/', '')
1617
1620
  // }
1618
-
1621
+
1619
1622
  if ( /^\//.test(req) && !ignoreWebRoot )
1620
1623
  req = req.substr(1);
1621
-
1624
+
1622
1625
  rte = ( ignoreWebRoot != null && ignoreWebRoot ) ? req : wroot + req;
1623
1626
  // cleaning url in case of ?param=value
1624
- originalUrl = rte;
1627
+ originalUrl = rte;
1625
1628
  rte = rte.replace(/\?(.*)/, '');
1626
-
1629
+
1627
1630
  req = local.req;
1628
- originalMethod = ( typeof(req.originalMethod) != 'undefined') ? req.originalMethod : req.method;
1629
- console.debug('[ BUNDLE ][ '+ local.options.conf.bundle +' ][ Controller ] trying to get route: ', rte, bundle, req.method);
1630
- if ( !ignoreWebRoot || !isStaticRoute(rte, req.method, bundle, env, ctx.config.envConf) && !ignoreWebRoot ) {
1631
+ originalMethod = ( typeof(req.originalMethod) != 'undefined') ? req.originalMethod : req.method;
1632
+ console.debug('[ BUNDLE ][ '+ local.options.conf.bundle +' ][ Controller ] trying to get route: ', rte, bundle, req.method);
1633
+ if ( !ignoreWebRoot || !isStaticRoute(rte, req.method, bundle, env, ctx.config.envConf) && !ignoreWebRoot ) {
1631
1634
  req.routing = lib.routing.getRouteByUrl(rte, bundle, req.method, req);
1632
1635
  // try alternative method
1633
1636
  if (!req.routing) {
@@ -1637,7 +1640,7 @@ function SuperController(options) {
1637
1640
  method = req.method = 'GET'
1638
1641
  }
1639
1642
  }
1640
-
1643
+
1641
1644
  //route = route = req.routing.name;
1642
1645
  } else {
1643
1646
  req.routing = {
@@ -1646,54 +1649,54 @@ function SuperController(options) {
1646
1649
  }
1647
1650
  }
1648
1651
  }
1649
-
1652
+
1650
1653
  res = local.res;
1651
1654
  next = local.next;
1652
1655
  isRelative = true;
1653
-
1656
+
1654
1657
  req.routing.param.path = rte
1655
1658
  } else if ( isValidURL(req) ) { // might be an URL
1656
1659
  rte = req;
1657
- originalUrl = rte;
1660
+ originalUrl = rte;
1658
1661
  rte = rte.replace(/\?(.*)/, '');
1659
-
1662
+
1660
1663
  req = local.req;
1661
1664
  res = local.res;
1662
1665
  next = local.next;
1663
-
1666
+
1664
1667
  req.routing.param.url = rte
1665
1668
  } else { // is by default a route name
1666
-
1669
+
1667
1670
  if ( /\@/.test(req) ) {
1668
1671
  var rteArr = req.split(/\//);
1669
1672
  if ( typeof(rteArr[1]) != 'undefined' )
1670
1673
  env = rteArr[1];
1671
-
1674
+
1672
1675
  rte = route = rteArr[0];
1673
1676
  rteArr = rteArr[0].split(/\@/);
1674
-
1677
+
1675
1678
  bundle = rteArr[1];
1676
-
1679
+
1677
1680
  } else {
1678
1681
  rte = route = ( new RegExp('^/'+conf.bundle+'-$').test(req) ) ? req : wroot.match(/[^/]/g).join('') +'-'+ req;
1679
1682
  }
1680
-
1681
-
1683
+
1684
+
1682
1685
  req = local.req;
1683
1686
  res = local.res;
1684
1687
  next = local.next;
1685
-
1688
+
1686
1689
  req.routing.param.route = routing[rte]
1687
- }
1688
-
1690
+ }
1691
+
1689
1692
  } else {
1690
- route = req.routing.param.route;
1693
+ route = req.routing.param.route;
1691
1694
  }
1692
-
1695
+
1693
1696
  if ( !originalMethod ) {
1694
1697
  originalMethod = ( typeof(req.originalMethod) != 'undefined') ? req.originalMethod : req.method;
1695
1698
  }
1696
-
1699
+
1697
1700
  var path = originalUrl || req.routing.param.path || '';
1698
1701
  var url = req.routing.param.url;
1699
1702
  var code = req.routing.param.code || 301;
@@ -1710,20 +1713,20 @@ function SuperController(options) {
1710
1713
 
1711
1714
  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;
1712
1715
  var hostname = (isProxyHost) ? ctx.config.envConf[bundle][env].hostname.replace(/\:\d+$/, '') : ctx.config.envConf[bundle][env].hostname;
1713
-
1716
+
1714
1717
  // if ( !/\:\d+$/.test(req.headers.host) )
1715
1718
  // hostname = hostname.replace(/\:\d+$/, '');
1716
1719
 
1717
1720
  if (route) { // will go with route first
1718
-
1721
+
1719
1722
  if ( /\,/.test(routing[route].url) ) {
1720
1723
  var paths = routing[route].url.split(/\,/g);
1721
1724
  path = (ignoreWebRoot) ? paths[0].replace(wroot, '') : paths[0];
1722
1725
  } else {
1723
1726
  path = (ignoreWebRoot) ? routing[route].url.replace(wroot, '') : routing[route].url;
1724
1727
  }
1725
-
1726
- if (bundle != conf.bundle) {
1728
+
1729
+ if (bundle != conf.bundle) {
1727
1730
  path = hostname + path;
1728
1731
  }
1729
1732
  } else if (url && !path) {
@@ -1737,15 +1740,15 @@ function SuperController(options) {
1737
1740
  // nothing to do, just ignoring
1738
1741
  //} else {
1739
1742
  } else if ( !path && typeof(isRelative) == 'undefined' ) {
1740
-
1743
+
1741
1744
  path = hostname + path
1742
1745
  //path = local.req.headers.host + path
1743
1746
  }
1744
-
1745
-
1747
+
1748
+
1746
1749
 
1747
1750
  if (!local.res.headersSent) {
1748
-
1751
+
1749
1752
  // backing up oldParams
1750
1753
  var oldParams = local.req[originalMethod.toLowerCase()];
1751
1754
  var requestParams = req[req.method.toLowerCase()] || {};
@@ -1754,42 +1757,42 @@ function SuperController(options) {
1754
1757
  self.throwError(requestParams.error);
1755
1758
  return;
1756
1759
  }
1757
-
1758
- if (
1759
- !/GET/i.test(req.method)
1760
- ||
1761
- originalMethod && !/GET/i.test(originalMethod)
1762
- ) { // trying to redirect using the wrong method ?
1763
-
1760
+
1761
+ if (
1762
+ !/GET/i.test(req.method)
1763
+ ||
1764
+ originalMethod && !/GET/i.test(originalMethod)
1765
+ ) { // trying to redirect using the wrong method ?
1766
+
1764
1767
  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);
1765
1768
  method = local.req.method = self.setRequestMethod('GET', conf);
1766
- code = 303;
1769
+ code = 303;
1767
1770
  }
1768
-
1769
-
1771
+
1772
+
1770
1773
  // merging new & olds params
1771
1774
  requestParams = merge(requestParams, oldParams);
1772
1775
  // remove session to prevent reaching the 2000 chars limit
1773
1776
  // if you need the session, you need to find another way to retrieve while in the next route
1774
- if ( typeof(requestParams.session) != 'undefined' ) {
1777
+ if ( typeof(requestParams.session) != 'undefined' ) {
1775
1778
  delete requestParams.session;
1776
1779
  }
1777
- if ( typeof(requestParams) != 'undefined' && requestParams.count() > 0 ) {
1780
+ if ( typeof(requestParams) != 'undefined' && requestParams.count() > 0 ) {
1778
1781
  //if ( typeof(requestParams.error) != 'undefined' )
1779
-
1782
+
1780
1783
  var inheritedData = null;
1781
1784
  if ( /\?/.test(path) ) {
1782
- inheritedData = '&inheritedData='+ encodeURIComponent(JSON.stringify(requestParams));
1785
+ inheritedData = '&inheritedData='+ encodeURIComponent(JSON.stringify(requestParams));
1783
1786
  } else {
1784
- inheritedData = '?inheritedData='+ encodeURIComponent(JSON.stringify(requestParams));
1785
- }
1786
-
1787
+ inheritedData = '?inheritedData='+ encodeURIComponent(JSON.stringify(requestParams));
1788
+ }
1789
+
1787
1790
  if ( inheritedData.length > 2000 ) {
1788
1791
  var error = new ApiError('Controller::redirect(...) exceptions: `inheritedData` reached 2000 chars limit', 424);
1789
1792
  self.throwError(error);
1790
1793
  return;
1791
1794
  }
1792
-
1795
+
1793
1796
  // if redirecting from a xhrRequest
1794
1797
  if ( self.isXMLRequest() ) {
1795
1798
  // `requestParams` should be stored in the session to avoid passing datas in clear
@@ -1803,21 +1806,24 @@ function SuperController(options) {
1803
1806
  redirectObj.location += inheritedData;
1804
1807
  }
1805
1808
  }
1806
-
1809
+
1807
1810
  self.renderJSON(redirectObj);
1808
1811
  return;
1809
1812
  }
1810
-
1813
+
1811
1814
  path += inheritedData;
1812
- }
1813
-
1815
+ }
1816
+
1814
1817
  var ext = 'html';
1815
1818
  res.setHeader('content-type', local.options.conf.server.coreConfiguration.mime[ext]);
1816
-
1817
- if (
1818
- typeof(local.res._headers) != 'undefined'
1819
- && typeof(local.res._headers['access-control-allow-methods']) != 'undefined'
1820
- && local.res._headers['access-control-allow-methods'] != req.method
1819
+
1820
+ var resHeaderACAM = res.getHeader('access-control-allow-methods');
1821
+ if (
1822
+ // typeof(local.res._headers) != 'undefined'
1823
+ // && typeof(local.res._headers['access-control-allow-methods']) != 'undefined'
1824
+ // && local.res._headers['access-control-allow-methods'] != req.method
1825
+ typeof(resHeaderACAM) != 'undefined'
1826
+ && resHeaderACAM != req.method
1821
1827
  ||
1822
1828
  !new RegExp(req.method, 'i').test( res.getHeader('access-control-allow-methods') )
1823
1829
  ) {
@@ -1825,11 +1831,11 @@ function SuperController(options) {
1825
1831
  }
1826
1832
  //path += '?query='+ JSON.stringify(self.getRequestMethodParams());
1827
1833
  local.req[req.method.toLowerCase()] = self.getRequestMethodParams() || {};
1828
-
1834
+
1829
1835
  var headInfos = {
1830
- 'location': path
1831
- };
1832
-
1836
+ 'location': path
1837
+ };
1838
+
1833
1839
  if (self.isCacheless()) {
1834
1840
  res.writeHead(code, merge(headInfos, {
1835
1841
  'cache-control': 'no-cache, no-store, must-revalidate', // preventing browsers from using cache
@@ -1838,24 +1844,26 @@ function SuperController(options) {
1838
1844
  }))
1839
1845
  } else {
1840
1846
  res.writeHead(code, headInfos)
1841
- }
1842
- // in case of query from another bundle waiting for a response
1843
- var redirectObject = JSON.stringify({ status: code, headers: headInfos });
1844
- res.end(redirectObject);
1847
+ }
1848
+ // in case of query from another bundle waiting for a response
1849
+ var redirectObject = JSON.stringify({ status: code, headers: headInfos });
1850
+
1845
1851
  try {
1852
+ res.end(redirectObject);
1846
1853
  local.res.headersSent = true;// done for the render() method
1847
1854
  } catch(err){
1848
1855
  // ignoring the warning
1856
+ // console.warn(err.stack);
1849
1857
  }
1850
-
1858
+
1851
1859
  console.info(local.req.method.toUpperCase() +' ['+code+'] '+ path);
1852
-
1860
+
1853
1861
  if ( typeof(next) != 'undefined' )
1854
1862
  next();
1855
1863
  else
1856
1864
  return;
1857
1865
  }
1858
-
1866
+
1859
1867
  }
1860
1868
  }
1861
1869
 
@@ -1896,7 +1904,7 @@ function SuperController(options) {
1896
1904
  })
1897
1905
  }
1898
1906
  }
1899
-
1907
+
1900
1908
  this.getBundleStatus = function(req, res, next) {
1901
1909
  self.renderJSON({
1902
1910
  status: 200,
@@ -1904,8 +1912,8 @@ function SuperController(options) {
1904
1912
  message: 'I am alive !'
1905
1913
  });
1906
1914
  }
1907
-
1908
- this.checkBundleStatus = async function(bundle, cb) {
1915
+
1916
+ this.checkBundleStatus = async function(bundle, cb) {
1909
1917
  var opt = self.getConfig('app').proxy[bundle];
1910
1918
  var route = lib.routing.getRoute('bundle-status@'+bundle);
1911
1919
  opt.method = 'GET';
@@ -1915,29 +1923,29 @@ function SuperController(options) {
1915
1923
  .then( function onQueryResponse(_status) {
1916
1924
  response = _status
1917
1925
  });
1918
-
1926
+
1919
1927
  if (cb) {
1920
1928
  cb(error, response);
1921
1929
  } else {
1922
1930
  return response;
1923
1931
  }
1924
1932
  }
1925
-
1933
+
1926
1934
  /**
1927
1935
  * downloadFromURL
1928
1936
  * Download from an URL
1929
1937
  * - attachment/inline
1930
1938
  * OR
1931
- * - locally: `Controller.store(target, cb)` must be called to store on `onComplete` event
1932
- *
1939
+ * - locally: `Controller.store(target, cb)` must be called to store on `onComplete` event
1940
+ *
1933
1941
  * @param {string} url - eg.: https://upload.wikimedia.org/wikipedia/fr/2/2f/Firefox_Old_Logo.png
1934
1942
  * @param {object} [options]
1935
- *
1936
- *
1943
+ *
1944
+ *
1937
1945
  * */
1938
1946
  this.downloadFromURL = function(url, options) {
1939
-
1940
- var defaultOptions = {
1947
+
1948
+ var defaultOptions = {
1941
1949
  // file name i you want to rename the file
1942
1950
  file: null,
1943
1951
  fileSize: null,
@@ -1947,7 +1955,7 @@ function SuperController(options) {
1947
1955
  contentDisposition: 'attachment',
1948
1956
  // content-type (https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Configuring_server_MIME_types)
1949
1957
  contentType: 'application/octet-stream',
1950
-
1958
+
1951
1959
  agent: false,
1952
1960
  // set to false to ignore certificate verification
1953
1961
  rejectUnauthorized: true,
@@ -1957,9 +1965,9 @@ function SuperController(options) {
1957
1965
  keepAlive: true,
1958
1966
  headers: {}
1959
1967
  };
1960
-
1968
+
1961
1969
  var opt = ( typeof(options) != 'undefined' ) ? merge(options, defaultOptions) : defaultOptions;
1962
-
1970
+
1963
1971
  var requestOptions = {};
1964
1972
  for (var o in opt) {
1965
1973
  if ( !/(toLocalDir|contentDisposition|contentType|file)/.test(o) )
@@ -1968,81 +1976,81 @@ function SuperController(options) {
1968
1976
 
1969
1977
  // defining protocol & scheme
1970
1978
  var protocol = null;
1971
- var scheme = null;
1972
-
1979
+ var scheme = null;
1980
+
1973
1981
  if ( /\:\/\//.test(url) ) {
1974
1982
  scheme = url.match(/^\w+\:/)[0];
1975
1983
  scheme = scheme.substr(0, scheme.length-1);
1976
-
1984
+
1977
1985
  if ( !/^http/.test(scheme) ) {
1978
1986
  self.throwError(local.res, 500, new Error('[ '+ scheme +' ] Scheme not supported. Ref.: `http` or `https` only'));
1979
1987
  return;
1980
1988
  }
1981
-
1982
-
1983
-
1989
+
1990
+
1991
+
1984
1992
  } else { // by default
1985
1993
  scheme = 'http';
1986
1994
  }
1987
-
1995
+
1988
1996
  requestOptions.scheme = scheme +':';
1989
-
1997
+
1990
1998
  //defining port
1991
1999
  var port = url.match(/\:\d+\//) || null;
1992
2000
  if ( port != null ) {
1993
2001
  port = port[0].substr(1, port[0].length-2);
1994
- requestOptions.port = ~~port;
2002
+ requestOptions.port = ~~port;
1995
2003
  }
1996
-
2004
+
1997
2005
  // defining hostname & path
1998
2006
  var parts = url.replace(new RegExp( scheme + '\:\/\/'), '').split(/\//g);
1999
2007
  requestOptions.host = parts[0].replace(/\:\d+/, '');
2000
2008
  requestOptions.path = '/' + parts.splice(1).join('/');
2001
-
2002
-
2009
+
2010
+
2003
2011
  // extension and mime
2004
- var filename = url.split(/\//g).pop();
2012
+ var filename = url.split(/\//g).pop();
2005
2013
  if (!filename) {
2006
2014
  self.throwError(local.res, 500, new Error('Filename not found in url: `'+ url +'`'));
2007
2015
  return;
2008
2016
  }
2009
-
2010
-
2017
+
2018
+
2011
2019
  if ( !/\.\w+$/.test(filename) ) {
2012
2020
  self.throwError(local.res, 500, new Error('[ '+ filename +' ] extension not found.'));
2013
2021
  return;
2014
2022
  }
2015
-
2016
-
2023
+
2024
+
2017
2025
  // filename renaming
2018
2026
  if (opt.file)
2019
2027
  filename = opt.file;
2020
-
2028
+
2021
2029
  if ( opt.contentDisposition == 'attachment') {
2022
2030
  opt.contentDisposition += '; filename=' + filename;
2023
2031
  }
2024
-
2032
+
2025
2033
  var ext = filename.match(/\.\w+$/)[0].substr(1)
2026
2034
  , contentType = null
2027
2035
  , tmp = _(GINA_TMPDIR +'/'+ filename, true)
2028
2036
  ;
2029
-
2037
+
2030
2038
  if ( typeof(local.options.conf.server.coreConfiguration.mime[ext]) != 'undefined' ) {
2031
2039
 
2032
2040
  contentType = (opt.contentType != defaultOptions.contentType) ? opt.contentType : local.options.conf.server.coreConfiguration.mime[ext];
2033
-
2041
+
2034
2042
  } else { // extension not supported
2035
2043
  self.throwError(local.res, 500, new Error('[ '+ ext +' ] Extension not supported. Ref.: gina/core mime.types'));
2036
2044
  return;
2037
2045
  }
2038
-
2046
+
2039
2047
  // defining responseType
2040
2048
  requestOptions.headers['content-type'] = contentType;
2041
2049
  requestOptions.headers['content-disposition'] = opt.contentDisposition;
2042
-
2050
+
2043
2051
  var browser = require(''+ scheme);
2044
2052
  //console.debug('requestOptions: \n', JSON.stringify(requestOptions, null, 4));
2045
-
2053
+
2046
2054
  browser.get(requestOptions, function(response) {
2047
2055
 
2048
2056
  local.res.setHeader('content-type', contentType + '; charset='+ local.options.conf.encoding);
@@ -2051,28 +2059,28 @@ function SuperController(options) {
2051
2059
  local.res.setHeader('content-length', opt.fileSize);
2052
2060
  }
2053
2061
  //local.res.setHeader('content-length', opt.fileSize);
2054
- // local.res.setHeader('cache-control', 'must-revalidate');
2055
- // local.res.setHeader('pragma', 'must-revalidate');
2056
-
2062
+ // local.res.setHeader('cache-control', 'must-revalidate');
2063
+ // local.res.setHeader('pragma', 'must-revalidate');
2064
+
2057
2065
  // response.on('end', function onResponsePipeEnd(){
2058
2066
  // self.renderJSON({ url: url});
2059
2067
  // //local.res.end( Buffer.from(data) );
2060
- // //local.res.headersSent = true;
2061
-
2068
+ // //local.res.headersSent = true;
2069
+
2062
2070
  // // if ( typeof(local.next) != 'undefined')
2063
2071
  // // local.next();
2064
2072
  // // else
2065
2073
  // // return;
2066
2074
  // });
2067
-
2075
+
2068
2076
  response.pipe(local.res);
2069
2077
  });
2070
-
2078
+
2071
2079
  return;
2072
2080
 
2073
2081
  }
2074
2082
 
2075
-
2083
+
2076
2084
  /**
2077
2085
  * Download to targeted filename.ext - Will create target if new
2078
2086
  * Use `cb` callback or `onComplete` event
@@ -2081,17 +2089,17 @@ function SuperController(options) {
2081
2089
  * @param {object} options
2082
2090
  **/
2083
2091
  this.downloadFromLocal = function(filename) {
2084
-
2085
- var file = filename.split(/\//g).pop();
2092
+
2093
+ var file = filename.split(/\//g).pop();
2086
2094
  var ext = file.split(/\./g).pop()
2087
2095
  , contentType = null
2088
2096
  ;
2089
-
2097
+
2090
2098
  if ( typeof(local.options.conf.server.coreConfiguration.mime[ext]) != 'undefined' ) {
2091
2099
 
2092
2100
  contentType = local.options.conf.server.coreConfiguration.mime[ext];
2093
2101
  local.res.setHeader('content-type', contentType);
2094
- local.res.setHeader('content-disposition', 'attachment; filename=' + file);
2102
+ local.res.setHeader('content-disposition', 'attachment; filename=' + file);
2095
2103
 
2096
2104
  var filestream = fs.createReadStream(filename);
2097
2105
  filestream.pipe(local.res);
@@ -2099,7 +2107,7 @@ function SuperController(options) {
2099
2107
  } else { // extension not supported
2100
2108
  self.throwError(local.res, 500, new Error('[ '+ ext +' ] Extension not supported. Ref.: gina/core mime.types'));
2101
2109
  return;
2102
- }
2110
+ }
2103
2111
  }
2104
2112
 
2105
2113
 
@@ -2122,17 +2130,17 @@ function SuperController(options) {
2122
2130
  * */
2123
2131
  this.store = async function(target, files, cb) {
2124
2132
 
2125
-
2133
+
2126
2134
  var start = function(target, files, cb) {
2127
-
2135
+
2128
2136
  if (arguments.length == 2 && typeof(arguments[1]) == 'function' ) {
2129
2137
  var cb = arguments[1];
2130
2138
  }
2131
-
2139
+
2132
2140
  if ( typeof(files) == 'undefined' || typeof(files) == 'function' ) {
2133
2141
  files = local.req.files
2134
2142
  }
2135
-
2143
+
2136
2144
  var uploadedFiles = [];
2137
2145
 
2138
2146
  if ( typeof(files) == 'undefined' || files.count() == 0 ) {
@@ -2155,25 +2163,25 @@ function SuperController(options) {
2155
2163
  self.emit('uploaded', folder)
2156
2164
  }
2157
2165
  } else {
2158
- // files list
2159
- var fileName = null;
2166
+ // files list
2167
+ var fileName = null;
2160
2168
  for (var len = files.length; i < len; ++i ){
2161
-
2169
+
2162
2170
  fileName = files[i].filename || files[i].originalFilename
2163
-
2171
+
2164
2172
  list[i] = {
2165
2173
  source: files[i].path,
2166
2174
  target: _(uploadDir.toString() + '/' + fileName)
2167
2175
  };
2168
-
2169
- uploadedFiles[i] = {
2176
+
2177
+ uploadedFiles[i] = {
2170
2178
  file : fileName,
2171
- filename : list[i].target,
2179
+ filename : list[i].target,
2172
2180
  size : files[i].size,
2173
2181
  type : files[i].type,
2174
2182
  encoding : files[i].encoding
2175
2183
  };
2176
-
2184
+
2177
2185
  }
2178
2186
 
2179
2187
  movefiles(0, local.res, list, function (err) {
@@ -2279,7 +2287,7 @@ function SuperController(options) {
2279
2287
  } while (cert.fingerprint256 !== lastprint256);
2280
2288
 
2281
2289
  }*/
2282
-
2290
+
2283
2291
  };
2284
2292
 
2285
2293
  this.query = function() { // options, data, callback
@@ -2293,7 +2301,7 @@ function SuperController(options) {
2293
2301
  data = arguments[arguments.length-1]
2294
2302
  }
2295
2303
  // preventing multiple call of self.query() when controller is rendering from another required controller
2296
- if (
2304
+ if (
2297
2305
  typeof(local.options) != 'undefined'
2298
2306
  && typeof(local.options.renderingStack) != 'undefined'
2299
2307
  && local.options.renderingStack.length > 1
@@ -2301,22 +2309,22 @@ function SuperController(options) {
2301
2309
  return false
2302
2310
  }
2303
2311
  self.isProcessingError = false; // by default
2304
-
2312
+
2305
2313
  var queryData = {}
2306
2314
  , defaultOptions = local.query.options
2307
2315
  , path = options.path
2308
- , browser = null
2316
+ , browser = null
2309
2317
  ;
2310
2318
 
2311
2319
  // options must be used as a copy in case of multiple calls of self.query(options, ...)
2312
2320
  options = merge(JSON.clone(options), defaultOptions);
2313
-
2321
+
2314
2322
  for (var o in options) {//cleaning
2315
2323
  if ( typeof(options[o]) == 'undefined' || options[o] == undefined) {
2316
2324
  delete options[o]
2317
2325
  }
2318
2326
  }
2319
-
2327
+
2320
2328
  if (self.isCacheless() || self.isLocalScope() ) {
2321
2329
  options.rejectUnauthorized = false;
2322
2330
  }
@@ -2329,16 +2337,7 @@ function SuperController(options) {
2329
2337
  self.emit('query#complete', err)
2330
2338
  }
2331
2339
 
2332
-
2333
2340
 
2334
- // if (arguments.length <3) {
2335
- // if ( typeof(data) == 'function') {
2336
- // var callback = data;
2337
- // var data = undefined;
2338
- // } else {
2339
- // callback = undefined;
2340
- // }
2341
- // }
2342
2341
  if ( typeof(data) != 'undefined' && data.count() > 0) {
2343
2342
 
2344
2343
  queryData = '?';
@@ -2362,7 +2361,7 @@ function SuperController(options) {
2362
2361
 
2363
2362
  queryData = queryData.substring(0, queryData.length-1);
2364
2363
  queryData = queryData.replace(/\s/g, '%20');
2365
-
2364
+
2366
2365
  options.path += queryData;
2367
2366
  }
2368
2367
 
@@ -2370,7 +2369,7 @@ function SuperController(options) {
2370
2369
  queryData = ''
2371
2370
  }
2372
2371
 
2373
-
2372
+
2374
2373
  // Internet Explorer override
2375
2374
  if ( local.req != null && /msie/i.test(local.req.headers['user-agent']) ) {
2376
2375
  options.headers['content-type'] = 'text/plain';
@@ -2389,7 +2388,7 @@ function SuperController(options) {
2389
2388
 
2390
2389
  //you need this, even when empty.
2391
2390
  options.headers['content-length'] = queryData.length;
2392
-
2391
+
2393
2392
  // adding gina headers
2394
2393
  if ( local.req != null && typeof(local.req.ginaHeaders) != 'undefined' ) {
2395
2394
  // gina form headers
@@ -2405,7 +2404,7 @@ function SuperController(options) {
2405
2404
  ;
2406
2405
  // cleanup options.path
2407
2406
  if (/\:\/\//.test(options.path)) {
2408
-
2407
+
2409
2408
  var hArr = options.path.split(/^(https|http)\:\/\//);
2410
2409
  var domain = hArr[1] +'://';
2411
2410
  var host = hArr[2].split(/\//)[0];
@@ -2417,72 +2416,84 @@ function SuperController(options) {
2417
2416
  .replace(options.host, '')
2418
2417
  .replace(':'+port, '');
2419
2418
  }
2420
-
2419
+
2421
2420
  // retrieve protocol & scheme: if empty, take the bundles protocol
2422
2421
  protocol = options.protocol || ctx.gina.config.envConf[ctx.bundle][ctx.env].server.protocol;// bundle servers's protocol by default
2423
2422
  protocol = protocol.match(/[.a-z 0-9]+/ig)[0];
2424
2423
  scheme = options.scheme || ctx.gina.config.envConf[ctx.bundle][ctx.env].server.scheme;// bundle servers's scheme by default
2425
2424
  scheme = scheme.match(/[a-z 0-9]+/ig)[0];
2426
-
2425
+ // retrieve credentials
2426
+ if ( typeof(options.ca) == 'undefined' || ! options.ca ) {
2427
+ options.ca = ctx.gina.config.envConf[ctx.bundle][ctx.env].server.credentials.ca;
2428
+ }
2429
+
2427
2430
  //retrieving dynamic host, hostname & port
2428
2431
  if ( /\@/.test(options.hostname) ) {
2429
-
2432
+
2430
2433
  var bundle = ( options.hostname.replace(/(.*)\:\/\//, '') ).split(/\@/)[0];
2431
-
2434
+
2432
2435
  // No shorcut possible because conf.hostname might differ from user inputs
2433
2436
  options.host = ctx.gina.config.envConf[bundle][ctx.env].host.replace(/(.*)\:\/\//, '').replace(/\:\d+/, '');
2434
2437
  options.hostname = ctx.gina.config.envConf[bundle][ctx.env].hostname;
2435
2438
  options.port = ctx.gina.config.envConf[bundle][ctx.env].server.port;
2436
-
2439
+
2437
2440
  options.protocol = ctx.gina.config.envConf[bundle][ctx.env].server.protocol;
2438
2441
  options.scheme = ctx.gina.config.envConf[bundle][ctx.env].server.scheme;
2442
+
2443
+ // retrieve credentials
2444
+ if ( typeof(options.ca) == 'undefined' || ! options.ca ) {
2445
+ options.ca = ctx.gina.config.envConf[bundle][ctx.env].server.credentials.ca;
2446
+ }
2447
+
2439
2448
  // might be != from the bundle requesting
2440
2449
  //options.protocol = ctx.gina.config.envConf[bundle][ctx.env].content.settings.server.protocol || ctx.gina.config.envConf[bundle][ctx.env].server.protocol;
2441
2450
  //options.scheme = ctx.gina.config.envConf[bundle][ctx.env].content.settings.server.scheme || ctx.gina.config.envConf[bundle][ctx.env].server.scheme;
2442
2451
  }
2443
-
2452
+
2444
2453
  if ( typeof(options.protocol) == 'undefined' ) {
2445
2454
  options.protocol = protocol
2446
2455
  }
2447
2456
  if ( typeof(options.scheme) == 'undefined' ) {
2448
2457
  options.scheme = scheme
2449
2458
  }
2450
-
2451
-
2459
+
2460
+
2461
+
2462
+
2452
2463
  // reformating scheme
2453
2464
  if( !/\:$/.test(options.scheme) )
2454
2465
  options.scheme += ':';
2455
-
2456
- try {
2457
- options.queryData = queryData;
2466
+
2467
+ try {
2468
+ options.queryData = queryData;
2458
2469
  var protocolVersion = ~~options.protocol.match(/\/(.*)$/)[1].replace(/\.\d+/, '');
2459
2470
  var httpLib = options.protocol.match(/^(.*)\//)[1] + ( (protocolVersion >= 2) ? protocolVersion : '' );
2460
2471
  if ( !/http2/.test(httpLib) && /https/.test(options.scheme) ) {
2461
2472
  httpLib += 's';
2462
2473
  }
2463
-
2464
- browser = require(''+ httpLib);
2465
-
2474
+
2475
+ browser = require(''+ httpLib);
2476
+
2466
2477
  if ( /http2/.test(httpLib) ) {
2467
2478
  return handleHTTP2ClientRequest(browser, options, callback);
2468
2479
  } else {
2469
- return handleHTTP1ClientRequest(browser, options, callback);
2470
- }
2471
-
2472
-
2480
+ return handleHTTP1ClientRequest(browser, options, callback);
2481
+ }
2482
+
2483
+
2473
2484
  } catch(err) {
2474
2485
  if (callback) {
2475
2486
  return callback(err)
2476
2487
  }
2477
2488
  self.emit('query#complete', err)
2478
2489
  }
2479
-
2490
+
2480
2491
  }
2481
-
2492
+
2482
2493
  var handleHTTP1ClientRequest = function(browser, options, callback) {
2483
-
2494
+
2484
2495
  var altOpt = JSON.clone(options);
2485
-
2496
+
2486
2497
  altOpt.protocol = options.scheme;
2487
2498
  altOpt.hostname = options.host;
2488
2499
  altOpt.port = options.port;
@@ -2492,24 +2503,24 @@ function SuperController(options) {
2492
2503
  } catch(err) {
2493
2504
  self.emit('query#complete', err);
2494
2505
  }
2495
-
2506
+
2496
2507
  } else {
2497
2508
  console.warn('[ CONTROLLER ][ HTTP/1.0#query ] options.encKey not found !');
2498
2509
  }
2499
-
2510
+
2500
2511
  if ( typeof(altOpt.encCert) != 'undefined' ) {
2501
2512
  try {
2502
2513
  altOpt.encCert = fs.readFileSync(options.encCert);
2503
2514
  } catch(err) {
2504
2515
  self.emit('query#complete', err);
2505
2516
  }
2506
-
2517
+
2507
2518
  } else {
2508
2519
  console.warn('[ CONTROLLER ][ HTTP/1.0#query ] options.encCert not found !');
2509
2520
  }
2510
-
2521
+
2511
2522
  altOpt.agent = new browser.Agent(altOpt);
2512
-
2523
+
2513
2524
  var req = browser.request(altOpt, function(res) {
2514
2525
 
2515
2526
  res.setEncoding('utf8');
@@ -2526,24 +2537,24 @@ function SuperController(options) {
2526
2537
  });
2527
2538
 
2528
2539
  res.on('end', function onEnd(err) {
2529
-
2530
-
2540
+
2541
+
2531
2542
  // exceptions filter
2532
2543
  if ( typeof(data) == 'string' && /^Unknown ALPN Protocol/.test(data) ) {
2533
2544
  err = {
2534
2545
  status: 500,
2535
2546
  error: new Error(data)
2536
2547
  };
2537
-
2548
+
2538
2549
  if ( typeof(callback) != 'undefined' ) {
2539
2550
  callback(err)
2540
2551
  } else {
2541
2552
  self.emit('query#complete', err)
2542
2553
  }
2543
-
2554
+
2544
2555
  return
2545
2556
  }
2546
-
2557
+
2547
2558
  //Only when needed.
2548
2559
  if ( typeof(callback) != 'undefined' ) {
2549
2560
  if ( typeof(data) == 'string' && /^(\{|%7B|\[{)|\[\]/.test(data) ) {
@@ -2573,7 +2584,7 @@ function SuperController(options) {
2573
2584
  exception.status = 500;
2574
2585
  self.throwError(exception);
2575
2586
  return;
2576
- }
2587
+ }
2577
2588
 
2578
2589
  } else {
2579
2590
  if ( typeof(data) == 'string' && /^(\{|%7B|\[{)|\[\]/.test(data) ) {
@@ -2600,14 +2611,14 @@ function SuperController(options) {
2600
2611
 
2601
2612
  //starting from from >0.10.15
2602
2613
  req.on('error', function onError(err) {
2603
-
2604
-
2614
+
2615
+
2605
2616
  if (
2606
- typeof(err.code) != 'undefined' && /ECONNREFUSED|ECONNRESET/.test(err.code)
2607
- || typeof(err.cause) != 'undefined' && typeof(err.cause.code) != 'undefined' && /ECONNREFUSED|ECONNRESET/.test(err.cause.code)
2617
+ typeof(err.code) != 'undefined' && /ECONNREFUSED|ECONNRESET/.test(err.code)
2618
+ || typeof(err.cause) != 'undefined' && typeof(err.cause.code) != 'undefined' && /ECONNREFUSED|ECONNRESET/.test(err.cause.code)
2608
2619
  ) {
2609
2620
 
2610
- var port = getContext('gina').ports[options.protocol][options.scheme.replace(/\:/, '')][ options.port ];//err.port || err.cause.port
2621
+ var port = getContext('gina').ports[options.protocol][options.scheme.replace(/\:/, '')][ options.port ];//err.port || err.cause.port
2611
2622
  if ( typeof(port) != 'undefined' ) {
2612
2623
  err.accessPoint = port;
2613
2624
  err.message = '`Controller::query()` could not connect to [ ' + err.accessPoint + ' ] using port '+options.port+'.\n';
@@ -2667,30 +2678,30 @@ function SuperController(options) {
2667
2678
  exception.status = 500;
2668
2679
  self.throwError(exception);
2669
2680
  return;
2670
- }
2681
+ }
2671
2682
  })
2672
2683
  }
2673
-
2684
+
2674
2685
  }
2675
2686
  }
2676
-
2687
+
2677
2688
  var handleHTTP2ClientRequest = function(browser, options, callback) {
2678
-
2679
- //cleanup
2689
+
2690
+ //cleanup
2680
2691
  options[':authority'] = options.hostname;
2681
-
2692
+
2682
2693
  delete options.host;
2683
-
2694
+
2684
2695
  if ( typeof(options[':path']) == 'undefined' ) {
2685
2696
  options[':path'] = options.path;
2686
2697
  delete options.path;
2687
- }
2698
+ }
2688
2699
  if ( typeof(options[':method']) == 'undefined' ) {
2689
2700
  options[':method'] = options.method.toUpperCase();
2690
2701
  delete options.method;
2691
2702
  }
2692
-
2693
- // only if binary !!
2703
+
2704
+ // only if binary !!
2694
2705
  // if ( typeof(options['content-length']) == 'undefined' ) {
2695
2706
  // options['content-length'] = options.headers['content-length'] ;
2696
2707
  // delete options.headers['content-length'];
@@ -2699,11 +2710,11 @@ function SuperController(options) {
2699
2710
  // options['content-type'] = options.headers['content-type'] ;
2700
2711
  // delete options.headers['content-type'];
2701
2712
  // }
2702
-
2713
+
2703
2714
  if ( typeof(options[':scheme']) == 'undefined' ) {
2704
2715
  options[':scheme'] = options.scheme ;
2705
2716
  }
2706
-
2717
+
2707
2718
  if ( typeof(options.ca) != 'undefined' ) {
2708
2719
  try {
2709
2720
  options.ca = fs.readFileSync(options.ca);
@@ -2713,58 +2724,58 @@ function SuperController(options) {
2713
2724
  } else {
2714
2725
  self.emit('query#complete', err);
2715
2726
  }
2716
-
2727
+
2717
2728
  return;
2718
2729
  }
2719
-
2730
+
2720
2731
  } else {
2721
2732
  console.warn('[ CONTROLLER ][ HTTP/2.0#query ] options.ca not found !');
2722
2733
  }
2723
-
2724
-
2734
+
2735
+
2725
2736
  var body = Buffer.from(options.queryData);
2726
- options.headers['content-length'] = body.length;
2737
+ options.headers['content-length'] = body.length;
2727
2738
  delete options.queryData;
2728
-
2729
-
2730
-
2731
- const client = browser.connect(options.hostname, options);
2732
-
2733
-
2739
+
2740
+
2741
+
2742
+ const client = browser.connect(options.hostname, options);
2743
+
2744
+
2734
2745
  const {
2735
2746
  HTTP2_HEADER_PROTOCOL,
2736
- HTTP2_HEADER_SCHEME,
2747
+ HTTP2_HEADER_SCHEME,
2737
2748
  HTTP2_HEADER_AUTHORITY,
2738
2749
  HTTP2_HEADER_PATH,
2739
2750
  HTTP2_HEADER_METHOD,
2740
2751
  HTTP2_HEADER_STATUS
2741
2752
  } = browser.constants;
2742
-
2743
-
2753
+
2754
+
2744
2755
  if ( typeof(local.req.headers['x-requested-with']) != 'undefined' ) {
2745
2756
  options.headers['x-requested-with'] = local.req.headers['x-requested-with']
2746
2757
  }
2747
-
2758
+
2748
2759
  if ( typeof(local.req.headers['access-control-allow-credentials']) != 'undefined' ) {
2749
2760
  options.headers['access-control-allow-credentials'] = local.req.headers['access-control-allow-credentials']
2750
2761
  }
2751
-
2762
+
2752
2763
  if ( typeof(local.req.headers['content-type']) != 'undefined' && local.req.headers['content-type'] != options.headers['content-type'] ) {
2753
2764
  options.headers['content-type'] = local.req.headers['content-type']
2754
2765
  }
2755
-
2756
- var headers = merge({
2766
+
2767
+ var headers = merge({
2757
2768
  [HTTP2_HEADER_METHOD]: options[':method'],
2758
- [HTTP2_HEADER_PATH]: options[':path']
2769
+ [HTTP2_HEADER_PATH]: options[':path']
2759
2770
  }, options.headers);
2760
-
2771
+
2761
2772
  // merging with user options
2762
2773
  for (var o in options) {
2763
2774
  if (!/^\:/.test(o) && !/headers/.test(o) && typeof(headers[o]) == 'undefined' ) {
2764
2775
  headers[o] = options[o]
2765
2776
  }
2766
2777
  }
2767
-
2778
+
2768
2779
  /**
2769
2780
  * sessionOptions
2770
2781
  * endStream <boolean> true if the Http2Stream writable side should be closed initially, such as when sending a GET request that should not expect a payload body.
@@ -2778,55 +2789,55 @@ function SuperController(options) {
2778
2789
  endStream = false;
2779
2790
  sessionOptions.endStream = endStream;
2780
2791
  }
2781
-
2782
-
2792
+
2793
+
2783
2794
  client.on('error', (error) => {
2784
-
2795
+
2785
2796
  console.error( '`'+ options[':path']+ '` : '+ error.stack||error.message);
2786
- if (
2787
- typeof(error.cause) != 'undefined' && typeof(error.cause.code) != 'undefined' && /ECONNREFUSED|ECONNRESET/.test(error.cause.code)
2788
- || /ECONNREFUSED|ECONNRESET/.test(error.code)
2797
+ if (
2798
+ typeof(error.cause) != 'undefined' && typeof(error.cause.code) != 'undefined' && /ECONNREFUSED|ECONNRESET/.test(error.cause.code)
2799
+ || /ECONNREFUSED|ECONNRESET/.test(error.code)
2789
2800
  ) {
2790
-
2801
+
2791
2802
  var port = getContext('gina').ports[options.protocol][options.scheme.replace(/\:/, '')][ options.port ];
2792
2803
  if ( typeof(port) != 'undefined' ) {
2793
2804
  error.accessPoint = port;
2794
2805
  error.message = 'Could not connect to [ ' + error.accessPoint + ' ].\nThe `'+port.split(/\@/)[0]+'` bundle is offline or unreachable.\n';
2795
- }
2806
+ }
2796
2807
  }
2797
2808
  self.throwError(error);
2798
2809
  return;
2799
2810
  });
2800
-
2811
+
2801
2812
  client.on('connect', () => {
2802
-
2813
+
2803
2814
  var req = client.request( headers, sessionOptions );
2804
-
2805
-
2806
- // req.on('response', function onQueryResponse(headers, flags) {
2815
+
2816
+
2817
+ // req.on('response', function onQueryResponse(headers, flags) {
2807
2818
  // for (const name in headers) {
2808
2819
  // console.debug(`${name}: ${headers[name]}`);
2809
2820
  // }
2810
2821
  // });
2811
-
2822
+
2812
2823
  req.setEncoding('utf8');
2813
2824
  var data = '';
2814
- req.on('data', function onQueryDataChunk(chunk) {
2815
- data += chunk;
2825
+ req.on('data', function onQueryDataChunk(chunk) {
2826
+ data += chunk;
2816
2827
  });
2817
-
2828
+
2818
2829
  req.on('error', function onQueryError(error) {
2819
2830
 
2820
- if (
2821
- typeof(error.cause) != 'undefined' && typeof(error.cause.code) != 'undefined' && /ECONNREFUSED|ECONNRESET/.test(error.cause.code)
2822
- || /ECONNREFUSED|ECONNRESET/.test(error.code)
2831
+ if (
2832
+ typeof(error.cause) != 'undefined' && typeof(error.cause.code) != 'undefined' && /ECONNREFUSED|ECONNRESET/.test(error.cause.code)
2833
+ || /ECONNREFUSED|ECONNRESET/.test(error.code)
2823
2834
  ) {
2824
-
2835
+
2825
2836
  var port = getContext('gina').ports[options.protocol][options.scheme.replace(/\:/, '')][ options.port ];
2826
2837
  if ( typeof(port) != 'undefined' ) {
2827
2838
  error.accessPoint = port;
2828
2839
  error.message = 'Could not connect to [ ' + error.accessPoint + ' ].\n' + error.message;
2829
- }
2840
+ }
2830
2841
  }
2831
2842
 
2832
2843
 
@@ -2834,7 +2845,7 @@ function SuperController(options) {
2834
2845
  // you can get here if :
2835
2846
  // - you are trying to query using: `enctype="multipart/form-data"`
2836
2847
  // - server responded with an error
2837
- if ( typeof(callback) != 'undefined' ) {
2848
+ if ( typeof(callback) != 'undefined' ) {
2838
2849
  callback(error);
2839
2850
  } else {
2840
2851
  error = {
@@ -2844,28 +2855,28 @@ function SuperController(options) {
2844
2855
 
2845
2856
  self.emit('query#complete', error)
2846
2857
  }
2847
-
2858
+
2848
2859
  return;
2849
2860
  });
2850
-
2851
- req.on('end', function onEnd() {
2852
-
2861
+
2862
+ req.on('end', function onEnd() {
2863
+
2853
2864
  // exceptions filter
2854
2865
  if ( typeof(data) == 'string' && /^Unknown ALPN Protocol/.test(data) ) {
2855
2866
  var err = {
2856
2867
  status: 500,
2857
2868
  error: new Error(data)
2858
2869
  };
2859
-
2870
+
2860
2871
  if ( typeof(callback) != 'undefined' ) {
2861
2872
  callback(err)
2862
2873
  } else {
2863
2874
  self.emit('query#complete', err)
2864
2875
  }
2865
-
2876
+
2866
2877
  return
2867
2878
  }
2868
-
2879
+
2869
2880
  //Only when needed.
2870
2881
  if ( typeof(callback) != 'undefined' ) {
2871
2882
  if ( typeof(data) == 'string' && /^(\{|%7B|\[{)|\[\]/.test(data) ) {
@@ -2896,24 +2907,24 @@ function SuperController(options) {
2896
2907
  if ( data.status && /^3/.test(data.status) && typeof(data.headers) != 'undefined' ) {
2897
2908
  local.res.writeHead(data.status, data.headers);
2898
2909
  return local.res.end();
2899
- }
2900
-
2910
+ }
2911
+
2901
2912
  if ( data.status && !/^2/.test(data.status) && typeof(local.options.conf.server.coreConfiguration.statusCodes[data.status]) != 'undefined' ) {
2902
2913
  if ( /^5/.test(data.status) ) {
2903
- return callback(data)
2914
+ return callback(data)
2904
2915
  } else {
2905
2916
  self.throwError(data);
2906
2917
  return;
2907
- }
2918
+ }
2908
2919
  } else {
2909
2920
  // required when control is used in an halted state
2910
2921
  // Ref.: resumeRequest()
2911
2922
  if ( self && self.isHaltedRequest() && typeof(local.onHaltedRequestResumed) != 'undefined' ) {
2912
2923
  local.onHaltedRequestResumed(false);
2913
2924
  }
2914
- return callback( false, data )
2925
+ return callback( false, data )
2915
2926
  }
2916
-
2927
+
2917
2928
  } catch (e) {
2918
2929
  var infos = local.options, controllerName = infos.controller.substr(infos.controller.lastIndexOf('/'));
2919
2930
  var msg = 'Controller Query Exception while catching back.\nBundle: '+ infos.bundle +'\nController File: /controllers'+ controllerName +'\nControl: this.'+ infos.control +'(...)\n\r' + e.stack;
@@ -2921,8 +2932,8 @@ function SuperController(options) {
2921
2932
  exception.status = 500;
2922
2933
  self.throwError(exception);
2923
2934
  return;
2924
- }
2925
-
2935
+ }
2936
+
2926
2937
  } else {
2927
2938
  if ( typeof(data) == 'string' && /^(\{|%7B|\[{)|\[\]/.test(data) ) {
2928
2939
  try {
@@ -2935,13 +2946,13 @@ function SuperController(options) {
2935
2946
  self.emit('query#complete', data)
2936
2947
  }
2937
2948
  }
2938
-
2949
+
2939
2950
  // intercepting fallback redirect
2940
2951
  if ( data.status && /^3/.test(data.status) && typeof(data.headers) != 'undefined' ) {
2941
2952
  self.removeAllListeners(['query#complete']);
2942
2953
  local.res.writeHead(data.status, data.headers);
2943
2954
  return local.res.end();
2944
- }
2955
+ }
2945
2956
 
2946
2957
  if ( data.status && !/^2/.test(data.status) && typeof(local.options.conf.server.coreConfiguration.statusCodes[data.status]) != 'undefined' ) {
2947
2958
  self.emit('query#complete', data)
@@ -2953,22 +2964,22 @@ function SuperController(options) {
2953
2964
  }
2954
2965
  self.emit('query#complete', false, data)
2955
2966
  }
2956
- }
2957
-
2967
+ }
2968
+
2958
2969
  client.close();
2959
2970
  });
2960
-
2971
+
2961
2972
  if (!endStream) {
2962
2973
  req.end(body);
2963
2974
  }
2964
2975
  });
2965
-
2966
-
2976
+
2977
+
2967
2978
  return {
2968
2979
  onComplete : function(cb) {
2969
-
2980
+
2970
2981
  self.once('query#complete', function(err, data){
2971
-
2982
+
2972
2983
  if ( typeof(data) == 'string' && /^(\{|%7B|\[{)|\[\]/.test(data) ) {
2973
2984
  try {
2974
2985
  data = JSON.parse(data)
@@ -2979,7 +2990,7 @@ function SuperController(options) {
2979
2990
  }
2980
2991
  }
2981
2992
  }
2982
-
2993
+
2983
2994
  try {
2984
2995
  if ( data.status && !/^2/.test(data.status) && typeof(local.options.conf.server.coreConfiguration.statusCodes[data.status]) != 'undefined') {
2985
2996
  cb(data)
@@ -2989,7 +3000,7 @@ function SuperController(options) {
2989
3000
  if ( self.isHaltedRequest() && typeof(local.onHaltedRequestResumed) != 'undefined' ) {
2990
3001
  local.onHaltedRequestResumed(err);
2991
3002
  }
2992
-
3003
+
2993
3004
  cb(err, data)
2994
3005
  }
2995
3006
  } catch (e) {
@@ -2999,7 +3010,7 @@ function SuperController(options) {
2999
3010
  exception.status = 500;
3000
3011
  self.throwError(exception);
3001
3012
  return;
3002
- }
3013
+ }
3003
3014
  })
3004
3015
  }
3005
3016
  }
@@ -3066,8 +3077,8 @@ function SuperController(options) {
3066
3077
  }
3067
3078
 
3068
3079
  req.getParam = function(name) {
3069
-
3070
- var param = null;
3080
+
3081
+ var param = null;
3071
3082
  switch( req.method.toLowerCase() ) {
3072
3083
  case 'get':
3073
3084
  param = req.get[name];
@@ -3089,24 +3100,24 @@ function SuperController(options) {
3089
3100
  return param
3090
3101
  }
3091
3102
  }
3092
-
3103
+
3093
3104
  /**
3094
- * Forward request
3105
+ * Forward request
3095
3106
  * Allowing x-bundle forward
3096
3107
  * Attention: this is a work in progres, do not use it yet
3097
- *
3098
- * @param {object} req
3099
- * @param {object} res
3100
- * @param {callback} next
3101
- * @returns
3108
+ *
3109
+ * @param {object} req
3110
+ * @param {object} res
3111
+ * @param {callback} next
3112
+ * @returns
3102
3113
  */
3103
3114
  this.forward = function(req, res, next) {
3104
3115
  var route = req.routing;
3105
3116
  if ( typeof(route.param.url) == 'undefined' || /^(null|\s*)$/.test(route.param.url) ) {
3106
3117
  self.throwError( new Error('`route.param.url` must be defiend in your route: `'+ route.rule +'`') );
3107
3118
  return;
3108
- }
3109
-
3119
+ }
3120
+
3110
3121
  var param = {};
3111
3122
  for (let p in route.param) {
3112
3123
  if ( /^(url|urlIndex|control|file|title|bundle|project|hostname|port|path|method)$/.test(p) ) {
@@ -3138,14 +3149,14 @@ function SuperController(options) {
3138
3149
  port = route.param.port;
3139
3150
  path = route.param.port;
3140
3151
  }
3141
-
3152
+
3142
3153
  var method = null;
3143
3154
  if ( typeof(route.param.method) != 'undefined' ) {
3144
3155
  method = route.param.method.toLowerCase();
3145
3156
  } else {
3146
3157
  method = req.method.toLowerCase();
3147
3158
  }
3148
-
3159
+
3149
3160
  var opt = {
3150
3161
  ca: ca,
3151
3162
  hostname: hostname,
@@ -3156,7 +3167,7 @@ function SuperController(options) {
3156
3167
  if (self.isCacheless() || self.isLocalScope() ) {
3157
3168
  opt.rejectUnauthorized = false;
3158
3169
  }
3159
-
3170
+
3160
3171
  var obj = req[ req.method.toLowerCase() ];
3161
3172
  // if ( req.files != 'undefined' ) {
3162
3173
  // obj.files = req.files;
@@ -3166,17 +3177,17 @@ function SuperController(options) {
3166
3177
  self.throwError(err);
3167
3178
  return;
3168
3179
  }
3169
-
3180
+
3170
3181
  // TODO - filter : redirect & location
3171
-
3182
+
3172
3183
  // if ( self.isXMLRequest() || !hasViews() || !local.options.isUsingTemplate && !hasViews() || hasViews() && !local.options.isUsingTemplate ) {
3173
3184
  self.renderJSON(result)
3174
3185
  // } else {
3175
3186
  // self.render(result)
3176
- // }
3187
+ // }
3177
3188
  });
3178
3189
  }
3179
-
3190
+
3180
3191
 
3181
3192
  /**
3182
3193
  * Get config
@@ -3243,8 +3254,8 @@ function SuperController(options) {
3243
3254
  } else if ( typeof(code) != 'undefined' ) (
3244
3255
  console.warn('`'+ code +'` not supported : sticking with `short` code')
3245
3256
  )
3246
-
3247
-
3257
+
3258
+
3248
3259
  for ( var i = 0, len = userLocales.length; i< len; ++i ) {
3249
3260
 
3250
3261
  if (userLocales[i][cde]) {
@@ -3297,8 +3308,8 @@ function SuperController(options) {
3297
3308
  } else {
3298
3309
  rules = JSON.clone(local.options.conf.content.forms).rules[form.id] || null;
3299
3310
  }
3300
-
3301
- if (!rules) {
3311
+
3312
+ if (!rules) {
3302
3313
  rules = {};
3303
3314
  console.warn('[CONTROLLER]['+ local.options.conf.bundle +'][Backend validation] did not find matching rules for form.id `'+ form.id +'` for `'+ bundle+' bundle`. Do not Panic if you did not defined any.')
3304
3315
  }
@@ -3307,40 +3318,40 @@ function SuperController(options) {
3307
3318
  return;
3308
3319
  }
3309
3320
  }
3310
-
3321
+
3311
3322
  return rules;
3312
3323
  }
3313
-
3324
+
3314
3325
  this.push = function(payload) {
3315
-
3326
+
3316
3327
  var req = local.req, res = local.res;
3317
3328
  var method = req.method.toLowerCase();
3318
3329
  // if no session defined, will push to all active clients
3319
3330
  var sessionId = ( typeof(req[method].sessionID) != 'undefined' ) ? req[method].sessionID : null;
3320
-
3331
+
3321
3332
  // resume current session
3322
-
3323
- if (!payload) {
3324
- payload = null;
3333
+
3334
+ if (!payload) {
3335
+ payload = null;
3325
3336
  if ( typeof(req[method]) != 'undefined' && typeof(req[method].payload) != 'undefined' ) {
3326
3337
  if ( typeof(payload) == 'string' ) {
3327
3338
  payload = decodeURIComponent(req[method].payload)
3328
3339
  } else {
3329
3340
  payload = JSON.stringify(req[method].payload)
3330
- }
3341
+ }
3331
3342
  }
3332
3343
  } else if ( typeof(payload) == 'object' ) {
3333
3344
  payload = JSON.stringify(payload)
3334
- }
3335
-
3345
+ }
3346
+
3336
3347
  try {
3337
3348
  var clients = null;
3338
3349
  if (sessionId) {
3339
3350
  clients = self.serverInstance.eio.getClientsBySessionId(sessionId);
3340
3351
  if (clients)
3341
3352
  clients.send(payload);
3342
- }
3343
-
3353
+ }
3354
+
3344
3355
  // send to all clients if no specific sessionId defined
3345
3356
  if (!sessionId) {
3346
3357
  clients = self.serverInstance.eio.clients;
@@ -3348,14 +3359,14 @@ function SuperController(options) {
3348
3359
  clients[id].send(payload)
3349
3360
  }
3350
3361
  }
3351
-
3362
+
3352
3363
  res.end();
3353
3364
  } catch(err) {
3354
3365
  self.throwError(err);
3355
3366
  return;
3356
- }
3367
+ }
3357
3368
  }
3358
-
3369
+
3359
3370
  var getSession = function() {
3360
3371
  var session = null;
3361
3372
  if ( typeof(local.req.session) != 'undefined') {
@@ -3365,10 +3376,10 @@ function SuperController(options) {
3365
3376
  if (!session && typeof(local.req.session) != 'undefined' && typeof(local.req.session.user) != 'undefined') {
3366
3377
  session = local.req.session.user;
3367
3378
  }
3368
-
3379
+
3369
3380
  return session;
3370
3381
  }
3371
-
3382
+
3372
3383
  this.isHaltedRequest = function(session) {
3373
3384
  // trying to retrieve session since it is optional
3374
3385
  if ( typeof(session) == 'undefined' ) {
@@ -3381,24 +3392,24 @@ function SuperController(options) {
3381
3392
  // session = local.req.session.user;
3382
3393
  // }
3383
3394
  if (
3384
- !session
3385
- ||
3395
+ !session
3396
+ ||
3386
3397
  typeof(session) != 'undefined'
3387
3398
  && typeof(session.haltedRequest) == 'undefined'
3388
3399
  ) {
3389
3400
  return false;
3390
3401
  }
3391
3402
  }
3392
-
3403
+
3393
3404
  return (typeof(session.haltedRequest) != 'undefined' ) ? true : false;
3394
3405
  }
3395
-
3396
-
3406
+
3407
+
3397
3408
  local.haltedRequestUrlResumed = false;
3398
-
3409
+
3399
3410
  this.pauseRequest = function(data, requestStorage) {
3400
-
3401
-
3411
+
3412
+
3402
3413
  // saving halted request
3403
3414
  var req = local.req
3404
3415
  , res = local.res
@@ -3410,22 +3421,22 @@ function SuperController(options) {
3410
3421
  data : JSON.clone(data)
3411
3422
  }
3412
3423
  ;
3413
-
3424
+
3414
3425
  if (
3415
3426
  typeof(requestStorage) == 'undefined'
3416
3427
  && typeof(req.session) != 'undefined'
3417
3428
  ) {
3418
3429
  requestStorage = req.session;
3419
3430
  }
3420
-
3431
+
3421
3432
  if (
3422
- typeof(requestStorage) == 'undefined'
3433
+ typeof(requestStorage) == 'undefined'
3423
3434
  ) {
3424
3435
  var error = new ApiError('`requestStorage` is required', 424);
3425
3436
  self.throwError(error);
3426
3437
  return;
3427
3438
  }
3428
-
3439
+
3429
3440
  var requestParams = {}, i = 0;
3430
3441
  for (var p in req.params) {
3431
3442
  if (i > 0) {
@@ -3436,13 +3447,13 @@ function SuperController(options) {
3436
3447
  if (requestParams.count() > 0) {
3437
3448
  haltedRequest.params = requestParams;
3438
3449
  }
3439
-
3450
+
3440
3451
  requestStorage.haltedRequest = haltedRequest;
3441
-
3452
+
3442
3453
  return requestStorage;
3443
3454
  }
3444
-
3445
-
3455
+
3456
+
3446
3457
  /**
3447
3458
  * resumeRequest
3448
3459
  * Used to resume an halted request
@@ -3450,35 +3461,35 @@ function SuperController(options) {
3450
3461
  * - a middleware attached `haltedRequest` to userSession
3451
3462
  * OR
3452
3463
  * - a persistant object where `haltedRequest` is attached
3453
- *
3454
- * @param {object} req
3455
- * @param {object} res
3464
+ *
3465
+ * @param {object} req
3466
+ * @param {object} res
3456
3467
  * @param {callback|null} next
3457
3468
  * @param {object} [requestStorage] - Will try to use sessionStorage if not passed
3458
3469
  */
3459
3470
  this.resumeRequest = function(requestStorage) {
3460
-
3471
+
3461
3472
  if (local.haltedRequestUrlResumed)
3462
3473
  return;
3463
-
3474
+
3464
3475
  var haltedRequest = null
3465
3476
  , req = local.req
3466
3477
  , res = local.res
3467
3478
  , next = local.next
3468
3479
  ;
3469
-
3480
+
3470
3481
  if (
3471
3482
  typeof(requestStorage) == 'undefined'
3472
3483
  && typeof(req.session) != 'undefined'
3473
3484
  ) {
3474
3485
  requestStorage = req.session;
3475
3486
  }
3476
-
3487
+
3477
3488
  if (
3478
- typeof(requestStorage) == 'undefined'
3489
+ typeof(requestStorage) == 'undefined'
3479
3490
  ||
3480
- typeof(requestStorage) != 'undefined'
3481
- && typeof(requestStorage.haltedRequest) == 'undefined'
3491
+ typeof(requestStorage) != 'undefined'
3492
+ && typeof(requestStorage.haltedRequest) == 'undefined'
3482
3493
  ) {
3483
3494
  var error = new ApiError('`requestStorage.haltedRequest` is required', 424);
3484
3495
  self.throwError(error);
@@ -3493,11 +3504,11 @@ function SuperController(options) {
3493
3504
  if (req.method.toLowerCase() == method) {
3494
3505
  data = merge(data, req[method])
3495
3506
  }
3496
-
3497
- delete req[method];
3507
+
3508
+ delete req[method];
3498
3509
  }
3499
-
3500
-
3510
+
3511
+
3501
3512
  var dataAsParams = {};
3502
3513
  if (data.count() > 0) {
3503
3514
  dataAsParams = JSON.clone(haltedRequest.data);
@@ -3509,25 +3520,25 @@ function SuperController(options) {
3509
3520
  requiredController = self.requireController(haltedRequest.routing.namespace, self._options );
3510
3521
  } catch (err) {
3511
3522
  self.throwError(err);
3512
- }
3523
+ }
3513
3524
  }
3514
3525
  req.routing = haltedRequest.routing;
3515
3526
  req.method = haltedRequest.method;
3516
3527
  req[haltedRequest.method] = data;
3517
-
3528
+
3518
3529
  local.haltedRequestUrlResumed = true;
3519
- if ( /GET/i.test(req.method) ) {
3530
+ if ( /GET/i.test(req.method) ) {
3520
3531
  if ( typeof(requestStorage.haltedRequest) != 'undefined' ) {
3521
3532
  delete requestStorage.haltedRequest;
3522
3533
  }
3523
3534
  delete requestStorage.haltedRequest;
3524
3535
  delete requestStorage.inheritedData;
3525
3536
  requestStorage.haltedRequestUrlResumed = url;
3526
-
3537
+
3527
3538
  requiredController.redirect(url, true);
3528
3539
  } else {
3529
3540
  local.onHaltedRequestResumed = function(err) {
3530
- if (!err) {
3541
+ if (!err) {
3531
3542
  delete requestStorage.haltedRequest;
3532
3543
  delete requestStorage.inheritedData;
3533
3544
  }
@@ -3535,7 +3546,7 @@ function SuperController(options) {
3535
3546
  if ( typeof(next) == 'function' ) {
3536
3547
  console.warn('About to override `next` param');
3537
3548
  }
3538
-
3549
+
3539
3550
  try {
3540
3551
  requiredController[req.routing.param.control](req, res, next);
3541
3552
  // consuming it
@@ -3544,12 +3555,12 @@ function SuperController(options) {
3544
3555
  console.error('[ BUNDLE ][ '+ local.options.conf.bundle +' ][ Controller ] Could not resume haltedRequest\n' + err.stack );
3545
3556
  self.throwError(err);
3546
3557
  }
3547
-
3548
-
3549
- }
3558
+
3559
+
3560
+ }
3550
3561
  }
3551
-
3552
-
3562
+
3563
+
3553
3564
  this.renderCustomError = function (req, res, next) {
3554
3565
 
3555
3566
  // preventing multiple call of self.renderWithoutLayout() when controller is rendering from another required controller
@@ -3559,13 +3570,13 @@ function SuperController(options) {
3559
3570
  local.options.isRenderingCustomError = true;
3560
3571
 
3561
3572
  //local.options.isWithoutLayout = true;
3562
-
3573
+
3563
3574
  var data = null;
3564
3575
  if ( typeof(req.routing.param.error) != 'undefined' ) {
3565
3576
  data = JSON.clone(req.routing.param.error) || {};
3566
3577
  delete req.routing.param.error
3567
3578
  }
3568
-
3579
+
3569
3580
  var session = getSession();
3570
3581
  if (session) {
3571
3582
  data.session = JSON.clone(session)
@@ -3603,13 +3614,13 @@ function SuperController(options) {
3603
3614
  //assets: {}
3604
3615
  };
3605
3616
  errOptions = merge(localOptions, local.options);
3606
-
3607
-
3617
+
3618
+
3608
3619
  }
3609
3620
  delete local.options.namespace;
3610
3621
  self.render(data, displayToolbar, errOptions);
3611
3622
  }
3612
-
3623
+
3613
3624
 
3614
3625
  /**
3615
3626
  * Throw error
@@ -3623,7 +3634,7 @@ function SuperController(options) {
3623
3634
  this.throwError = function(res, code, msg) {
3624
3635
  self.isProcessingError = true;
3625
3636
  var errorObject = null; // to be returned
3626
-
3637
+
3627
3638
  // preventing multiple call of self.throwError() when controller is rendering from another required controller
3628
3639
  if (local.options.renderingStack.length > 1) {
3629
3640
  return false
@@ -3634,21 +3645,21 @@ function SuperController(options) {
3634
3645
  // err.fallback must be a valide route object or a url string
3635
3646
  var fallback = null;
3636
3647
  var standardErrorMessage = null;
3637
- if (
3638
- arguments[0] instanceof Error
3648
+ if (
3649
+ arguments[0] instanceof Error
3639
3650
  || arguments.length == 1 && typeof(res) == 'object'
3640
3651
  || arguments[arguments.length-1] instanceof Error
3641
- || typeof(arguments[arguments.length-1]) == 'string' && !(arguments[0] instanceof Error)
3652
+ || typeof(arguments[arguments.length-1]) == 'string' && !(arguments[0] instanceof Error)
3642
3653
  ) {
3643
-
3654
+
3644
3655
  code = ( res && typeof(res.status) != 'undefined' ) ? res.status : 500;
3645
-
3656
+
3646
3657
  if ( typeof(statusCodes[code]) != 'undefined' ) {
3647
3658
  standardErrorMessage = statusCodes[code];
3648
3659
  } else {
3649
3660
  console.warn('[ ApiValidator ] statusCode `'+ code +'` not matching any definition in `'+_( getPath('gina').core + '/status.codes')+'`\nPlease contact the Gina dev team to add one if required');
3650
3661
  }
3651
-
3662
+
3652
3663
  errorObject = {
3653
3664
  status : code,
3654
3665
  error : res.error || res.message || standardErrorMessage
@@ -3663,17 +3674,17 @@ function SuperController(options) {
3663
3674
  } else if (res.message) {
3664
3675
  console.warn('[ Controller ] Ignoring message because of the format.\n'+res.message)
3665
3676
  }
3666
-
3677
+
3667
3678
  } else if ( typeof(arguments[arguments.length-1]) == 'string' ) {
3668
3679
  // formated error
3669
3680
  errorObject.message = arguments[arguments.length-1]
3670
3681
  } else if (
3671
- arguments[arguments.length-1] instanceof Error
3672
- || typeof(res) == 'object' && typeof(res.stack) != 'undefined'
3682
+ arguments[arguments.length-1] instanceof Error
3683
+ || typeof(res) == 'object' && typeof(res.stack) != 'undefined'
3673
3684
  ) {
3674
3685
  errorObject = merge(arguments[arguments.length-1], errorObject)
3675
3686
  }
3676
-
3687
+
3677
3688
  if ( typeof(res.fallback) != 'undefined' ) {
3678
3689
  fallback = res.fallback
3679
3690
  }
@@ -3685,7 +3696,7 @@ function SuperController(options) {
3685
3696
  code = res || 500;
3686
3697
  res = local.res;
3687
3698
  }
3688
-
3699
+
3689
3700
  var responseHeaders = res.getHeaders() || local.res.getHeaders();
3690
3701
  var req = local.req;
3691
3702
  var next = local.next;
@@ -3694,18 +3705,18 @@ function SuperController(options) {
3694
3705
  // but if we are calling it from a view, we should render the error back to the view
3695
3706
  if ( self.isXMLRequest() || !hasViews() && !/delete/i.test(req.method) || !local.options.isUsingTemplate && !hasViews() || hasViews() && !local.options.isUsingTemplate ) {
3696
3707
  // fallback interception
3697
- if ( fallback ) {
3708
+ if ( fallback ) {
3698
3709
  if ( typeof(fallback) == 'string' ){ // string url: user provided
3699
3710
  return self.redirect( fallback, true )
3700
3711
  } else {
3701
3712
  // else, using url from route object
3702
3713
  // Reminder
3703
3714
  // Here, we use route.toUrl() intead of
3704
- // route.url to support x-bundle com
3715
+ // route.url to support x-bundle com
3705
3716
  return self.redirect( fallback.toUrl() );
3706
3717
  }
3707
3718
  }
3708
-
3719
+
3709
3720
  // allowing this.throwError(err)
3710
3721
  if ( typeof(code) == 'object' && !msg && typeof(code.status) != 'undefined' && typeof(code.error) != 'undefined' ) {
3711
3722
  msg = code.error || code.message;
@@ -3725,7 +3736,7 @@ function SuperController(options) {
3725
3736
  // res.writeHead(code, { 'content-type': bundleConf.server.coreConfiguration.mime['json']} );
3726
3737
  // }
3727
3738
  // }
3728
-
3739
+
3729
3740
  // TODO - test with internet explorer then remove this if working
3730
3741
  if ( typeof(req.headers['user-agent']) != 'undefined' ) {
3731
3742
  if ( /msie/i.test(req.headers['user-agent']) ) {
@@ -3743,8 +3754,8 @@ function SuperController(options) {
3743
3754
  res.writeHead(code, "content-type", bundleConf.server.coreConfiguration.mime['json']+ '; charset='+ bundleConf.encoding);
3744
3755
  }
3745
3756
 
3746
-
3747
-
3757
+
3758
+
3748
3759
  if (!errorObject) {
3749
3760
  errorObject = {
3750
3761
  status: code,
@@ -3754,7 +3765,7 @@ function SuperController(options) {
3754
3765
  stack: msg.stack
3755
3766
  }
3756
3767
  }
3757
-
3768
+
3758
3769
  var errOutput = null, output = errorObject.toString();
3759
3770
  if ( output == '[object Object]' ) {
3760
3771
  errOutput = JSON.stringify(errorObject);
@@ -3766,15 +3777,15 @@ function SuperController(options) {
3766
3777
  }
3767
3778
  );
3768
3779
  }
3769
-
3770
- console.error('[ BUNDLE ][ '+ bundleConf.bundle +' ][ Controller ] '+ req.method +' ['+res.statusCode +'] '+ req.url +'\n'+ errOutput);
3780
+
3781
+ console.error('[ BUNDLE ][ '+ bundleConf.bundle +' ][ Controller ] '+ req.method +' ['+res.statusCode +'] '+ req.url +'\n'+ errOutput);
3771
3782
  return res.end(errOutput);
3772
3783
  } else {
3773
-
3774
-
3775
- console.error(req.method +' ['+ errorObject.status +'] '+ req.url);
3776
-
3777
-
3784
+
3785
+
3786
+ console.error(req.method +' ['+ errorObject.status +'] '+ req.url + '\n'+ (errorObject.stack||errorObject.message));
3787
+
3788
+
3778
3789
  // intercept none HTML mime types
3779
3790
  var url = unescape(local.req.url) /// avoid %20
3780
3791
  , ext = null
@@ -3789,8 +3800,8 @@ function SuperController(options) {
3789
3800
  if ( !ext || /^(html|htm)$/i.test(ext) ) {
3790
3801
  isHtmlContent = true;
3791
3802
  }
3792
-
3793
- if (
3803
+
3804
+ if (
3794
3805
  isHtmlContent
3795
3806
  && typeof(bundleConf.content.templates._common.errorFiles) != 'undefined'
3796
3807
  && typeof(bundleConf.content.templates._common.errorFiles[code]) != 'undefined'
@@ -3810,11 +3821,11 @@ function SuperController(options) {
3810
3821
  //message : errorObject.message || msg || null,
3811
3822
  pathname : url
3812
3823
  };
3813
-
3824
+
3814
3825
  if ( errorObject ) {
3815
3826
  eData = merge(errorObject, eData);
3816
3827
  }
3817
-
3828
+
3818
3829
  if ( typeof(msg) == 'object' ) {
3819
3830
  if ( typeof(msg.stack) != 'undefined' ) {
3820
3831
  eData.stack = msg.stack
@@ -3823,8 +3834,8 @@ function SuperController(options) {
3823
3834
  eData.message = msg.message
3824
3835
  }
3825
3836
  }
3826
- if (
3827
- code
3837
+ if (
3838
+ code
3828
3839
  // See: framework/${version}/core/status.code
3829
3840
  && typeof(bundleConf.server.coreConfiguration.statusCodes[code]) != 'undefined'
3830
3841
  ) {
@@ -3834,13 +3845,13 @@ function SuperController(options) {
3834
3845
  // if ( typeof(local.req.routing) != 'undefined' ) {
3835
3846
  // eData.routing = local.req.routing;
3836
3847
  // }
3837
-
3848
+
3838
3849
  if (typeof(bundleConf.content.templates._common.errorFiles[code]) != 'undefined') {
3839
3850
  eFilename = bundleConf.content.templates._common.errorFiles[code];
3840
3851
  } else {
3841
3852
  eFilename = bundleConf.content.templates._common.errorFiles[eCode];
3842
3853
  }
3843
-
3854
+
3844
3855
  if (!local.options.isRenderingCustomError) {
3845
3856
  var eRule = 'custom-error-page@'+ bundle;
3846
3857
  var routeObj = bundleConf.content.routing[eRule];
@@ -3851,16 +3862,16 @@ function SuperController(options) {
3851
3862
  routeObj.param.error = eData;
3852
3863
  routeObj.param.displayToolbar = self.isCacheless();
3853
3864
  routeObj.param.isLocalOptionResetNeeded = true;
3854
-
3855
-
3865
+
3866
+
3856
3867
  local.req.routing = routeObj;
3857
3868
  local.req.params.errorObject = errorObject;
3858
3869
  self.renderCustomError(local.req, res, local.next);
3859
3870
  return;
3860
3871
  }
3861
-
3872
+
3862
3873
  }
3863
-
3874
+
3864
3875
  // if (!errorObject) {
3865
3876
  // errorObject = {
3866
3877
  // status: code,
@@ -3871,7 +3882,7 @@ function SuperController(options) {
3871
3882
  // }
3872
3883
  // }
3873
3884
  var msgString = '<h1 class="status">Error '+ code +'.</h1>';
3874
-
3885
+
3875
3886
  console.error('[ BUNDLE ][ '+ local.options.conf.bundle +' ][ Controller ] `this.'+ req.routing.param.control +'(...)` ['+res.statusCode +'] '+ req.url);
3876
3887
  if ( typeof(msg) == 'object' ) {
3877
3888
 
@@ -3913,7 +3924,7 @@ function SuperController(options) {
3913
3924
  if (typeof(errorObject) != 'undefined' && errorObject && typeof(errorObject.stack) != 'undefined' ) {
3914
3925
  stack = errorObject.stack
3915
3926
  }
3916
-
3927
+
3917
3928
  if (title) {
3918
3929
  msgString += '<pre class="'+ eCode +' title">'+ title +'</pre>';
3919
3930
  }
@@ -3922,7 +3933,7 @@ function SuperController(options) {
3922
3933
  }
3923
3934
  if (stack) {
3924
3935
  msgString += '<pre class="'+ eCode +' stack">'+ stack +'</pre>';
3925
- }
3936
+ }
3926
3937
  }
3927
3938
  res.writeHead(code, { 'content-type': bundleConf.server.coreConfiguration.mime[ext]+'; charset='+ bundleConf.encoding } );
3928
3939
  // if ( isHtmlContent && hasCustomErrorFile ) {
@@ -3931,7 +3942,7 @@ function SuperController(options) {
3931
3942
  //if ( isHtmlContent && !hasCustomErrorFile ) {
3932
3943
  res.end(msgString);
3933
3944
  //}
3934
-
3945
+
3935
3946
  return;
3936
3947
  }
3937
3948
  } else {