gina 0.0.9-p91b → 0.1.1-alpha.2

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 (466) hide show
  1. package/INSTALL.md +46 -0
  2. package/{core/asset/html/static.html → Icon/r} +0 -0
  3. package/LICENSE +1 -1
  4. package/README-4Contributors.md +96 -0
  5. package/README.md +296 -104
  6. package/bin/cli +287 -0
  7. package/bin/cli-debug +60 -0
  8. package/bin/cmd +184 -0
  9. package/bin/gina +180 -0
  10. package/config/logger.json +17 -0
  11. package/doc/framework/cli/doc.json +9 -0
  12. package/doc/framework/index.md +60 -0
  13. package/framework/v0.1.1-alpha.2/AUTHORS +7 -0
  14. package/{core/utils/lib/inherits → framework/v0.1.1-alpha.2}/LICENSE +1 -1
  15. package/framework/v0.1.1-alpha.2/VERSION +1 -0
  16. package/{core/locales/dist/language/en.json → framework/v0.1.1-alpha.2/core/asset/html/nolayout.html} +0 -0
  17. package/{core/locales/dist/language/fr.json → framework/v0.1.1-alpha.2/core/asset/html/static.html} +0 -0
  18. package/{core → framework/v0.1.1-alpha.2/core}/asset/img/android-chrome-192x192.png +0 -0
  19. package/{core → framework/v0.1.1-alpha.2/core}/asset/img/android-chrome-512x512.png +0 -0
  20. package/{core → framework/v0.1.1-alpha.2/core}/asset/img/apple-touch-icon.png +0 -0
  21. package/{core → framework/v0.1.1-alpha.2/core}/asset/img/favicon-16x16.png +0 -0
  22. package/{core → framework/v0.1.1-alpha.2/core}/asset/img/favicon-32x32.png +0 -0
  23. package/{core → framework/v0.1.1-alpha.2/core}/asset/img/favicon.ico +0 -0
  24. package/framework/v0.1.1-alpha.2/core/asset/js/plugin/dist/gina.js +20904 -0
  25. package/framework/v0.1.1-alpha.2/core/asset/js/plugin/dist/gina.js.map +56 -0
  26. package/framework/v0.1.1-alpha.2/core/asset/js/plugin/dist/gina.min.css +1 -0
  27. package/framework/v0.1.1-alpha.2/core/asset/js/plugin/dist/gina.min.css.map +1 -0
  28. package/framework/v0.1.1-alpha.2/core/asset/js/plugin/dist/gina.min.js +736 -0
  29. package/framework/v0.1.1-alpha.2/core/asset/js/plugin/dist/gina.min.js.map +56 -0
  30. package/framework/v0.1.1-alpha.2/core/asset/js/plugin/dist/gina.onload.min.js +5 -0
  31. package/framework/v0.1.1-alpha.2/core/asset/js/plugin/dist/gina.onload.min.js.map +8 -0
  32. package/framework/v0.1.1-alpha.2/core/asset/js/plugin/readme.md +192 -0
  33. package/framework/v0.1.1-alpha.2/core/asset/js/plugin/uuid.json +23 -0
  34. package/framework/v0.1.1-alpha.2/core/config.js +2308 -0
  35. package/framework/v0.1.1-alpha.2/core/connectors/couchbase/index.js +757 -0
  36. package/framework/v0.1.1-alpha.2/core/connectors/couchbase/lib/connector.js +20 -0
  37. package/framework/v0.1.1-alpha.2/core/connectors/couchbase/lib/connector.v2.js +429 -0
  38. package/framework/v0.1.1-alpha.2/core/connectors/couchbase/lib/connector.v3.js +432 -0
  39. package/framework/v0.1.1-alpha.2/core/connectors/couchbase/lib/n1ql.js +14 -0
  40. package/framework/v0.1.1-alpha.2/core/connectors/couchbase/lib/session-store.js +21 -0
  41. package/framework/v0.1.1-alpha.2/core/connectors/couchbase/lib/session-store.v2.js +258 -0
  42. package/framework/v0.1.1-alpha.2/core/connectors/couchbase/lib/session-store.v3.js +341 -0
  43. package/{core → framework/v0.1.1-alpha.2/core}/controller/controller.framework.js +3 -2
  44. package/framework/v0.1.1-alpha.2/core/controller/controller.js +3990 -0
  45. package/{core → framework/v0.1.1-alpha.2/core}/controller/index.js +5 -5
  46. package/framework/v0.1.1-alpha.2/core/deps/busboy/.travis.yml +17 -0
  47. package/framework/v0.1.1-alpha.2/core/deps/busboy/LICENSE +19 -0
  48. package/framework/v0.1.1-alpha.2/core/deps/busboy/README.md +225 -0
  49. package/framework/v0.1.1-alpha.2/core/deps/busboy/deps/encoding/encoding-indexes.js +73 -0
  50. package/framework/v0.1.1-alpha.2/core/deps/busboy/deps/encoding/encoding.js +2391 -0
  51. package/framework/v0.1.1-alpha.2/core/deps/busboy/lib/main.js +89 -0
  52. package/framework/v0.1.1-alpha.2/core/deps/busboy/lib/types/multipart.js +328 -0
  53. package/framework/v0.1.1-alpha.2/core/deps/busboy/lib/types/urlencoded.js +214 -0
  54. package/framework/v0.1.1-alpha.2/core/deps/busboy/lib/utils.js +191 -0
  55. package/framework/v0.1.1-alpha.2/core/deps/busboy/package.json +69 -0
  56. package/framework/v0.1.1-alpha.2/core/deps/swig-client/swig-2.0.0.min.js +5 -0
  57. package/{core → framework/v0.1.1-alpha.2/core}/dev/index.js +5 -5
  58. package/{core → framework/v0.1.1-alpha.2/core}/dev/lib/class.js +1 -1
  59. package/{core → framework/v0.1.1-alpha.2/core}/dev/lib/factory.js +1 -1
  60. package/{core → framework/v0.1.1-alpha.2/core}/dev/lib/tools.js +0 -0
  61. package/framework/v0.1.1-alpha.2/core/gna.js +1070 -0
  62. package/{core → framework/v0.1.1-alpha.2/core}/locales/README.md +41 -2
  63. package/{core → framework/v0.1.1-alpha.2/core}/locales/currency.json +0 -0
  64. package/{core/plugins/README.md → framework/v0.1.1-alpha.2/core/locales/dist/language/en.json} +0 -0
  65. package/{core/plugins/lib/intl/README.md → framework/v0.1.1-alpha.2/core/locales/dist/language/fr.json} +0 -0
  66. package/{core → framework/v0.1.1-alpha.2/core}/locales/dist/region/en.json +0 -0
  67. package/framework/v0.1.1-alpha.2/core/locales/dist/region/fr.json +9492 -0
  68. package/{core → framework/v0.1.1-alpha.2/core}/locales/index.js +5 -4
  69. package/{core → framework/v0.1.1-alpha.2/core}/locales/src/make.js +15 -12
  70. package/{core → framework/v0.1.1-alpha.2/core}/locales/src/resources/currency.csv +0 -0
  71. package/{core → framework/v0.1.1-alpha.2/core}/locales/src/resources/region.csv +0 -0
  72. package/{core → framework/v0.1.1-alpha.2/core}/locales/src/resources/region.mapping.json +0 -0
  73. package/{core → framework/v0.1.1-alpha.2/core}/mime.types +0 -0
  74. package/{core → framework/v0.1.1-alpha.2/core}/model/entity.js +156 -196
  75. package/{core → framework/v0.1.1-alpha.2/core}/model/index.js +67 -48
  76. package/{core → framework/v0.1.1-alpha.2/core}/model/template/entityFactory.js +2 -2
  77. package/{core → framework/v0.1.1-alpha.2/core}/model/template/index.js +8 -10
  78. package/{core/plugins/lib/storage → framework/v0.1.1-alpha.2/core/plugins}/README.md +0 -0
  79. package/{core → framework/v0.1.1-alpha.2/core}/plugins/index.js +3 -3
  80. package/{core/plugins/lib/validator → framework/v0.1.1-alpha.2/core/plugins/lib/file}/README.md +0 -0
  81. package/{core/plugins/lib/intl → framework/v0.1.1-alpha.2/core/plugins/lib/file}/build.json +0 -0
  82. package/framework/v0.1.1-alpha.2/core/plugins/lib/file/package.json +25 -0
  83. package/{core/utils/lib/collection → framework/v0.1.1-alpha.2/core/plugins/lib/intl}/README.md +0 -0
  84. package/{core/plugins/lib/storage → framework/v0.1.1-alpha.2/core/plugins/lib/intl}/build.json +0 -0
  85. package/{core → framework/v0.1.1-alpha.2/core}/plugins/lib/intl/package.json +3 -3
  86. package/{core → framework/v0.1.1-alpha.2/core}/plugins/lib/intl/src/main.js +17 -1
  87. package/{core/utils/lib/routing → framework/v0.1.1-alpha.2/core/plugins/lib/storage}/README.md +0 -0
  88. package/{core/plugins/lib/validator → framework/v0.1.1-alpha.2/core/plugins/lib/storage}/build.json +0 -0
  89. package/{core → framework/v0.1.1-alpha.2/core}/plugins/lib/storage/package.json +2 -2
  90. package/{core → framework/v0.1.1-alpha.2/core}/plugins/lib/storage/src/main.js +91 -85
  91. package/{core/utils/lib/url → framework/v0.1.1-alpha.2/core/plugins/lib/validator}/README.md +0 -0
  92. package/{core/utils/lib/collection → framework/v0.1.1-alpha.2/core/plugins/lib/validator}/build.json +0 -0
  93. package/{core → framework/v0.1.1-alpha.2/core}/plugins/lib/validator/package.json +3 -3
  94. package/framework/v0.1.1-alpha.2/core/plugins/lib/validator/src/form-validator.js +1762 -0
  95. package/framework/v0.1.1-alpha.2/core/plugins/lib/validator/src/main.js +6917 -0
  96. package/framework/v0.1.1-alpha.2/core/router.js +664 -0
  97. package/framework/v0.1.1-alpha.2/core/server.express.js +213 -0
  98. package/framework/v0.1.1-alpha.2/core/server.isaac.js +386 -0
  99. package/framework/v0.1.1-alpha.2/core/server.js +3010 -0
  100. package/{core → framework/v0.1.1-alpha.2/core}/status.codes +8 -0
  101. package/framework/v0.1.1-alpha.2/core/template/boilerplate/bundle/config/app.json +6 -0
  102. package/framework/v0.1.1-alpha.2/core/template/boilerplate/bundle/config/routing.json +11 -0
  103. package/framework/v0.1.1-alpha.2/core/template/boilerplate/bundle/config/settings.json +9 -0
  104. package/framework/v0.1.1-alpha.2/core/template/boilerplate/bundle/config/settings.server.json +30 -0
  105. package/framework/v0.1.1-alpha.2/core/template/boilerplate/bundle/config/templates.json +42 -0
  106. package/framework/v0.1.1-alpha.2/core/template/boilerplate/bundle/controllers/controller.content.js +39 -0
  107. package/framework/v0.1.1-alpha.2/core/template/boilerplate/bundle/controllers/controller.js +30 -0
  108. package/framework/v0.1.1-alpha.2/core/template/boilerplate/bundle/controllers/setup.js +111 -0
  109. package/{core/template/samples → framework/v0.1.1-alpha.2/core/template/boilerplate}/bundle/index.js +0 -0
  110. package/{core/template/samples/bundle → framework/v0.1.1-alpha.2/core/template/boilerplate/bundle_namespace}/controllers/controller.js +9 -7
  111. package/{core/template/views → framework/v0.1.1-alpha.2/core/template/boilerplate/bundle_public}/css/default.css +0 -0
  112. package/{core/template/views → framework/v0.1.1-alpha.2/core/template/boilerplate/bundle_public}/css/vendor/readme.md +0 -0
  113. package/{core/template/views → framework/v0.1.1-alpha.2/core/template/boilerplate/bundle_public}/favicon.ico +0 -0
  114. package/framework/v0.1.1-alpha.2/core/template/boilerplate/bundle_public/js/vendor/readme.md +1 -0
  115. package/framework/v0.1.1-alpha.2/core/template/boilerplate/bundle_public/readme.md +1 -0
  116. package/framework/v0.1.1-alpha.2/core/template/boilerplate/bundle_templates/handlers/main.js +24 -0
  117. package/{core/template/views/html/default.html → framework/v0.1.1-alpha.2/core/template/boilerplate/bundle_templates/html/homepage.html} +0 -0
  118. package/{core/template/views/html/layout.html → framework/v0.1.1-alpha.2/core/template/boilerplate/bundle_templates/html/layout/main.html} +2 -2
  119. package/{core → framework/v0.1.1-alpha.2/core}/template/command/gina.bat.tpl +0 -0
  120. package/{core → framework/v0.1.1-alpha.2/core}/template/command/gina.tpl +1 -1
  121. package/framework/v0.1.1-alpha.2/core/template/conf/env.json +76 -0
  122. package/{core/template/conf/project.json → framework/v0.1.1-alpha.2/core/template/conf/manifest.json} +1 -0
  123. package/{core → framework/v0.1.1-alpha.2/core}/template/conf/package.json +2 -2
  124. package/framework/v0.1.1-alpha.2/core/template/conf/settings.json +92 -0
  125. package/framework/v0.1.1-alpha.2/core/template/conf/statics.json +10 -0
  126. package/framework/v0.1.1-alpha.2/core/template/conf/templates.json +37 -0
  127. package/{core → framework/v0.1.1-alpha.2/core}/template/error/client/json/401.json +0 -0
  128. package/{core → framework/v0.1.1-alpha.2/core}/template/error/client/json/403.json +0 -0
  129. package/{core → framework/v0.1.1-alpha.2/core}/template/error/client/json/404.json +0 -0
  130. package/{core → framework/v0.1.1-alpha.2/core}/template/error/server/html/50x.html +0 -0
  131. package/{core → framework/v0.1.1-alpha.2/core}/template/error/server/json/500.json +0 -0
  132. package/{core → framework/v0.1.1-alpha.2/core}/template/error/server/json/503.json +0 -0
  133. package/{core/utils/lib/routing/build.json → framework/v0.1.1-alpha.2/core/template/extensions/logger/config.json} +0 -0
  134. package/{core/utils → framework/v0.1.1-alpha.2}/helpers/console.js +3 -3
  135. package/{core/utils → framework/v0.1.1-alpha.2}/helpers/context.js +240 -49
  136. package/framework/v0.1.1-alpha.2/helpers/dateFormat.js +528 -0
  137. package/framework/v0.1.1-alpha.2/helpers/index.js +79 -0
  138. package/framework/v0.1.1-alpha.2/helpers/json/README.md +0 -0
  139. package/framework/v0.1.1-alpha.2/helpers/json/package.json +20 -0
  140. package/framework/v0.1.1-alpha.2/helpers/json/src/main.js +97 -0
  141. package/{core/utils → framework/v0.1.1-alpha.2}/helpers/path.js +342 -140
  142. package/framework/v0.1.1-alpha.2/helpers/plugins/README.md +4 -0
  143. package/framework/v0.1.1-alpha.2/helpers/plugins/package.json +20 -0
  144. package/framework/v0.1.1-alpha.2/helpers/plugins/src/api-error.js +160 -0
  145. package/framework/v0.1.1-alpha.2/helpers/plugins/src/main.js +32 -0
  146. package/framework/v0.1.1-alpha.2/helpers/prototypes.js +218 -0
  147. package/{core/utils → framework/v0.1.1-alpha.2}/helpers/task.js +49 -29
  148. package/{core/utils → framework/v0.1.1-alpha.2}/helpers/text.js +7 -7
  149. package/framework/v0.1.1-alpha.2/lib/archiver/README.md +0 -0
  150. package/framework/v0.1.1-alpha.2/lib/archiver/build.json +0 -0
  151. package/framework/v0.1.1-alpha.2/lib/archiver/package.json +20 -0
  152. package/framework/v0.1.1-alpha.2/lib/archiver/src/dep/jszip.min.js +15 -0
  153. package/framework/v0.1.1-alpha.2/lib/archiver/src/main.js +499 -0
  154. package/framework/v0.1.1-alpha.2/lib/cmd/aliases.json +13 -0
  155. package/framework/v0.1.1-alpha.2/lib/cmd/bundle/add.js +507 -0
  156. package/framework/v0.1.1-alpha.2/lib/cmd/bundle/arguments.json +4 -0
  157. package/framework/v0.1.1-alpha.2/lib/cmd/bundle/copy.js +15 -0
  158. package/framework/v0.1.1-alpha.2/lib/cmd/bundle/cp.js +2 -0
  159. package/framework/v0.1.1-alpha.2/lib/cmd/bundle/help.js +28 -0
  160. package/framework/v0.1.1-alpha.2/lib/cmd/bundle/help.txt +67 -0
  161. package/framework/v0.1.1-alpha.2/lib/cmd/bundle/list.js +129 -0
  162. package/framework/v0.1.1-alpha.2/lib/cmd/bundle/remove.js +229 -0
  163. package/framework/v0.1.1-alpha.2/lib/cmd/bundle/rename.js +4 -0
  164. package/framework/v0.1.1-alpha.2/lib/cmd/bundle/restart.js +235 -0
  165. package/framework/v0.1.1-alpha.2/lib/cmd/bundle/rm.js +2 -0
  166. package/framework/v0.1.1-alpha.2/lib/cmd/bundle/start.js +394 -0
  167. package/framework/v0.1.1-alpha.2/lib/cmd/bundle/status.js +3 -0
  168. package/framework/v0.1.1-alpha.2/lib/cmd/bundle/stop.js +232 -0
  169. package/framework/v0.1.1-alpha.2/lib/cmd/env/add.js +436 -0
  170. package/framework/v0.1.1-alpha.2/lib/cmd/env/get.js +62 -0
  171. package/framework/v0.1.1-alpha.2/lib/cmd/env/help.js +28 -0
  172. package/framework/v0.1.1-alpha.2/lib/cmd/env/help.txt +33 -0
  173. package/framework/v0.1.1-alpha.2/lib/cmd/env/link-dev.js +80 -0
  174. package/framework/v0.1.1-alpha.2/lib/cmd/env/list.js +111 -0
  175. package/framework/v0.1.1-alpha.2/lib/cmd/env/remove.js +150 -0
  176. package/framework/v0.1.1-alpha.2/lib/cmd/env/rm.js +2 -0
  177. package/framework/v0.1.1-alpha.2/lib/cmd/env/set.js +57 -0
  178. package/framework/v0.1.1-alpha.2/lib/cmd/env/unset.js +44 -0
  179. package/framework/v0.1.1-alpha.2/lib/cmd/env/use.js +79 -0
  180. package/framework/v0.1.1-alpha.2/lib/cmd/framework/dot.js +70 -0
  181. package/framework/v0.1.1-alpha.2/lib/cmd/framework/get.js +0 -0
  182. package/framework/v0.1.1-alpha.2/lib/cmd/framework/help.js +39 -0
  183. package/framework/v0.1.1-alpha.2/lib/cmd/framework/help.txt +31 -0
  184. package/framework/v0.1.1-alpha.2/lib/cmd/framework/init.js +514 -0
  185. package/{core/utils/lib/cmd → framework/v0.1.1-alpha.2/lib/cmd/framework}/msg.json +3 -3
  186. package/framework/v0.1.1-alpha.2/lib/cmd/framework/open.js +50 -0
  187. package/framework/v0.1.1-alpha.2/lib/cmd/framework/restart.js +124 -0
  188. package/framework/v0.1.1-alpha.2/lib/cmd/framework/set.js +161 -0
  189. package/framework/v0.1.1-alpha.2/lib/cmd/framework/start.js +96 -0
  190. package/framework/v0.1.1-alpha.2/lib/cmd/framework/status.js +72 -0
  191. package/framework/v0.1.1-alpha.2/lib/cmd/framework/stop.js +159 -0
  192. package/framework/v0.1.1-alpha.2/lib/cmd/framework/tail.js +183 -0
  193. package/framework/v0.1.1-alpha.2/lib/cmd/framework/update.js +0 -0
  194. package/framework/v0.1.1-alpha.2/lib/cmd/framework/version.js +44 -0
  195. package/framework/v0.1.1-alpha.2/lib/cmd/gina-dev.1.md +66 -0
  196. package/framework/v0.1.1-alpha.2/lib/cmd/gina-framework.1.md +100 -0
  197. package/framework/v0.1.1-alpha.2/lib/cmd/gina.1.md +79 -0
  198. package/framework/v0.1.1-alpha.2/lib/cmd/helper.js +1147 -0
  199. package/framework/v0.1.1-alpha.2/lib/cmd/index.js +170 -0
  200. package/framework/v0.1.1-alpha.2/lib/cmd/msg.json +20 -0
  201. package/framework/v0.1.1-alpha.2/lib/cmd/port/help.js +28 -0
  202. package/framework/v0.1.1-alpha.2/lib/cmd/port/help.txt +31 -0
  203. package/framework/v0.1.1-alpha.2/lib/cmd/port/inc/scan.js +108 -0
  204. package/framework/v0.1.1-alpha.2/lib/cmd/port/list.js +176 -0
  205. package/framework/v0.1.1-alpha.2/lib/cmd/port/set.js +0 -0
  206. package/framework/v0.1.1-alpha.2/lib/cmd/project/add.js +528 -0
  207. package/framework/v0.1.1-alpha.2/lib/cmd/project/arguments.json +9 -0
  208. package/framework/v0.1.1-alpha.2/lib/cmd/project/build.js +115 -0
  209. package/framework/v0.1.1-alpha.2/lib/cmd/project/help.js +28 -0
  210. package/framework/v0.1.1-alpha.2/lib/cmd/project/help.txt +76 -0
  211. package/framework/v0.1.1-alpha.2/lib/cmd/project/import.js +2 -0
  212. package/framework/v0.1.1-alpha.2/lib/cmd/project/list.js +55 -0
  213. package/framework/v0.1.1-alpha.2/lib/cmd/project/move.js +0 -0
  214. package/framework/v0.1.1-alpha.2/lib/cmd/project/remove.js +144 -0
  215. package/framework/v0.1.1-alpha.2/lib/cmd/project/rename.js +162 -0
  216. package/framework/v0.1.1-alpha.2/lib/cmd/project/restart.js +0 -0
  217. package/framework/v0.1.1-alpha.2/lib/cmd/project/rm.js +2 -0
  218. package/framework/v0.1.1-alpha.2/lib/cmd/project/start.js +0 -0
  219. package/framework/v0.1.1-alpha.2/lib/cmd/project/status.js +3 -0
  220. package/framework/v0.1.1-alpha.2/lib/cmd/project/stop.js +0 -0
  221. package/framework/v0.1.1-alpha.2/lib/cmd/protocol/help.js +27 -0
  222. package/framework/v0.1.1-alpha.2/lib/cmd/protocol/help.txt +57 -0
  223. package/framework/v0.1.1-alpha.2/lib/cmd/protocol/list.js +239 -0
  224. package/framework/v0.1.1-alpha.2/lib/cmd/protocol/set.js +631 -0
  225. package/framework/v0.1.1-alpha.2/lib/cmd/scope/help.js +28 -0
  226. package/framework/v0.1.1-alpha.2/lib/cmd/scope/help.txt +33 -0
  227. package/framework/v0.1.1-alpha.2/lib/cmd/scope/link-local.js +80 -0
  228. package/framework/v0.1.1-alpha.2/lib/cmd/scope/list.js +116 -0
  229. package/framework/v0.1.1-alpha.2/lib/cmd/scope/remove.js +150 -0
  230. package/framework/v0.1.1-alpha.2/lib/cmd/scope/rm.js +2 -0
  231. package/framework/v0.1.1-alpha.2/lib/cmd/scope/set.js +57 -0
  232. package/framework/v0.1.1-alpha.2/lib/cmd/scope/unset.js +44 -0
  233. package/framework/v0.1.1-alpha.2/lib/cmd/scope/use.js +79 -0
  234. package/framework/v0.1.1-alpha.2/lib/cmd/view/add.js +311 -0
  235. package/framework/v0.1.1-alpha.2/lib/collection/README.md +5 -0
  236. package/framework/v0.1.1-alpha.2/lib/collection/build.json +0 -0
  237. package/{core/utils → framework/v0.1.1-alpha.2}/lib/collection/package.json +2 -2
  238. package/framework/v0.1.1-alpha.2/lib/collection/src/main.js +1459 -0
  239. package/{core/utils → framework/v0.1.1-alpha.2}/lib/config.js +49 -34
  240. package/framework/v0.1.1-alpha.2/lib/cron/README.md +7 -0
  241. package/framework/v0.1.1-alpha.2/lib/cron/package.json +20 -0
  242. package/framework/v0.1.1-alpha.2/lib/cron/src/main.js +176 -0
  243. package/{core/utils → framework/v0.1.1-alpha.2}/lib/generator/index.js +8 -4
  244. package/framework/v0.1.1-alpha.2/lib/index.js +116 -0
  245. package/framework/v0.1.1-alpha.2/lib/inherits/LICENSE +19 -0
  246. package/{core/utils → framework/v0.1.1-alpha.2}/lib/inherits/README.md +0 -0
  247. package/{core/utils → framework/v0.1.1-alpha.2}/lib/inherits/example/inheriting_eventemitter.js +0 -0
  248. package/{core/utils → framework/v0.1.1-alpha.2}/lib/inherits/example/protected_inheritance.js +0 -0
  249. package/{core/utils → framework/v0.1.1-alpha.2}/lib/inherits/example/simple_inheritance.js +0 -0
  250. package/{core/utils → framework/v0.1.1-alpha.2}/lib/inherits/example/super_attribute_overridden_by_child_on_init.js +0 -0
  251. package/{core/utils → framework/v0.1.1-alpha.2}/lib/inherits/package.json +2 -2
  252. package/{core/utils → framework/v0.1.1-alpha.2}/lib/inherits/src/main.js +18 -19
  253. package/framework/v0.1.1-alpha.2/lib/logger/README.md +7 -0
  254. package/framework/v0.1.1-alpha.2/lib/logger/package.json +20 -0
  255. package/framework/v0.1.1-alpha.2/lib/logger/src/containers/default/index.js +55 -0
  256. package/framework/v0.1.1-alpha.2/lib/logger/src/containers/file/index.js +251 -0
  257. package/framework/v0.1.1-alpha.2/lib/logger/src/containers/file/lib/logrotator/README.md +100 -0
  258. package/framework/v0.1.1-alpha.2/lib/logger/src/containers/file/lib/logrotator/index.js +274 -0
  259. package/framework/v0.1.1-alpha.2/lib/logger/src/containers/mq/index.js +52 -0
  260. package/framework/v0.1.1-alpha.2/lib/logger/src/containers/mq/listener.js +302 -0
  261. package/framework/v0.1.1-alpha.2/lib/logger/src/containers/mq/speaker.js +118 -0
  262. package/framework/v0.1.1-alpha.2/lib/logger/src/helper.js +131 -0
  263. package/framework/v0.1.1-alpha.2/lib/logger/src/main.js +734 -0
  264. package/{core/utils → framework/v0.1.1-alpha.2}/lib/math/index.js +58 -35
  265. package/{core/utils → framework/v0.1.1-alpha.2}/lib/merge/README.md +5 -0
  266. package/{core/utils → framework/v0.1.1-alpha.2}/lib/merge/example/merge.js +1 -1
  267. package/{core/utils → framework/v0.1.1-alpha.2}/lib/merge/example/merge_2_literal objects.js +0 -0
  268. package/{core/utils → framework/v0.1.1-alpha.2}/lib/merge/example/merge_and_preserve_first.js +2 -0
  269. package/{core/utils → framework/v0.1.1-alpha.2}/lib/merge/package.json +2 -2
  270. package/framework/v0.1.1-alpha.2/lib/merge/src/main.js +531 -0
  271. package/{core/utils → framework/v0.1.1-alpha.2}/lib/model.js +42 -19
  272. package/framework/v0.1.1-alpha.2/lib/proc.js +518 -0
  273. package/framework/v0.1.1-alpha.2/lib/routing/README.md +0 -0
  274. package/framework/v0.1.1-alpha.2/lib/routing/build.json +0 -0
  275. package/{core/utils → framework/v0.1.1-alpha.2}/lib/routing/package.json +2 -2
  276. package/framework/v0.1.1-alpha.2/lib/routing/src/main.js +1492 -0
  277. package/framework/v0.1.1-alpha.2/lib/session-store.js +33 -0
  278. package/{core/utils → framework/v0.1.1-alpha.2}/lib/shell.js +43 -30
  279. package/framework/v0.1.1-alpha.2/lib/swig-filters/README.md +0 -0
  280. package/framework/v0.1.1-alpha.2/lib/swig-filters/package.json +20 -0
  281. package/framework/v0.1.1-alpha.2/lib/swig-filters/src/main.js +322 -0
  282. package/framework/v0.1.1-alpha.2/lib/url/README.md +0 -0
  283. package/{core/utils → framework/v0.1.1-alpha.2}/lib/url/index.js +2 -1
  284. package/{core/utils → framework/v0.1.1-alpha.2}/lib/url/mocks.json +0 -0
  285. package/{core/utils → framework/v0.1.1-alpha.2}/lib/url/routing.json +9 -9
  286. package/{core/utils → framework/v0.1.1-alpha.2}/lib/url/test.js +0 -0
  287. package/{core/utils → framework/v0.1.1-alpha.2}/lib/validator.js +7 -7
  288. package/framework/v0.1.1-alpha.2/package.json +14 -0
  289. package/package.json +35 -33
  290. package/resources/etc/init.d/debian/gina +117 -0
  291. package/resources/home/framework/env.json +34 -0
  292. package/resources/home/framework/locals.json +14 -0
  293. package/resources/home/framework/project.json +48 -0
  294. package/resources/home/framework/projects.json +6 -0
  295. package/resources/home/main.json +47 -0
  296. package/resources/home/settings.json +22 -0
  297. package/resources/home/user/extensions/logger/default/config.json +77 -0
  298. package/resources/home/user/extensions/logger/file/config.json +11 -0
  299. package/resources/img/android-chrome-192x192.png +0 -0
  300. package/resources/img/android-chrome-512x512.png +0 -0
  301. package/resources/img/apple-touch-icon.png +0 -0
  302. package/resources/img/favicon-16x16.png +0 -0
  303. package/resources/img/favicon-32x32.png +0 -0
  304. package/resources/img/favicon.ico +0 -0
  305. package/resources/package.json.template +50 -0
  306. package/script/lib.js +24 -0
  307. package/script/post_install.js +449 -157
  308. package/script/pre_install.js +277 -36
  309. package/script/prepare_version.js +425 -0
  310. package/utils/helper.js +438 -0
  311. package/utils/prototypes.js +239 -0
  312. package/utils/prototypes.json_clone.js +175 -0
  313. package/.npmignore +0 -6
  314. package/MIDDLEWARE +0 -1
  315. package/SUCCESS +0 -1
  316. package/VERSION +0 -1
  317. package/core/asset/html/nolayout.html +0 -1
  318. package/core/asset/js/plugin/build.dev.json +0 -28
  319. package/core/asset/js/plugin/build.json +0 -31
  320. package/core/asset/js/plugin/dist/gina.min.css +0 -1
  321. package/core/asset/js/plugin/dist/gina.min.css.map +0 -1
  322. package/core/asset/js/plugin/dist/gina.min.js +0 -13731
  323. package/core/asset/js/plugin/dist/gina.min.js.map +0 -42
  324. package/core/asset/js/plugin/dist/gina.onload.min.js +0 -3
  325. package/core/asset/js/plugin/dist/gina.onload.min.js.map +0 -8
  326. package/core/asset/js/plugin/readme.md +0 -152
  327. package/core/asset/js/plugin/src/gina/main.js +0 -132
  328. package/core/asset/js/plugin/src/gina/popin/css/design.css +0 -23
  329. package/core/asset/js/plugin/src/gina/popin/css/main.css +0 -1112
  330. package/core/asset/js/plugin/src/gina/popin/css/popin.css +0 -3
  331. package/core/asset/js/plugin/src/gina/popin/css/popin.css.map +0 -1
  332. package/core/asset/js/plugin/src/gina/popin/doc/TOC.md +0 -29
  333. package/core/asset/js/plugin/src/gina/popin/doc/css.md +0 -162
  334. package/core/asset/js/plugin/src/gina/popin/doc/extend.md +0 -663
  335. package/core/asset/js/plugin/src/gina/popin/doc/faq.md +0 -46
  336. package/core/asset/js/plugin/src/gina/popin/doc/html.md +0 -227
  337. package/core/asset/js/plugin/src/gina/popin/doc/js.md +0 -37
  338. package/core/asset/js/plugin/src/gina/popin/doc/misc.md +0 -178
  339. package/core/asset/js/plugin/src/gina/popin/doc/usage.md +0 -130
  340. package/core/asset/js/plugin/src/gina/popin/main.js +0 -783
  341. package/core/asset/js/plugin/src/gina/popin/sass/config.sass +0 -37
  342. package/core/asset/js/plugin/src/gina/popin/sass/gina-design.sass +0 -622
  343. package/core/asset/js/plugin/src/gina/popin/sass/gina-popin.sass +0 -54
  344. package/core/asset/js/plugin/src/gina/popin/sass/helper.scss +0 -73
  345. package/core/asset/js/plugin/src/gina/toolbar/.npmignore +0 -19
  346. package/core/asset/js/plugin/src/gina/toolbar/css/toolbar.css +0 -433
  347. package/core/asset/js/plugin/src/gina/toolbar/css/toolbar.css.map +0 -1
  348. package/core/asset/js/plugin/src/gina/toolbar/index.html +0 -285
  349. package/core/asset/js/plugin/src/gina/toolbar/index.kit +0 -120
  350. package/core/asset/js/plugin/src/gina/toolbar/jquery-3.1.0.min.js +0 -4
  351. package/core/asset/js/plugin/src/gina/toolbar/main.js +0 -693
  352. package/core/asset/js/plugin/src/gina/toolbar/mock.gina.json +0 -1
  353. package/core/asset/js/plugin/src/gina/toolbar/mock.user.json +0 -1
  354. package/core/asset/js/plugin/src/gina/toolbar/readme.md +0 -7
  355. package/core/asset/js/plugin/src/gina/toolbar/sass/toolbar.sass +0 -563
  356. package/core/asset/js/plugin/src/gina/toolbar/svg-src/Info-color.svg +0 -1
  357. package/core/asset/js/plugin/src/gina/toolbar/svg-src/Info-grey.svg +0 -1
  358. package/core/asset/js/plugin/src/gina/toolbar/svg-src/error-color.svg +0 -1
  359. package/core/asset/js/plugin/src/gina/toolbar/svg-src/error-grey.svg +0 -1
  360. package/core/asset/js/plugin/src/gina/toolbar/svg-src/info-optim.svg +0 -13
  361. package/core/asset/js/plugin/src/gina/toolbar/svg-src/logo-gina.svg +0 -1
  362. package/core/asset/js/plugin/src/gina/toolbar/svg-src/settings-big.svg +0 -1
  363. package/core/asset/js/plugin/src/gina/toolbar/svg-src/settings.afdesign +0 -0
  364. package/core/asset/js/plugin/src/gina/toolbar/svg-src/settings.svg +0 -1
  365. package/core/asset/js/plugin/src/gina/toolbar/svg-src/stripe-calendar-optim.svg +0 -1
  366. package/core/asset/js/plugin/src/gina/toolbar/svg-src/stripe-calendar.svg +0 -1
  367. package/core/asset/js/plugin/src/gina/toolbar/svg-src/stripe-card-optim.svg +0 -1
  368. package/core/asset/js/plugin/src/gina/toolbar/svg-src/stripe-card.svg +0 -1
  369. package/core/asset/js/plugin/src/gina/toolbar/svg-src/stripe-lock-optim.svg +0 -1
  370. package/core/asset/js/plugin/src/gina/toolbar/svg-src/stripe-lock.svg +0 -1
  371. package/core/asset/js/plugin/src/gina/toolbar/svg-src/warning-color.svg +0 -1
  372. package/core/asset/js/plugin/src/gina/toolbar/svg-src/warning-grey.svg +0 -1
  373. package/core/asset/js/plugin/src/gina/toolbar/test.jpg +0 -0
  374. package/core/asset/js/plugin/src/gina/toolbar/toolbar.html +0 -104
  375. package/core/asset/js/plugin/src/gina/utils/dom.js +0 -24
  376. package/core/asset/js/plugin/src/gina/utils/events.js +0 -201
  377. package/core/asset/js/plugin/src/gina/utils/loader.js +0 -57
  378. package/core/asset/js/plugin/src/main.js +0 -235
  379. package/core/asset/js/plugin/src/vendor/jquery/1.11.1-css-event_alias.min.js +0 -5
  380. package/core/asset/js/plugin/src/vendor/jquery/1.12.4.min.js +0 -5
  381. package/core/asset/js/plugin/src/vendor/jquery/2.1.1-css-event_alias-sizzle.min.js +0 -4
  382. package/core/asset/js/plugin/src/vendor/jquery/README.md +0 -14
  383. package/core/asset/js/plugin/src/vendor/jquery/slim-3.1.1.min.js +0 -4
  384. package/core/config.js +0 -1225
  385. package/core/controller/controller.js +0 -1860
  386. package/core/gna.js +0 -908
  387. package/core/plugins/lib/validator/src/form-validator.js +0 -788
  388. package/core/plugins/lib/validator/src/main.js +0 -2056
  389. package/core/router.js +0 -717
  390. package/core/server.js +0 -1363
  391. package/core/template/conf/env.json +0 -70
  392. package/core/template/conf/settings.json +0 -48
  393. package/core/template/conf/statics.json +0 -6
  394. package/core/template/conf/views.json +0 -16
  395. package/core/template/samples/bundle/config/app.json +0 -4
  396. package/core/template/samples/bundle/config/routing.json +0 -9
  397. package/core/template/samples/bundle/controllers/setup.js +0 -33
  398. package/core/template/views/js/vendor/readme.md +0 -1
  399. package/core/template/views/readme.md +0 -1
  400. package/core/utils/helpers/dateFormat.js +0 -264
  401. package/core/utils/helpers/index.js +0 -202
  402. package/core/utils/index.js +0 -75
  403. package/core/utils/lib/cmd/app.js +0 -686
  404. package/core/utils/lib/cmd/basic.help.txt +0 -40
  405. package/core/utils/lib/cmd/basic.js +0 -141
  406. package/core/utils/lib/cmd/gina-add-bundle.js +0 -328
  407. package/core/utils/lib/cmd/gina-add-views.js +0 -99
  408. package/core/utils/lib/cmd/gina-build.js +0 -218
  409. package/core/utils/lib/cmd/gina-clean.js +0 -26
  410. package/core/utils/lib/cmd/gina-connect.js +0 -176
  411. package/core/utils/lib/cmd/gina-delete-bundle.js +0 -176
  412. package/core/utils/lib/cmd/gina-deploy.js +0 -452
  413. package/core/utils/lib/cmd/gina-init-project.js +0 -83
  414. package/core/utils/lib/cmd/gina-start-bundle.js +0 -3
  415. package/core/utils/lib/cmd/gina-start.js +0 -3
  416. package/core/utils/lib/cmd/index.js +0 -157
  417. package/core/utils/lib/cmd/project.js +0 -14
  418. package/core/utils/lib/collection/src/main.js +0 -650
  419. package/core/utils/lib/logger/containers/file.js +0 -11
  420. package/core/utils/lib/logger/index.js +0 -260
  421. package/core/utils/lib/merge/src/main.js +0 -344
  422. package/core/utils/lib/proc.js +0 -416
  423. package/core/utils/lib/routing/src/main.js +0 -165
  424. package/documentation/css/default.css +0 -3
  425. package/documentation/html/home.html +0 -6
  426. package/documentation/html/inc/_footer.html +0 -5
  427. package/documentation/html/layout.html +0 -21
  428. package/documentation/img/debug-conf1.png +0 -0
  429. package/documentation/img/debug-conf2.png +0 -0
  430. package/documentation/img/debug-conf3.png +0 -0
  431. package/documentation/img/debug-conf4.png +0 -0
  432. package/documentation/img/debug-conf5.png +0 -0
  433. package/documentation/img/debug-conf6.png +0 -0
  434. package/documentation/img/debug-conf7.png +0 -0
  435. package/documentation/img/debug-new1.png +0 -0
  436. package/documentation/img/debug-new2.png +0 -0
  437. package/documentation/img/debug-start.png +0 -0
  438. package/documentation/md/api/controller/main.md +0 -74
  439. package/migration_note.md +0 -7
  440. package/package-lock.json +0 -611
  441. package/script/pre_publish.js +0 -207
  442. package/tutorial/Commands/README.md +0 -56
  443. package/tutorial/Commands/add-bundle-result.png +0 -0
  444. package/tutorial/Commands/add-bundle.png +0 -0
  445. package/tutorial/Commands/delete-bundle.png +0 -0
  446. package/tutorial/Commands/help.png +0 -0
  447. package/tutorial/Commands/init-project.png +0 -0
  448. package/tutorial/Commands/start-bundle-result.png +0 -0
  449. package/tutorial/Commands/start-bundle-stop.png +0 -0
  450. package/tutorial/Commands/start-bundle.png +0 -0
  451. package/tutorial/Commands/version.png +0 -0
  452. package/tutorial/ETC/README.md +0 -74
  453. package/tutorial/ETC/add-bundle-result.png +0 -0
  454. package/tutorial/ETC/add-bundle.png +0 -0
  455. package/tutorial/ETC/init-project.png +0 -0
  456. package/tutorial/Install/README.md +0 -54
  457. package/tutorial/Install/git-get.png +0 -0
  458. package/tutorial/Install/git-install-end.png +0 -0
  459. package/tutorial/Install/git-install-result.png +0 -0
  460. package/tutorial/Install/git-install-start.png +0 -0
  461. package/tutorial/Install/install-end.png +0 -0
  462. package/tutorial/Install/install-result.png +0 -0
  463. package/tutorial/Install/install-start.png +0 -0
  464. package/tutorial/WebStorm/README.md +0 -30
  465. package/tutorial/WebStorm/closure-compiler.png +0 -0
  466. package/tutorial/WebStorm/sass.png +0 -0
package/core/server.js DELETED
@@ -1,1363 +0,0 @@
1
- //Imports.
2
- var fs = require('fs');
3
- var path = require('path');
4
- var EventEmitter = require('events').EventEmitter;
5
- var express = require('express');
6
- var zlib = require('zlib'); // gzip / deflate
7
- var url = require('url');
8
- var Config = require('./config');
9
- var Router = require('./router');
10
- var util = require('util');
11
- var utils = require('./utils');
12
- var inherits = utils.inherits;
13
- var merge = utils.merge;
14
- var Proc = utils.Proc;
15
- var console = utils.logger;
16
- var multiparty = utils.multiparty;
17
-
18
-
19
- function Server(options) {
20
- var self = this;
21
- var local = {
22
- router : null,
23
- hasViews: {}
24
- };
25
-
26
- this.conf = {
27
- core: {}
28
- };
29
-
30
- this.routing = {};
31
- //this.activeChild = 0;
32
-
33
- /**
34
- * Set Configuration
35
- * @param {object} options Configuration
36
- *
37
- *
38
- * @callback callback responseCallback
39
- * @param {boolean} complete
40
- * @public
41
- */
42
- var init = function(options) {
43
-
44
- //Starting app.
45
- self.appName = options.bundle;
46
-
47
- self.env = options.env;
48
- self.version = options.version;
49
- local.router = new Router(self.env);
50
-
51
- //True => multiple bundles sharing the same server (port).
52
- self.isStandalone = options.isStandalone;
53
- self.executionPath = options.executionPath;
54
- self.bundles = options.bundles;
55
-
56
- if (!self.isStandalone) {
57
- //Only load the related conf / env.
58
- self.conf[self.appName] = {};
59
- self.conf[self.appName][self.env] = options.conf[self.appName][self.env];
60
- self.conf[self.appName][self.env].bundlesPath = options.conf[self.appName][self.env].bundlesPath;
61
- self.conf[self.appName][self.env].modelsPath = options.conf[self.appName][self.env].modelsPath;
62
- if (!self.conf[self.appName][self.env].server.request) {
63
- self.conf[self.appName][self.env].server.request = {
64
- isXMLRequest: false
65
- }
66
- }
67
- } else {
68
-
69
- //console.log("Running mode not handled yet..", self.appName, " VS ", self.bundles);
70
- //Load all conf for the related apps & env.
71
- var apps = self.bundles;
72
- for (var i=0; i<apps.length; ++i) {
73
- self.conf[apps[i]] = {};
74
- self.conf[apps[i]][self.env] = options.conf[apps[i]][self.env];
75
- self.conf[apps[i]][self.env].bundlesPath = options.conf[apps[i]][self.env].bundlesPath;
76
- self.conf[apps[i]][self.env].modelsPath = options.conf[apps[i]][self.env].modelsPath;
77
- if (!self.conf[apps[i]][self.env].server.request) {
78
- self.conf[apps[i]][self.env].server.request = {
79
- isXMLRequest: false
80
- }
81
- }
82
- }
83
- }
84
-
85
- // getting server core config
86
- var statusCodes = null
87
- , mime = null;
88
-
89
- try {
90
- //var corePath = getPath('gina.core');
91
- var corePath = getPath('gina').core;
92
- statusCodes = fs.readFileSync( _( corePath + '/status.codes') ).toString();
93
- statusCodes = JSON.parse(statusCodes);
94
- if ( typeof(statusCodes['_comment']) != 'undefined' )
95
- delete statusCodes['_comment'];
96
-
97
- mime = fs.readFileSync(corePath + '/mime.types').toString();
98
- mime = JSON.parse(mime);
99
- if ( typeof(mime['_comment']) != 'undefined' )
100
- delete mime['_comment'];
101
-
102
- self.conf.core.statusCodes = statusCodes;
103
- self.conf.core.mime = mime
104
-
105
- } catch(err) {
106
- console.error(err.stack||err.message);
107
- process.exit(1)
108
- }
109
-
110
- self.emit('configured', false, express(), express, self.conf[self.appName][self.env]);
111
- }
112
-
113
-
114
- this.start = function(instance) {
115
-
116
- if (instance) {
117
- self.instance = instance
118
- }
119
-
120
- onRoutesLoaded( function(err) {//load all registered routes in routing.json
121
- console.debug('Routing loaded' + '\n'+ JSON.stringify(self.routing, null, '\t'));
122
-
123
- if ( hasViews(self.appName) ) {
124
- utils.url(self.conf[self.appName][self.env], self.routing)
125
- }
126
-
127
- if (!err) {
128
- onRequest()
129
- }
130
- })
131
- }
132
-
133
- /**
134
- * onRoutesLoaded
135
- *
136
- *
137
- * */
138
- var onRoutesLoaded = function(callback) {
139
-
140
- var config = new Config()
141
- , conf = config.getInstance(self.appName)
142
- , serverCoreConf = self.conf.core
143
- , routing = {}
144
- , reverseRouting = {}
145
- , cacheless = config.isCacheless()
146
- , env = self.env
147
- , apps = conf.allBundles//conf.bundles
148
- , filename = ''
149
- , appName = ''
150
- , tmp = {}
151
- , standaloneTmp = {}
152
- , main = ''
153
- , tmpContent = ''
154
- , i = 0
155
- , file = null // template file
156
- , wroot = null
157
- , hasWebRoot = false
158
- , webrootAutoredirect = null
159
- , localWroot = null
160
- , originalRules = []
161
- , oRuleCount = 0;
162
-
163
- //Standalone or shared instance mode. It doesn't matter.
164
- for (; i<apps.length; ++i) {
165
- config.setServerCoreConf(apps[i], self.env, serverCoreConf);
166
-
167
- var appPath = _(conf.envConf[apps[i]][self.env].bundlesPath+ '/' + apps[i]);
168
- appName = apps[i];
169
-
170
- //Specific case.
171
- if (!self.isStandalone && i == 0) appName = apps[i];
172
-
173
- try {
174
- main = _(appPath + '/config/' + conf.envConf[apps[i]][self.env].files.routing);
175
- filename = main;//by default
176
- filename = conf.envConf[apps[i]][self.env].files.routing.replace(/.json/, '.' +env + '.json');
177
- filename = _(appPath + '/config/' + filename);
178
- //Can't do a thing without.
179
- if ( !fs.existsSync(filename) ) {
180
- filename = main
181
- }
182
-
183
- if (cacheless) {
184
- delete require.cache[_(filename, true)]
185
- }
186
-
187
- if (filename != main) {
188
- routing = tmpContent = merge(require(main), require(filename), true);
189
-
190
- } else {
191
- try {
192
- tmpContent = require(filename);
193
- } catch (err) {
194
- // do not block here because the bundle is not build for the same env
195
- console.warn(err.stack);
196
- continue
197
- }
198
- }
199
-
200
- try {
201
-
202
- wroot = conf.envConf[apps[i]][self.env].server.webroot;
203
- webrootAutoredirect = conf.envConf[apps[i]][self.env].server.webrootAutoredirect;
204
- // renaming rule for standalone setup
205
- if ( self.isStandalone && apps[i] != self.appName && wroot == '/') {
206
- wroot = '/'+ apps[i];
207
- conf.envConf[apps[i]][self.env].server.webroot = wroot
208
- }
209
-
210
- if (wroot.length >1) {
211
- hasWebRoot = true
212
- } else {
213
- hasWebRoot = false
214
- }
215
-
216
- tmp = tmpContent;
217
- //Adding important properties; also done in core/config.
218
- for (var rule in tmp){
219
- tmp[rule +'@'+ appName] = tmp[rule];
220
- delete tmp[rule];
221
- file = rule;
222
- rule = rule +'@'+ appName;
223
-
224
-
225
- tmp[rule].bundle = (tmp[rule].bundle) ? tmp[rule].bundle : apps[i]; // for reverse search
226
- tmp[rule].param.file = ( typeof(tmp) != 'string' && typeof(tmp[rule].param.file) != 'undefined' ) ? tmp[rule].param.file : file; // get template file
227
- // by default, method is inherited from the request
228
- if (
229
- hasWebRoot && typeof(tmp[rule].param.path) != 'undefined' && typeof(tmp[rule].param.ignoreWebRoot) == 'undefined'
230
- || hasWebRoot && typeof(tmp[rule].param.path) != 'undefined' && !tmp[rule].param.ignoreWebRoot
231
- ) {
232
- tmp[rule].param.path = wroot + tmp[rule].param.path
233
- }
234
-
235
- if (typeof(tmp[rule].url) != 'object') {
236
- if (tmp[rule].url.length > 1 && tmp[rule].url.substr(0,1) != '/') {
237
- tmp[rule].url = '/'+tmp[rule].url
238
- } else if (tmp[rule].url.length > 1 && conf.envConf[apps[i]][self.env].server.webroot.substr(conf.envConf[apps[i]][self.env].server.webroot.length-1,1) == '/') {
239
- tmp[rule].url = tmp[rule].url.substr(1)
240
- } else {
241
- if (wroot.substr(wroot.length-1,1) == '/') {
242
- wroot = wroot.substr(wroot.length-1,1).replace('/', '')
243
- }
244
- }
245
-
246
-
247
- if (tmp[rule].bundle != apps[i]) { // allowing to override bundle name in routing.json
248
- // originalRule is used to facilitate cross bundles (hypertext)linking
249
- originalRules[oRuleCount] = ( self.isStandalone && tmp[rule] && apps[i] != self.appName) ? apps[i] + '-' + rule : rule;
250
- ++oRuleCount;
251
-
252
- localWroot = conf.envConf[tmp[rule].bundle][self.env].server.webroot;
253
- // standalone setup
254
- if ( self.isStandalone && tmp[rule].bundle != self.appName && localWroot == '/') {
255
- localWroot = '/'+ routing[rule].bundle;
256
- conf.envConf[tmp[rule].bundle][self.env].server.webroot = localWroot
257
- }
258
- if (localWroot.substr(localWroot.length-1,1) == '/') {
259
- localWroot = localWroot.substr(localWroot.length-1,1).replace('/', '')
260
- }
261
- if ( typeof(tmp[rule].param.ignoreWebRoot) == 'undefined' || !tmp[rule].param.ignoreWebRoot )
262
- tmp[rule].url = localWroot + tmp[rule].url
263
- } else {
264
- if ( typeof(tmp[rule].param.ignoreWebRoot) == 'undefined' || !tmp[rule].param.ignoreWebRoot )
265
- tmp[rule].url = wroot + tmp[rule].url
266
- else if (!tmp[rule].url.length)
267
- tmp[rule].url += '/'
268
- }
269
-
270
- } else {
271
-
272
- for (var u=0; u<tmp[rule].url.length; ++u) {
273
- if (tmp[rule].url[u].length > 1 && tmp[rule].url[u].substr(0,1) != '/') {
274
- tmp[rule].url[u] = '/'+tmp[rule].url[u]
275
- } else {
276
- if (wroot.substr(wroot.length-1,1) == '/') {
277
- wroot = wroot.substr(wroot.length-1,1).replace('/', '')
278
- }
279
- }
280
- if ( typeof(tmp[rule].param.ignoreWebRoot) == 'undefined' || !tmp[rule].param.ignoreWebRoot )
281
- tmp[rule].url[u] = wroot + tmp[rule].url[u]
282
- else if (!tmp[rule].url.length)
283
- tmp[rule].url += '/'
284
- }
285
- }
286
-
287
- if( hasViews(apps[i]) ) {
288
- // This is only an issue when it comes to the frontend dev
289
- // views.useRouteNameAsFilename is set to true by default
290
- // IF [ false ] the action is used as filename
291
- if ( !conf.envConf[apps[i]][self.env].content['views']['default'].useRouteNameAsFilename && tmp[rule].param.bundle != 'framework') {
292
- var tmpRouting = [];
293
- for (var r = 0, len = tmp[rule].param.file.length; r < len; ++r) {
294
- if (/[A-Z]/.test(tmp[rule].param.file.charAt(r))) {
295
- tmpRouting[0] = tmp[rule].param.file.substring(0, r);
296
- tmpRouting[1] = '-' + (tmp[rule].param.file.charAt(r)).toLocaleLowerCase();
297
- tmpRouting[2] = tmp[rule].param.file.substring(r + 1);
298
- tmp[rule].param.file = tmpRouting[0] + tmpRouting[1] + tmpRouting[2];
299
- ++r
300
- }
301
- }
302
- }
303
- }
304
-
305
- if ( self.isStandalone && tmp[rule]) {
306
- // deprecated: rules are now unique per bundle : rule@bundle
307
- //if (apps[i] != self.appName) {
308
- // standaloneTmp[apps[i] + '-' + rule] = JSON.parse(JSON.stringify(tmp[rule]))
309
- //} else {
310
- standaloneTmp[rule] = JSON.parse(JSON.stringify(tmp[rule]))
311
- //}
312
- }
313
- }// EO for
314
-
315
-
316
- } catch (err) {
317
- self.routing = routing = null;
318
- console.error(err.stack||err.message);
319
- callback(err)
320
- }
321
-
322
- } catch (err) {
323
- console.warn(err, err.stack||err.message);
324
- callback(err)
325
- }
326
-
327
-
328
- routing = merge(routing, ((self.isStandalone && apps[i] != self.appName ) ? standaloneTmp : tmp), true);
329
- // originalRule is used to facilitate cross bundles (hypertext)linking
330
- for (var r = 0, len = originalRules.length; r < len; r++) { // for each rule ( originalRules[r] )
331
- routing[originalRules[r]].originalRule = (routing[originalRules[r]].bundle === self.appName ) ? config.getOriginalRule(originalRules[r], routing) : config.getOriginalRule(routing[originalRules[r]].bundle +'-'+ originalRules[r], routing)
332
- }
333
-
334
- // reverse routing
335
- for (var rule in routing) {
336
- if ( typeof(routing[rule].url) != 'object' ) {
337
- reverseRouting[routing[rule].url] = rule
338
- } else {
339
- for (var u = 0, len = routing[rule].url.length; u < len; ++u) {
340
- reverseRouting[routing[rule].url[u]] = rule
341
- }
342
- }
343
- }
344
-
345
- config.setRouting(apps[i], self.env, routing);
346
- config.setReverseRouting(apps[i], self.env, reverseRouting);
347
-
348
- if (apps[i] == self.appName) {
349
- self.routing = routing;
350
- self.reverseRouting = reverseRouting
351
- }
352
-
353
- }//EO for.
354
-
355
-
356
- callback(false)
357
- }
358
-
359
- var hasViews = function(bundle) {
360
- var _hasViews = false, conf = new Config().getInstance(bundle);
361
- if (typeof(local.hasViews[bundle]) != 'undefined') {
362
- _hasViews = local.hasViews[bundle];
363
- } else {
364
- _hasViews = ( typeof(conf.envConf[bundle][self.env].content['views']) != 'undefined' ) ? true : false;
365
- local.hasViews[bundle] = _hasViews;
366
- }
367
-
368
- return _hasViews
369
- }
370
-
371
- var parseCollection = function (collection, obj) {
372
-
373
- for(var i = 0, len = collection.length; i<len; ++i) {
374
- obj[i] = parseObject(collection[i], obj);
375
- }
376
-
377
- return obj
378
- }
379
-
380
- var parseObject = function (tmp, obj) {
381
- var el = []
382
- , key = null
383
- ;
384
-
385
-
386
- for (var o in tmp) {
387
- //el[0] = decodeURIComponent(o);
388
- //el[1] = ( typeof(tmp[o]) == 'string') ? decodeURIComponent(tmp[o]) : tmp[o];
389
- el[0] = o;
390
- el[1] = tmp[o];
391
-
392
- //if ( Array.isArray(el[1]) ) {
393
- // obj = parseCollection(el[1], obj)
394
- //} else {
395
- if ( /^(.*)\[(.*)\]/.test(el[0]) ) { // some[field] ?
396
- key = el[0].replace(/\]/g, '').split(/\[/g);
397
- obj = parseLocalObj(obj, key, 0, el[1])
398
- } else {
399
- obj[ el[0] ] = el[1]
400
- }
401
- }
402
-
403
- return obj
404
- }
405
-
406
- var parseBody = function(body) {
407
-
408
- if ( /^(\{|\[|\%7B|\%5B)/.test(body) ) {
409
- try {
410
- var obj = {}, tmp = null;
411
-
412
- if ( /^(\%7B|\%5B)/.test(body) ) {
413
- tmp = JSON.parse(decodeURIComponent(body))
414
- } else {
415
- tmp = JSON.parse(body)
416
- }
417
-
418
- if ( Array.isArray(tmp) ) {
419
- obj = parseCollection(tmp, obj)
420
- } else {
421
- obj = parseObject(tmp, obj)
422
- }
423
-
424
- return obj
425
- } catch (err) {
426
- console.error('[365] could not parse body:\n' + body)
427
- }
428
-
429
- } else {
430
- var obj = {}, arr = body.split(/&/g);
431
- if ( /(\"false\"|\"true\"|\"on\")/.test(body) )
432
- body = body.replace(/\"false\"/g, false).replace(/\"true\"/g, true).replace(/\"on\"/g, true);
433
-
434
-
435
- var el = {}
436
- , value = null
437
- , key = null;
438
-
439
- for (var i = 0, len = arr.length; i < len; ++i) {
440
- if (!arr[i]) continue;
441
-
442
- arr[i] = decodeURIComponent(arr[i]);
443
-
444
- if ( /^\{/.test(arr[i]) || /\=\{/.test(arr[i]) || /\=\[/.test(arr[i]) ) {
445
- //if ( /^\{/.test(arr[i]) ) { // is a json string
446
- try {
447
- if (/^\{/.test(arr[i])) {
448
- obj = JSON.parse(arr[i]);
449
- break;
450
- } else {
451
- el = arr[i].match(/\=(.*)/);
452
- el[0] = arr[i].split(/\=/)[0];
453
- obj[ el[0] ] = JSON.parse( el[1] );
454
- }
455
-
456
-
457
- } catch (err) {
458
- console.error('[parseBody#1] could not parse body:\n' + arr[i])
459
- }
460
- } else {
461
- el = arr[i].split(/=/);
462
- if ( /\{\}\"\:/.test(el[1]) ) { //might be a json
463
- try {
464
- el[1] = JSON.parse(el[1])
465
- } catch (err) {
466
- console.error('[parseBody#2] could not parse body:\n' + el[1])
467
- }
468
- }
469
-
470
- if ( typeof(el[1]) == 'string' && !/\[object /.test(el[1])) {
471
- key = null;
472
- el[0] = decodeURIComponent(el[0]);
473
- el[1] = decodeURIComponent(el[1]);
474
-
475
- if ( /^(.*)\[(.*)\]/.test(el[0]) ) { // some[field] ?
476
- key = el[0].replace(/\]/g, '').split(/\[/g);
477
- obj = parseLocalObj(obj, key, 0, el[1])
478
- } else {
479
- obj[ el[0] ] = el[1]
480
- }
481
- }
482
- }
483
- }
484
-
485
- return obj
486
- }
487
-
488
-
489
- }
490
-
491
- var parseLocalObj = function(obj, key, k, value) {
492
-
493
- if ( typeof(obj[ key[k] ]) == 'undefined' ) {
494
- obj[ key[k] ] = {};
495
- }
496
-
497
- for (var prop in obj) {
498
-
499
- if (k == key.length-1) {
500
-
501
- if (prop == key[k]) {
502
- obj[prop] = ( typeof(value) != 'undefined' ) ? value : '';
503
- }
504
-
505
- } else if ( key.indexOf(prop) > -1 ) {
506
- ++k;
507
- if ( !obj[prop][ key[k] ] )
508
- obj[prop][ key[k] ] = {};
509
-
510
-
511
- parseLocalObj(obj[prop], key, k, value)
512
-
513
- }
514
- }
515
-
516
- return obj;
517
- }
518
-
519
- var onRequest = function() {
520
-
521
- var apps = self.bundles;
522
- var webrootLen = self.conf[self.appName][self.env].server.webroot.length;
523
-
524
- self.instance.all('*', function onInstance(request, response, next) {
525
- local.request = request;
526
- response.setHeader('X-Powered-By', 'Gina/'+self.version );
527
- // Fixing an express js bug :(
528
- // express is trying to force : /path/dir => /path/dir/
529
- // which causes : /path/dir/path/dir/ <---- by trying to add a slash in the end
530
- if (
531
- webrootLen > 1
532
- && request.url === self.conf[self.appName][self.env].server.webroot + '/' + self.conf[self.appName][self.env].server.webroot + '/'
533
- ) {
534
- request.url = self.conf[self.appName][self.env].server.webroot
535
- }
536
- //Only for dev & debug purposes.
537
- self.conf[self.appName][self.env]['protocol'] = request.protocol || self.conf[self.appName][self.env]['hostname'];
538
-
539
- request.body = {};
540
- request.get = {};
541
- request.post = {};
542
- request.put = {};
543
- request.delete = {};
544
- //request.patch = {}; ???
545
- //request.cookies = {}; // ???
546
-
547
- // be carfull, if you are using jQuery + cross domain, you have to set the header manually in your $.ajax query -> headers: {'X-Requested-With': 'XMLHttpRequest'}
548
- self.conf[self.appName][self.env].server.request.isXMLRequest = ( request.headers['x-requested-with'] && request.headers['x-requested-with'] == 'XMLHttpRequest' ) ? true : false;
549
-
550
- // Passing credentials :
551
- // - if you are using jQuery + cross domain, you have to set the `xhrFields` in your $.ajax query -> xhrFields: { withCredentials: true }
552
- // - if you are using another solution or doing it by hand, make sure to properly set the header: headers: {'Access-Control-Allow-Credentials': true }
553
- /**
554
- * NB.: jQuery
555
- * The `withCredentials` property will include any cookies from the remote domain in the request,
556
- * and it will also set any cookies from the remote domain.
557
- * Note that these cookies still honor same-origin policies, so your JavaScript code can’t access the cookies
558
- * from document.cookie or the response headers.
559
- * They can only be controlled by the remote domain.
560
- * */
561
- self.conf[self.appName][self.env].server.request.isWithCredentials = ( request.headers['access-control-allow-credentials'] && request.headers['access-control-allow-credentials'] == true ) ? true : false;
562
-
563
- // multipart wrapper for uploads
564
- // files are available from your controller or any middlewares:
565
- // @param {object} req.files
566
- if ( /multipart\/form-data;/.test(request.headers['content-type']) ) {
567
- // TODO - get options from settings.json & settings.{env}.json ...
568
- // -> https://github.com/andrewrk/node-multiparty
569
- var opt = self.conf[self.appName][self.env].content.settings.upload;
570
- // checking size
571
- var maxSize = parseInt(opt.maxFieldsSize);
572
- var fileSize = request.headers["content-length"]/1024/1024; //MB
573
-
574
- if (fileSize > maxSize) {
575
- throwError(response, 431, 'Attachment exceeded maximum file size [ '+ opt.maxFieldsSize +' ]');
576
- return false
577
- }
578
-
579
- var i = 0, form = new multiparty.Form(opt);
580
- form.parse(request, function(err, fields, files) {
581
- if (err) {
582
- throwError(response, 400, err.stack||err.message);
583
- return
584
- }
585
-
586
- if ( request.method.toLowerCase() === 'post') {
587
- for (i in fields) {
588
- // should be: request.post[i] = fields[i];
589
- request.post[i] = fields[i][0]; // <-- to fixe on multiparty
590
- }
591
- } else if ( request.method.toLowerCase() === 'get') {
592
- for (i in fields) {
593
- // should be: request.get[i] = fields[i];
594
- request.get[i] = fields[i][0]; // <-- to fixe on multiparty
595
- }
596
- }
597
-
598
- request.files = {};
599
- for (var i in files) {
600
- // should be: request.files[i] = files[i];
601
- request.files[i] = files[i][0]; // <-- to fixe on multiparty
602
- }
603
-
604
- if (request.fields) delete request.fields; // <- not needed anymore
605
-
606
- loadBundleConfiguration(request, response, next, function (err, bundle, pathname, config, req, res, next) {
607
- if (!req.handled) {
608
- req.handled = true;
609
- if (err) {
610
- if (!res.headersSent)
611
- throwError(response, 500, 'Internal server error\n' + err.stack, next)
612
- } else {
613
- handle(req, res, next, bundle, pathname, config)
614
- }
615
- }
616
- })
617
- })
618
- } else {
619
-
620
- request.on('data', function(chunk){ // for this to work, don't forget the name attr for you form elements
621
- if ( typeof(request.body) == 'object') {
622
- request.body = '';
623
- }
624
- request.body += chunk.toString()
625
- });
626
-
627
- request.on('end', function onEnd() {
628
- // to compare with /core/controller/controller.js -> getParams()
629
- switch( request.method.toLowerCase() ) {
630
- case 'post':
631
- var obj = {}, configuring = false;
632
- if ( typeof(request.body) == 'string' ) {
633
- // get rid of encoding issues
634
- try {
635
- if ( !/multipart\/form-data;/.test(request.headers['content-type']) ) {
636
- if ( /application\/x\-www\-form\-urlencoded/.test(request.headers['content-type']) ) {
637
- request.body = request.body.replace(/\+/g, ' ');
638
- }
639
-
640
- if ( request.body.substr(0,1) == '?')
641
- request.body = request.body.substr(1);
642
-
643
- // false & true case
644
- if ( /(\"false\"|\"true\"|\"on\")/.test(request.body) )
645
- request.body = request.body.replace(/\"false\"/g, false).replace(/\"true\"/g, true).replace(/\"on\"/g, true);
646
-
647
- obj = parseBody(request.body);
648
- if (obj.count() == 0 && request.body.length > 1) {
649
- try {
650
- request.post = JSON.parse(request.body);
651
- } catch (err) {}
652
- }
653
- }
654
-
655
- } catch (err) {
656
- var msg = '[ '+request.url+' ]\nCould not decodeURIComponent(requestBody).\n'+ err.stack;
657
- console.warn(msg);
658
- }
659
-
660
- } else {
661
- // 2016-05-19: fix to handle requests from swagger/express
662
- if (request.body.count() == 0 && typeof(request.query) != 'string' && request.query.count() > 0 ) {
663
- request.body = request.query
664
- }
665
- var bodyStr = JSON.stringify(request.body);
666
- // false & true case
667
- if ( /(\"false\"|\"true\"|\"on\")/.test(bodyStr) )
668
- bodyStr = bodyStr.replace(/\"false\"/g, false).replace(/\"true\"/g, true).replace(/\"on\"/g, true);
669
-
670
- obj = JSON.parse(bodyStr)
671
- }
672
-
673
- if ( obj.count() > 0 ) {
674
- // still need this to allow compatibility with express & connect middlewares
675
- request.body = request.post = obj;
676
- }
677
-
678
- // see.: https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#POST
679
- // Responses to this method are not cacheable,
680
- // unless the response includes appropriate Cache-Control or Expires header fields.
681
- // However, the 303 (See Other) response can be used to direct the user agent to retrieve a cacheable resource.
682
- response.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
683
- response.setHeader('Pragma', 'no-cache');
684
- response.setHeader('Expires', '0');
685
-
686
- // cleaning
687
- request.query = undefined;
688
- request.get = undefined;
689
- request.put = undefined;
690
- request.delete = undefined;
691
- break;
692
-
693
- case 'get':
694
- if ( request.query.count() > 0 ) {
695
- request.get = request.query;
696
- }
697
- // else, matching route params against url context instead once route is identified
698
-
699
-
700
- // cleaning
701
- request.query = undefined;
702
- request.post = undefined;
703
- request.put = undefined;
704
- request.delete = undefined;
705
- break;
706
-
707
- case 'put':
708
- // eg.: PUT /user/set/1
709
- var obj = {};
710
- if ( typeof(request.body) == 'string' ) {
711
- // get rid of encoding issues
712
- try {
713
- if ( !/multipart\/form-data;/.test(request.headers['content-type']) ) {
714
- if ( /application\/x\-www\-form\-urlencoded/.test(request.headers['content-type']) ) {
715
- request.body = request.body.replace(/\+/g, ' ');
716
- }
717
-
718
- if ( request.body.substr(0,1) == '?')
719
- request.body = request.body.substr(1);
720
-
721
- // false & true case
722
- if ( /(\"false\"|\"true\"|\"on\")/.test(request.body) )
723
- request.body = request.body.replace(/\"false\"/g, false).replace(/\"true\"/g, true).replace(/\"on\"/g, true);
724
-
725
- obj = parseBody(request.body);
726
-
727
- if ( typeof(obj) != 'undefined' && obj.count() == 0 && request.body.length > 1 ) {
728
- try {
729
- request.put = merge(request.put, JSON.parse(request.body));
730
- } catch (err) {
731
- console.log('Case `put` [ merge error ]: ' + (err.stack||err.message))
732
- }
733
- }
734
- }
735
-
736
- } catch (err) {
737
- var msg = '[ '+request.url+' ]\nCould not decodeURIComponent(requestBody).\n'+ err.stack;
738
- console.error(msg);
739
- throwError(response, 500, msg);
740
- }
741
-
742
- } else {
743
- // 2016-05-19: fix to handle requests from swagger/express
744
- if (request.body.count() == 0 && typeof(request.query) != 'string' && request.query.count() > 0 ) {
745
- request.body = request.query
746
- }
747
- var bodyStr = JSON.stringify(request.body);
748
- // false & true case
749
- if ( /(\"false\"|\"true\"|\"on\")/.test(bodyStr) )
750
- bodyStr = bodyStr.replace(/\"false\"/g, false).replace(/\"true\"/g, true).replace(/\"on\"/g, true);
751
-
752
- obj = JSON.parse(bodyStr)
753
- }
754
-
755
- if ( obj && typeof(obj) != 'undefined' && obj.count() > 0 ) {
756
- // still need this to allow compatibility with express & connect middlewares
757
- request.body = request.put = merge(request.put, obj);
758
- }
759
-
760
-
761
- request.query = undefined; // added on september 13 2016
762
- request.post = undefined;
763
- request.delete = undefined;
764
- request.get = undefined;
765
- break;
766
-
767
-
768
- case 'delete':
769
- if ( request.query.count() > 0 ) {
770
- request.delete = request.query;
771
- }
772
- // else, matching route params against url context instead once route is identified
773
-
774
- request.post = undefined;
775
- request.put = undefined;
776
- request.get = undefined;
777
- break
778
-
779
-
780
- };
781
-
782
- loadBundleConfiguration(request, response, next, function (err, bundle, pathname, config, req, res, next) {
783
- if (!req.handled) {
784
- req.handled = true;
785
- if (err) {
786
- if (!res.headersSent)
787
- throwError(response, 500, 'Internal server error\n' + err.stack, next)
788
- } else {
789
- handle(req, res, next, bundle, pathname, config)
790
- }
791
- } else {
792
- next()
793
- }
794
- })
795
-
796
- });
797
-
798
- if (request.end) request.end();
799
-
800
- } //EO if multipart
801
-
802
- });//EO this.instance
803
-
804
- var hostname = self.conf[self.appName][self.env].protocol + '://' + self.conf[self.appName][self.env].host + ':' + self.conf[self.appName][self.env].port[self.conf[self.appName][self.env].protocol];
805
- console.info(
806
- '\nbundle: [ ' + self.appName +' ]',
807
- '\nenv: [ '+ self.env +' ]',
808
- //'\nport: ' + self.conf[self.appName][self.env].port.http,
809
- '\npid: ' + process.pid,
810
- '\nThis way please -> '+ hostname
811
- );
812
-
813
-
814
- self.instance.listen(self.conf[self.appName][self.env].port.http);//By Default 3100
815
- //self.instance.timeout = 120000; // check node.js express & documentation
816
- self.emit('started', self.conf[self.appName][self.env])
817
- }
818
-
819
- var getHead = function(file) {
820
- var s = file.split(/\./);
821
- var ext = s[s.length-1];
822
- var type = undefined;
823
- var mime = self.conf[self.appName][self.env].server.coreConfiguration.mime;
824
-
825
- if( typeof(mime[ext]) != 'undefiend' ) {
826
- type = mime[ext];
827
- if (!type) {
828
- console.warn('[ '+file+' ] extension: `'+s[2]+'` not supported by gina: `core/mime.types`. Replacing with `plain/text` ')
829
- }
830
- }
831
- return type || 'plain/text'
832
- }
833
-
834
- var loadBundleConfiguration = function(req, res, next, callback) {
835
-
836
- var config = new Config();
837
- config.setBundles(self.bundles);
838
- var conf = config.getInstance(); // for all loaded bundles
839
- if ( typeof(conf) != 'undefined') {//for cacheless mode
840
- self.conf = conf
841
- }
842
-
843
- var pathname = url.parse(req.url, true).pathname;
844
- var bundle = self.appName; // by default
845
-
846
- // finding bundle
847
- if (self.isStandalone) {
848
-
849
- end:
850
- for (var b in conf) {
851
- if ( typeof(conf[b][self.env].content) != 'undefined' && typeof(conf[b][self.env].content.statics) != 'undefined' && conf[b][self.env].content.statics.count() > 0 ) {
852
- for (var s in conf[b][self.env].content.statics) {
853
- s = (s.substr(0,1) == '/') ? s.substr(1) : s;
854
- if ( (new RegExp('^/'+s)).test(pathname) ) {
855
- bundle = b;
856
- break end
857
- }
858
- }
859
- } else {
860
- // no statics ... use startingApp and leave it to handle()
861
- self.isNotStatic = true
862
- break
863
- }
864
- }
865
- }
866
-
867
-
868
- if ( /\/favicon\.ico/.test(pathname) && !hasViews(bundle)) {
869
- callback(false, bundle, pathname, config, req, res, next);
870
- return false
871
- }
872
-
873
- onBundleConfigLoaded(bundle, {
874
- err : false,
875
- config : config,
876
- pathname : pathname,
877
- req : req,
878
- res : res,
879
- conf : config,
880
- next : next,
881
- callback : callback
882
- })
883
- }
884
-
885
- var onBundleConfigLoaded = function(bundle, options) {
886
- var err = options.err
887
- , cacheless = options.config.isCacheless()
888
- , pathname = options.pathname
889
- , req = options.req
890
- , res = options.res
891
- , config = options.conf
892
- , next = options.next
893
- , callback = options.callback;
894
-
895
- //Reloading assets & files.
896
- if (!cacheless) { // all but dev & debug
897
- callback(err, bundle, pathname, options.config, req, res, next)
898
- } else {
899
- config.refresh(bundle, function(err, routing) {
900
- if (err) {
901
- throwError(res, 500, 'Internal Server Error: \n' + (err.stack||err), next)
902
- } else {
903
- //refreshing routing at the same time.
904
- self.routing = routing;
905
- callback(err, bundle, pathname, options.config, req, res, next)
906
- }
907
- })
908
- }
909
- }
910
-
911
- var handle = function(req, res, next, bundle, pathname, config) {
912
- var matched = false
913
- , isRoute = {}
914
- , withViews = hasViews(bundle)
915
- , router = local.router
916
- , cacheless = config.isCacheless()
917
- , wroot = null
918
- , isXMLRequest = self.conf[bundle][self.env].server.request.isXMLRequest;
919
-
920
- if (self.conf[bundle][self.env]['hostname'].replace(self.conf[bundle][self.env]['protocol'] + '://', '') != req.headers.host) {
921
- self.conf[bundle][self.env]['hostname'] = req.headers.host
922
- }
923
-
924
- router.setMiddlewareInstance(self.instance);
925
-
926
- //Middleware configuration.
927
- req.setEncoding(self.conf[bundle][self.env].encoding);
928
-
929
- try {
930
- var params = {}
931
- , routing = JSON.parse(JSON.stringify( config.getRouting(bundle, self.env) ));
932
-
933
- if ( routing == null || routing.count() == 0 ) {
934
- console.error('Malformed routing or Null value for bundle [' + bundle + '] => ' + req.originalUrl);
935
- throwError(res, 500, 'Internal server error\nMalformed routing or Null value for bundle [' + bundle + '] => ' + req.originalUrl, next);
936
- }
937
-
938
- } catch (err) {
939
- throwError(res, 500, err.stack, next)
940
- }
941
-
942
-
943
- out:
944
- for (var rule in routing) {
945
- if (typeof(routing[rule]['param']) == 'undefined')
946
- break;
947
-
948
- if (routing[rule].bundle != bundle) continue;
949
-
950
- //Preparing params to relay to the router.
951
- params = {
952
- method : routing[rule].method || req.method,
953
- requirements : routing[rule].requirements,
954
- namespace : routing[rule].namespace || undefined,
955
- url : unescape(pathname), /// avoid %20
956
- rule : routing[rule].originalRule || rule,
957
- param : routing[rule].param,
958
- middleware : routing[rule].middleware,
959
- bundle : routing[rule].bundle,
960
- isXMLRequest : isXMLRequest
961
- };
962
- //Parsing for the right url.
963
- try {
964
- isRoute = router.compareUrls(req, params, routing[rule].url);
965
- } catch (err) {
966
- throwError(res, 500, 'Rule [ '+rule+' ] needs your attention.\n'+err.stack);
967
- break;
968
- }
969
-
970
- if (pathname === routing[rule].url || isRoute.past) {
971
-
972
- //console.debug('Server is about to route to '+ pathname);
973
-
974
- if (!routing[rule].method && req.method) { // setting client request method if no method is defined in routing
975
- routing[rule].method = req.method
976
- } else if (!routing[rule].method) { // by default
977
- routing[rule].method = 'GET'
978
- }
979
-
980
- var allowed = (typeof(routing[rule].method) == 'undefined' || routing[rule].method.length > 0 || routing[rule].method.indexOf(req.method) != -1)
981
- if (!allowed) {
982
- throwError(res, 405, 'Method Not Allowed for [' + params.bundle + '] => ' + req.originalUrl);
983
- break;
984
- } else {
985
-
986
-
987
- // comparing routing method VS request.url method
988
- if ( routing[rule].method.toLowerCase() != req.method.toLowerCase() ) {
989
- throwError(res, 405, 'Method Not Allowed.\n'+ ' `'+req.originalUrl+'` is expecting `' + routing[rule].method.toUpperCase() +'` method but got `'+ req.method.toUpperCase() +'` instead');
990
- break
991
- }
992
-
993
- // handling GET method exception - if no param found
994
- var methods = ['get', 'delete'], method = req.method.toLowerCase();
995
- if (
996
- methods.indexOf(method) > -1 && typeof(req.query) != 'undefined' && req.query.count() == 0
997
- || methods.indexOf(method) > -1 && typeof(req.query) == 'undefined' && typeof(req.params) != 'undefined' && req.params.count() > 1
998
- ) {
999
- var p = 0;
1000
- for (var parameter in req.params) {
1001
- if (p > 0) {
1002
- req[method][parameter] = req.params[parameter]
1003
- }
1004
- ++p
1005
- }
1006
- } else if (method == 'put') {
1007
- var p = 0;
1008
- for (var parameter in req.params) {
1009
- if (p > 0) {
1010
- req[method][parameter] = req.params[parameter]
1011
- }
1012
- ++p
1013
- }
1014
- }
1015
-
1016
-
1017
- // onRouting Event ???
1018
- if (isRoute.past) {
1019
- if ( cacheless ) {
1020
- config.refreshModels(params.bundle, self.env, function onModelRefreshed(err){
1021
- if (err) {
1022
- throwError(res, 500, err.msg||err.stack , next)
1023
- } else {
1024
- router.route(req, res, next, params)
1025
- }
1026
- })
1027
- } else {
1028
- console.debug('[ 200 ] '+ pathname);
1029
- router.route(req, res, next, params)
1030
- }
1031
- }
1032
- }
1033
- matched = true;
1034
- isRoute = {};
1035
- break out;
1036
-
1037
- }
1038
- }
1039
-
1040
-
1041
- if (!matched) {
1042
-
1043
- //if ( typeof(self.isNotStatic) != 'undefined' && !res.headersSent) {
1044
- // delete self.isNotStatic;
1045
- // throwError(res, 404, 'Page not found: \n' + pathname, next)
1046
- //}
1047
- // find targeted bundle
1048
- var allowed = null
1049
- , conf = null
1050
- , uri = ''
1051
- , score = 0
1052
- , tmpKey = ''
1053
- , key = ''
1054
- , filename = ''
1055
- , conf = self.conf[bundle][self.env]
1056
- , wroot = conf.server.webroot;
1057
-
1058
- //webroot test
1059
- if (wroot != '/') {
1060
- uri = (pathname.replace(wroot, '')).split('/');
1061
- for (var s in conf.content.statics) {
1062
- s = (s.substr(0,1) == '/') ? s.substr(1) : s;
1063
- if ( (new RegExp('^/'+s)).test( pathname ) ) {
1064
- score = s.length;
1065
- if ( score > 0 && score > tmpKey.length) {
1066
- tmpKey = s
1067
- }
1068
- }
1069
- }
1070
-
1071
- if ( typeof(conf.content.statics) == 'undefined' || typeof(conf.content.statics[tmpKey]) != 'undefined' ) {
1072
- key = tmpKey
1073
- } else {
1074
- key = pathname
1075
- }
1076
-
1077
- // we add it into statics
1078
- if ( withViews && typeof(conf.content.statics[key]) == 'undefined' && conf.content.views.default.views != conf.content.views.default.html) {
1079
- conf.content.statics[key] = conf.content.views.default.views +'/'+ uri.join('/')
1080
- } else if (withViews && typeof(conf.content.statics[key]) == 'undefined') {
1081
- conf.content.statics[key] = conf.content.views.default.html +'/'+ uri.join('/') // normal case
1082
- }
1083
-
1084
-
1085
-
1086
- uri = pathname.split('/');
1087
- /** TODO - remove this
1088
- uri = (pathname.replace(wroot, '')).split('/');
1089
- var len = uri.length;
1090
-
1091
- uri.splice(0, 1);
1092
-
1093
- key = pathname.substr(1);
1094
- // we add it into statics
1095
- if ( withViews && typeof(conf.content.statics[key]) == 'undefined' && conf.content.views.default.views != conf.content.views.default.html) {
1096
- conf.content.statics[key] = conf.content.views.default.views +'/'+ uri.join('/')
1097
- } else if (withViews && typeof(conf.content.statics[key]) == 'undefined') {
1098
- conf.content.statics[key] = conf.content.views.default.html +'/'+ uri.join('/') // normal case
1099
- }
1100
- */
1101
-
1102
- } else {
1103
-
1104
- for (var s in conf.content.statics) {
1105
- s = (s.substr(0,1) == '/') ? s.substr(1) : s;
1106
- if ( (new RegExp('^/'+s)).test( pathname ) ) {
1107
- score = s.length;
1108
- if ( score > 0 && score > tmpKey.length) {
1109
- tmpKey = s
1110
- }
1111
- }
1112
- }
1113
- uri = pathname.split('/');
1114
-
1115
- if ( typeof(conf.content.statics) == 'undefined' || typeof(conf.content.statics[tmpKey]) != 'undefined' ) {
1116
- key = tmpKey
1117
- } else {
1118
- uri.splice(0, 1);
1119
- key = tmpKey + '/'+ uri.join('/')
1120
- }
1121
- }
1122
-
1123
- //static filter
1124
- if ( typeof(conf.content.statics) != 'undefined'
1125
- && typeof(conf.content.statics[key]) != 'undefined'
1126
- && typeof(key) != 'undefined'
1127
- && req.url === wroot + req.url.replace(wroot, '')
1128
- ) {
1129
- // No sessions for statics
1130
- if (req.session) {
1131
- delete req['session']
1132
- }
1133
-
1134
- uri = uri.join('/');
1135
- //if ( !/\.(.*)$/.test(key) ) {
1136
- if ( /\/$/.test(key) ) {
1137
- filename = _(path.join(conf.content.statics[key]), true)
1138
- } else {
1139
-
1140
- if ( /\//.test(key) ) {
1141
- filename = _(path.join(conf.content.statics[key], uri.replace((new RegExp('(/'+key+'|'+key +')')), '')), true)
1142
- } else {
1143
- // !!! this is adding a slash in the end .. not good !
1144
- filename = _(path.join(conf.content.statics[key], uri.replace(key, '')), true)
1145
- if (filename.substr(filename.length-1, 1) == '/' ) {
1146
- filename = filename.substr(0, filename.length-1)
1147
- }
1148
- }
1149
- }
1150
-
1151
- fs.exists(filename, function(exists) {
1152
-
1153
- if (exists) {
1154
-
1155
- if (fs.statSync(filename).isDirectory()) filename += '/index.html';
1156
-
1157
- if (cacheless) {
1158
- delete require.cache[filename]
1159
- }
1160
-
1161
- fs.readFile(filename, "binary", function(err, file) {
1162
- if (err) {
1163
- throwError(res, 404, 'Page not found: \n' + filename, next);
1164
- return
1165
- }
1166
- if (!res.headersSent) {
1167
- try {
1168
- res.setHeader("Content-Type", getHead(filename));
1169
- // adding handler `gina.ready(...)` wrapper
1170
- var conf = getContext('gina').config, hanlersPath = self.conf[conf.bundle][conf.env].content.statics.handlers;
1171
- if ( new RegExp('^'+ hanlersPath).test(filename) ) {
1172
- file = '(gina.ready(function onGinaReady($){\n'+ file + '\n},window["originalContext"]));'
1173
- }
1174
-
1175
- if (cacheless) {
1176
- // source maps integration for javascript & css
1177
- if ( /(.js|.css)$/.test(filename) && fs.existsSync(filename +'.map') ) {
1178
- res.setHeader("X-SourceMap", pathname +'.map')
1179
- }
1180
-
1181
- // serve without cache
1182
- res.writeHead(200, {
1183
- 'Cache-Control': 'no-cache, no-store, must-revalidate', // preventing browsers from caching it
1184
- 'Pragma': 'no-cache',
1185
- 'Expires': '0'
1186
- });
1187
-
1188
- } else {
1189
- res.writeHead(200)
1190
- }
1191
-
1192
- res.write(file, 'binary');
1193
- res.end()
1194
- } catch(err) {
1195
- throwError(res, 500, err.stack)
1196
- }
1197
- }
1198
- });
1199
- } else {
1200
- // else
1201
- if (wroot.substr(wroot.length-1,1) == '/') {
1202
- wroot = wroot.substr(wroot.length-1,1).replace('/', '')
1203
- }
1204
- // web services case ... when you hit from a web browser
1205
- if (pathname === wroot + '/favicon.ico' && !withViews && !res.headersSent ) {
1206
- res.writeHead(200, {'Content-Type': 'image/x-icon'} );
1207
- res.end()
1208
- }
1209
-
1210
- if (!res.headersSent)
1211
- throwError(res, 404, 'Page not found: \n' + pathname, next)
1212
-
1213
- }//EO exists
1214
- })//EO static filter
1215
-
1216
- } else if ( // might be rendering an existing static html page
1217
- /\.html$/.test(key)
1218
- && req.url === wroot + req.url.replace(wroot, '')
1219
- ) {
1220
- uri = uri.join('/');
1221
- // publishing from views
1222
- if ( /\//.test(key) ) {
1223
- filename = _(path.join(conf.content.statics['html'], uri.replace((new RegExp('(/'+key+'|'+key +')')), '')), true)
1224
- } else {
1225
- filename = _(path.join(conf.content.statics['html'], uri.replace(key, '')), true)
1226
- }
1227
-
1228
- fs.exists(filename, function(exists) {
1229
-
1230
- if(exists) {
1231
-
1232
- if (fs.statSync(filename).isDirectory()) filename += 'index.html';
1233
-
1234
- if (cacheless) {
1235
- delete require.cache[filename]
1236
- }
1237
-
1238
- fs.readFile(filename, "binary", function(err, file) {
1239
- if (err) {
1240
- throwError(res, 404, 'Page not found: \n' + filename, next);
1241
- return
1242
- }
1243
- if (!res.headersSent) {
1244
- try {
1245
- res.setHeader("Content-Type", getHead(filename));
1246
- if (cacheless) {
1247
- // serve without cache
1248
- res.writeHead(200, {
1249
- 'Cache-Control': 'no-cache, no-store, must-revalidate', // preventing browsers from caching it
1250
- 'Pragma': 'no-cache',
1251
- 'Expires': '0'
1252
- });
1253
-
1254
- } else {
1255
- res.writeHead(200)
1256
- }
1257
-
1258
- res.write(file, 'binary');
1259
- res.end()
1260
- } catch(err) {
1261
- throwError(res, 500, err.stack)
1262
- }
1263
- }
1264
- });
1265
- } else {
1266
- // else
1267
- if (wroot.substr(wroot.length-1,1) == '/') {
1268
- wroot = wroot.substr(wroot.length-1,1).replace('/', '')
1269
- }
1270
- // web services case ... when you hit from a web browser
1271
- if (pathname === wroot + '/favicon.ico' && !withViews && !res.headersSent ) {
1272
- res.writeHead(200, {'Content-Type': 'image/x-icon'} );
1273
- res.end()
1274
- }
1275
-
1276
- if (!res.headersSent)
1277
- throwError(res, 404, 'Page not found: \n' + pathname, next)
1278
-
1279
- }//EO exists
1280
- })//EO static filter
1281
-
1282
- } else {
1283
- // else
1284
- if (wroot.substr(wroot.length-1,1) == '/') {
1285
- wroot = wroot.substr(wroot.length-1,1).replace('/', '')
1286
- }
1287
-
1288
- if (pathname === wroot + '/favicon.ico' && !withViews && !res.headersSent ) {
1289
- res.writeHead(200, {'Content-Type': 'image/x-icon'} );
1290
- res.end()
1291
- }
1292
- if (!res.headersSent)
1293
- throwError(res, 404, 'Page not found: \n' + pathname, next)
1294
- }
1295
-
1296
- }
1297
- }
1298
-
1299
- var throwError = function(res, code, msg, next) {
1300
- var withViews = local.hasViews[self.appName] || hasViews(self.appName);
1301
- var isUsingTemplate = self.conf[self.appName][self.env].template;
1302
- var isXMLRequest = self.conf[self.appName][self.env].server.request.isXMLRequest;
1303
-
1304
- if (!res.headersSent) {
1305
- if (isXMLRequest || !withViews || !isUsingTemplate ) {
1306
- // allowing this.throwError(err)
1307
- if ( typeof(code) == 'object' && !msg && typeof(code.status) != 'undefined' && typeof(code.error) != 'undefined' ) {
1308
- msg = code.error;
1309
- code = code.status;
1310
- }
1311
-
1312
- // Internet Explorer override
1313
- if ( /msie/i.test(local.request.headers['user-agent']) ) {
1314
- res.writeHead(code, "Content-Type", "text/plain")
1315
- } else {
1316
- res.writeHead(code, { 'Content-Type': 'application/json'} )
1317
- }
1318
-
1319
- console.error(res.req.method +' [ '+code+' ] '+ res.req.url);
1320
- res.end(JSON.stringify({
1321
- status: code,
1322
- error: msg
1323
- }));
1324
- res.headersSent = true
1325
- } else {
1326
- res.writeHead(code, { 'Content-Type': 'text/html'} );
1327
- console.error(res.req.method +' [ '+code+' ] '+ res.req.url);
1328
- res.end('<h1>Error '+ code +'.</h1><pre>'+ msg + '</pre>');
1329
- res.headersSent = true
1330
- }
1331
- } else {
1332
- next()
1333
- }
1334
- }
1335
-
1336
-
1337
- this.onConfigured = function(callback) {
1338
- self.once('configured', function(err, instance, middleware, conf) {
1339
- callback(err, instance, middleware, conf)
1340
- });
1341
-
1342
- init(options);
1343
-
1344
- return {
1345
- onStarted: self.onStarted
1346
- }
1347
- }
1348
-
1349
- this.onStarted = function(callback) {
1350
- self.once('started', function(conf){
1351
- callback(conf)
1352
- });
1353
-
1354
- return {
1355
- onConfigured: self.onConfigured
1356
- }
1357
- }
1358
-
1359
- return this
1360
- };
1361
-
1362
- Server = inherits(Server, EventEmitter);
1363
- module.exports = Server