jimpex 8.0.0 → 9.0.0

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 (205) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +2 -2
  3. package/dist/app/index.d.mts +14 -0
  4. package/dist/app/index.d.ts +5 -4
  5. package/dist/app/index.js +4 -0
  6. package/dist/app/jimpex.d.mts +14 -0
  7. package/dist/app/jimpex.d.ts +3 -2
  8. package/dist/app/jimpex.js +225 -0
  9. package/dist/app/jimpex.js.map +1 -1
  10. package/dist/controllers/common/config.d.mts +79 -0
  11. package/dist/controllers/common/config.d.ts +3 -2
  12. package/dist/controllers/common/config.js +18 -0
  13. package/dist/controllers/common/config.js.map +1 -1
  14. package/dist/controllers/common/health.d.mts +83 -0
  15. package/dist/controllers/common/health.d.ts +4 -3
  16. package/dist/controllers/common/health.js +18 -0
  17. package/dist/controllers/common/health.js.map +1 -1
  18. package/dist/controllers/common/index.d.mts +21 -0
  19. package/dist/controllers/common/index.d.ts +4 -4
  20. package/dist/controllers/common/index.js +6 -0
  21. package/dist/controllers/common/statics.d.mts +215 -0
  22. package/dist/controllers/common/statics.d.ts +4 -4
  23. package/dist/controllers/common/statics.js +51 -0
  24. package/dist/controllers/common/statics.js.map +1 -1
  25. package/dist/controllers/index.d.mts +24 -0
  26. package/dist/controllers/index.d.ts +4 -4
  27. package/dist/controllers/index.js +5 -0
  28. package/dist/controllers/utils/gateway.d.mts +725 -0
  29. package/dist/controllers/utils/gateway.d.ts +4 -3
  30. package/dist/controllers/utils/gateway.js +152 -0
  31. package/dist/controllers/utils/gateway.js.map +1 -1
  32. package/dist/controllers/utils/index.d.mts +17 -0
  33. package/dist/controllers/utils/index.d.ts +4 -3
  34. package/dist/controllers/utils/index.js +4 -0
  35. package/dist/esm/app/jimpex.js +222 -1
  36. package/dist/esm/app/jimpex.js.map +1 -1
  37. package/dist/esm/{chunk-T2T6Q22Z.js → chunk-2B2CG5KL.js} +1 -1
  38. package/dist/esm/controllers/common/config.js +19 -1
  39. package/dist/esm/controllers/common/config.js.map +1 -1
  40. package/dist/esm/controllers/common/health.js +19 -1
  41. package/dist/esm/controllers/common/health.js.map +1 -1
  42. package/dist/esm/controllers/common/statics.js +48 -1
  43. package/dist/esm/controllers/common/statics.js.map +1 -1
  44. package/dist/esm/controllers/utils/gateway.js +153 -1
  45. package/dist/esm/controllers/utils/gateway.js.map +1 -1
  46. package/dist/esm/middlewares/common/errorHandler.js +25 -1
  47. package/dist/esm/middlewares/common/errorHandler.js.map +1 -1
  48. package/dist/esm/middlewares/common/forceHTTPS.js +13 -1
  49. package/dist/esm/middlewares/common/forceHTTPS.js.map +1 -1
  50. package/dist/esm/middlewares/common/hsts.js +22 -1
  51. package/dist/esm/middlewares/common/hsts.js.map +1 -1
  52. package/dist/esm/middlewares/html/fastHTML.js +55 -1
  53. package/dist/esm/middlewares/html/fastHTML.js.map +1 -1
  54. package/dist/esm/middlewares/html/showHTML.js +33 -1
  55. package/dist/esm/middlewares/html/showHTML.js.map +1 -1
  56. package/dist/esm/middlewares/utils/versionValidator.js +35 -1
  57. package/dist/esm/middlewares/utils/versionValidator.js.map +1 -1
  58. package/dist/esm/services/common/appError.js +48 -2
  59. package/dist/esm/services/common/appError.js.map +1 -1
  60. package/dist/esm/services/common/httpError.js +10 -1
  61. package/dist/esm/services/common/httpError.js.map +1 -1
  62. package/dist/esm/services/common/index.js +1 -1
  63. package/dist/esm/services/common/sendFile.js +1 -1
  64. package/dist/esm/services/frontend/frontendFs.js +29 -1
  65. package/dist/esm/services/frontend/frontendFs.js.map +1 -1
  66. package/dist/esm/services/frontend/index.js +1 -1
  67. package/dist/esm/services/html/htmlGenerator.js +51 -1
  68. package/dist/esm/services/html/htmlGenerator.js.map +1 -1
  69. package/dist/esm/services/html/index.js +1 -1
  70. package/dist/esm/services/http/apiClient.js +27 -1
  71. package/dist/esm/services/http/apiClient.js.map +1 -1
  72. package/dist/esm/services/http/http.js +50 -1
  73. package/dist/esm/services/http/http.js.map +1 -1
  74. package/dist/esm/services/http/index.js +1 -1
  75. package/dist/esm/services/http/responsesBuilder.js +49 -2
  76. package/dist/esm/services/http/responsesBuilder.js.map +1 -1
  77. package/dist/esm/services/utils/ensureBearerToken.js +17 -1
  78. package/dist/esm/services/utils/ensureBearerToken.js.map +1 -1
  79. package/dist/esm/services/utils/index.js +1 -1
  80. package/dist/esm/utils/fns/others.js +1 -1
  81. package/dist/esm/utils/fns/routes.js +1 -1
  82. package/dist/esm/utils/fns/routes.js.map +1 -1
  83. package/dist/esm/utils/fns/statuses.js +1 -1
  84. package/dist/esm/utils/fns/text.js +1 -1
  85. package/dist/esm/utils/wrappers.js +1 -1
  86. package/dist/{jimpex-7eaee271.d.ts → index-b2a04c78.d.ts} +9 -5
  87. package/dist/index-efeb437e.d.ts +1282 -0
  88. package/dist/index.d.mts +46 -0
  89. package/dist/index.d.ts +1 -1
  90. package/dist/index.js +9 -0
  91. package/dist/middlewares/common/errorHandler.d.mts +132 -0
  92. package/dist/middlewares/common/errorHandler.d.ts +4 -3
  93. package/dist/middlewares/common/errorHandler.js +24 -0
  94. package/dist/middlewares/common/errorHandler.js.map +1 -1
  95. package/dist/middlewares/common/forceHTTPS.d.mts +69 -0
  96. package/dist/middlewares/common/forceHTTPS.d.ts +5 -4
  97. package/dist/middlewares/common/forceHTTPS.js +12 -0
  98. package/dist/middlewares/common/forceHTTPS.js.map +1 -1
  99. package/dist/middlewares/common/hsts.d.mts +110 -0
  100. package/dist/middlewares/common/hsts.d.ts +5 -4
  101. package/dist/middlewares/common/hsts.js +21 -0
  102. package/dist/middlewares/common/hsts.js.map +1 -1
  103. package/dist/middlewares/common/index.d.mts +22 -0
  104. package/dist/middlewares/common/index.d.ts +4 -3
  105. package/dist/middlewares/common/index.js +6 -0
  106. package/dist/middlewares/html/fastHTML.d.mts +180 -0
  107. package/dist/middlewares/html/fastHTML.d.ts +4 -4
  108. package/dist/middlewares/html/fastHTML.js +54 -0
  109. package/dist/middlewares/html/fastHTML.js.map +1 -1
  110. package/dist/middlewares/html/index.d.mts +21 -0
  111. package/dist/middlewares/html/index.d.ts +4 -4
  112. package/dist/middlewares/html/index.js +5 -0
  113. package/dist/middlewares/html/showHTML.d.mts +127 -0
  114. package/dist/middlewares/html/showHTML.d.ts +4 -4
  115. package/dist/middlewares/html/showHTML.js +32 -0
  116. package/dist/middlewares/html/showHTML.js.map +1 -1
  117. package/dist/middlewares/index.d.mts +30 -0
  118. package/dist/middlewares/index.d.ts +4 -4
  119. package/dist/middlewares/index.js +6 -0
  120. package/dist/middlewares/utils/index.d.mts +20 -0
  121. package/dist/middlewares/utils/index.d.ts +4 -3
  122. package/dist/middlewares/utils/index.js +4 -0
  123. package/dist/middlewares/utils/versionValidator.d.mts +215 -0
  124. package/dist/middlewares/utils/versionValidator.d.ts +4 -3
  125. package/dist/middlewares/utils/versionValidator.js +34 -0
  126. package/dist/middlewares/utils/versionValidator.js.map +1 -1
  127. package/dist/services/common/appError.d.mts +139 -0
  128. package/dist/services/common/appError.d.ts +4 -3
  129. package/dist/services/common/appError.js +47 -1
  130. package/dist/services/common/appError.js.map +1 -1
  131. package/dist/services/common/httpError.d.mts +80 -0
  132. package/dist/services/common/httpError.d.ts +4 -3
  133. package/dist/services/common/httpError.js +9 -0
  134. package/dist/services/common/httpError.js.map +1 -1
  135. package/dist/services/common/index.d.mts +47 -0
  136. package/dist/services/common/index.d.ts +4 -4
  137. package/dist/services/common/index.js +4 -1
  138. package/dist/services/common/sendFile.d.mts +102 -0
  139. package/dist/services/common/sendFile.d.ts +3 -3
  140. package/dist/services/frontend/frontendFs.d.mts +96 -0
  141. package/dist/services/frontend/frontendFs.d.ts +3 -3
  142. package/dist/services/frontend/frontendFs.js +32 -0
  143. package/dist/services/frontend/frontendFs.js.map +1 -1
  144. package/dist/services/frontend/index.d.mts +40 -0
  145. package/dist/services/frontend/index.d.ts +4 -4
  146. package/dist/services/frontend/index.js +2 -1
  147. package/dist/services/html/htmlGenerator.d.mts +237 -0
  148. package/dist/services/html/htmlGenerator.d.ts +2 -2
  149. package/dist/services/html/htmlGenerator.js +50 -0
  150. package/dist/services/html/htmlGenerator.js.map +1 -1
  151. package/dist/services/html/index.d.mts +43 -0
  152. package/dist/services/html/index.d.ts +4 -4
  153. package/dist/services/html/index.js +2 -1
  154. package/dist/services/http/apiClient.d.mts +170 -0
  155. package/dist/services/http/apiClient.d.ts +4 -3
  156. package/dist/services/http/apiClient.js +26 -0
  157. package/dist/services/http/apiClient.js.map +1 -1
  158. package/dist/services/http/http.d.mts +176 -0
  159. package/dist/services/http/http.d.ts +4 -3
  160. package/dist/services/http/http.js +53 -0
  161. package/dist/services/http/http.js.map +1 -1
  162. package/dist/services/http/index.d.mts +51 -0
  163. package/dist/services/http/index.d.ts +4 -3
  164. package/dist/services/http/index.js +4 -1
  165. package/dist/services/http/responsesBuilder.d.mts +179 -0
  166. package/dist/services/http/responsesBuilder.d.ts +3 -2
  167. package/dist/services/http/responsesBuilder.js +48 -1
  168. package/dist/services/http/responsesBuilder.js.map +1 -1
  169. package/dist/services/index.d.mts +33 -0
  170. package/dist/services/index.d.ts +4 -4
  171. package/dist/services/index.js +8 -0
  172. package/dist/services/utils/ensureBearerToken.d.mts +158 -0
  173. package/dist/services/utils/ensureBearerToken.d.ts +5 -4
  174. package/dist/services/utils/ensureBearerToken.js +16 -0
  175. package/dist/services/utils/ensureBearerToken.js.map +1 -1
  176. package/dist/services/utils/index.d.mts +44 -0
  177. package/dist/services/utils/index.d.ts +4 -3
  178. package/dist/services/utils/index.js +2 -1
  179. package/dist/types/events.d.mts +14 -0
  180. package/dist/types/events.d.ts +5 -4
  181. package/dist/types/express.d.mts +10 -0
  182. package/dist/types/http.d.mts +79 -0
  183. package/dist/types/index.d.mts +14 -0
  184. package/dist/types/index.d.ts +1 -1
  185. package/dist/types/index.js +9 -0
  186. package/dist/types/options.d.mts +14 -0
  187. package/dist/types/options.d.ts +4 -3
  188. package/dist/types/utils.d.mts +48 -0
  189. package/dist/types/wootils.d.mts +4 -0
  190. package/dist/utils/fns/index.d.mts +5 -0
  191. package/dist/utils/fns/index.js +7 -0
  192. package/dist/utils/fns/others.d.mts +17 -0
  193. package/dist/utils/fns/routes.d.mts +39 -0
  194. package/dist/utils/fns/routes.js.map +1 -1
  195. package/dist/utils/fns/statuses.d.mts +45 -0
  196. package/dist/utils/fns/statuses.js +4 -0
  197. package/dist/utils/fns/statuses.js.map +1 -1
  198. package/dist/utils/fns/text.d.mts +9 -0
  199. package/dist/utils/index.d.mts +19 -0
  200. package/dist/utils/index.d.ts +5 -4
  201. package/dist/utils/index.js +5 -0
  202. package/dist/utils/wrappers.d.mts +14 -0
  203. package/dist/utils/wrappers.d.ts +4 -3
  204. package/package.json +43 -43
  205. /package/dist/esm/{chunk-T2T6Q22Z.js.map → chunk-2B2CG5KL.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/middlewares/common/hsts.ts"],"sourcesContent":["import { middlewareCreator } from '../../utils';\nimport { ExpressMiddleware } from '../../types';\n/**\n * The options to customize the HSTS header value.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security}\n * @group Middlewares/HSTS\n */\nexport type HSTSMiddlewareOptions = {\n /**\n * The time, in seconds, that the browser should remember that a site is only to be\n * accessed using HTTPS.\n *\n * @default 31536000\n */\n maxAge: number;\n /**\n * Whether or not the rule should apply to all sub domains.\n *\n * @default true\n */\n includeSubDomains: boolean;\n /**\n * Whether or not to include on the major browsers'\n * preload list. This directive is not part of the specification, for more information\n * about it, you should check the MDN documentation for the header.\n *\n * @default false\n */\n preload: boolean;\n};\n/**\n * A partial version of the {@link HSTSMiddlewareOptions}, to be used in the constructor\n * and the middleware creator.\n *\n * @group Middlewares/HSTS\n */\nexport type HSTSMiddlewarePartialOptions = Partial<HSTSMiddlewareOptions>;\n/**\n * The options for the middleware creator that will create the middleware, or not,\n * depending on the `enabled` option.\n *\n * @group Middlewares/HSTS\n */\nexport type HSTSMiddlewareSettings = HSTSMiddlewarePartialOptions & {\n /**\n * If it's not `true`, it won't return the middleware.\n */\n enabled?: boolean;\n};\n/**\n * Generates a middleware that includes the HSTS header on the responses.\n *\n * @see {@link https://tools.ietf.org/html/rfc6797}\n * @group Middleware Classes\n * @group Middlewares/HSTS\n * @prettierignore\n */\nexport class HSTS {\n /**\n * The customization options for the header.\n */\n protected readonly _options: HSTSMiddlewareOptions;\n /**\n * The value of the header that will be included in the responses.\n */\n protected readonly _header: string;\n /**\n * @param options The options to construct the class.\n */\n constructor(options: HSTSMiddlewarePartialOptions = {}) {\n this._options = {\n maxAge: 31536000,\n includeSubDomains: true,\n preload: false,\n ...options,\n };\n this._header = this._buildHeader();\n }\n /**\n * Generates the middleware that includes the HSTS header on the responses.\n */\n getMiddleware(): ExpressMiddleware {\n return (_, res, next) => {\n res.setHeader('Strict-Transport-Security', this._header);\n next();\n };\n }\n /**\n * The customization options.\n */\n get options(): Readonly<HSTSMiddlewareOptions> {\n return { ...this._options };\n }\n /**\n * The value of the header that will be included in the responses.\n */\n get header(): string {\n return this._header;\n }\n /**\n * Creates the header value based on the customization options.\n */\n protected _buildHeader(): string {\n const { maxAge, includeSubDomains, preload } = this._options;\n const directives = [`max-age=${maxAge}`];\n if (includeSubDomains) {\n directives.push('includeSubDomains');\n }\n\n if (preload) {\n directives.push('preload');\n }\n\n return directives.join('; ');\n }\n}\n/**\n * Creates the middleware that includes the HSTS header on the responses.\n *\n * @group Middlewares\n * @group Middlewares/HSTS\n */\nexport const hstsMiddleware = middlewareCreator(\n (options: HSTSMiddlewareSettings = {}) =>\n (app) => {\n const setting = app.getConfig<HSTSMiddlewareSettings | undefined>('hsts');\n if (\n !setting?.enabled ||\n (typeof options.enabled !== 'undefined' && !options.enabled)\n )\n return undefined;\n return new HSTS(options).getMiddleware();\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkC;AA0D3B,MAAM,KAAK;AAAA,EAYhB,YAAY,UAAwC,CAAC,GAAG;AARxD,wBAAmB;AAInB,wBAAmB;AAKjB,SAAK,WAAW;AAAA,MACd,QAAQ;AAAA,MACR,mBAAmB;AAAA,MACnB,SAAS;AAAA,MACT,GAAG;AAAA,IACL;AACA,SAAK,UAAU,KAAK,aAAa;AAAA,EACnC;AAAA,EAIA,gBAAmC;AACjC,WAAO,CAAC,GAAG,KAAK,SAAS;AACvB,UAAI,UAAU,6BAA6B,KAAK,OAAO;AACvD,WAAK;AAAA,IACP;AAAA,EACF;AAAA,EAIA,IAAI,UAA2C;AAC7C,WAAO,EAAE,GAAG,KAAK,SAAS;AAAA,EAC5B;AAAA,EAIA,IAAI,SAAiB;AACnB,WAAO,KAAK;AAAA,EACd;AAAA,EAIU,eAAuB;AAC/B,UAAM,EAAE,QAAQ,mBAAmB,QAAQ,IAAI,KAAK;AACpD,UAAM,aAAa,CAAC,WAAW,QAAQ;AACvC,QAAI,mBAAmB;AACrB,iBAAW,KAAK,mBAAmB;AAAA,IACrC;AAEA,QAAI,SAAS;AACX,iBAAW,KAAK,SAAS;AAAA,IAC3B;AAEA,WAAO,WAAW,KAAK,IAAI;AAAA,EAC7B;AACF;AAOO,MAAM,qBAAiB;AAAA,EAC5B,CAAC,UAAkC,CAAC,MAClC,CAAC,QAAQ;AACP,UAAM,UAAU,IAAI,UAA8C,MAAM;AACxE,QACE,CAAC,SAAS,WACT,OAAO,QAAQ,YAAY,eAAe,CAAC,QAAQ;AAEpD,aAAO;AACT,WAAO,IAAI,KAAK,OAAO,EAAE,cAAc;AAAA,EACzC;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/middlewares/common/hsts.ts"],"sourcesContent":["import { middlewareCreator } from '../../utils';\nimport { ExpressMiddleware } from '../../types';\n/**\n * The options to customize the HSTS header value.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security}\n * @group Middlewares/HSTS\n */\nexport type HSTSMiddlewareOptions = {\n /**\n * The time, in seconds, that the browser should remember that a site is only to be\n * accessed using HTTPS.\n *\n * @default 31536000\n */\n maxAge: number;\n /**\n * Whether or not the rule should apply to all sub domains.\n *\n * @default true\n */\n includeSubDomains: boolean;\n /**\n * Whether or not to include on the major browsers'\n * preload list. This directive is not part of the specification, for more information\n * about it, you should check the MDN documentation for the header.\n *\n * @default false\n */\n preload: boolean;\n};\n/**\n * A partial version of the {@link HSTSMiddlewareOptions}, to be used in the constructor\n * and the middleware creator.\n *\n * @group Middlewares/HSTS\n */\nexport type HSTSMiddlewarePartialOptions = Partial<HSTSMiddlewareOptions>;\n/**\n * The options for the middleware creator that will create the middleware, or not,\n * depending on the `enabled` option.\n *\n * @group Middlewares/HSTS\n */\nexport type HSTSMiddlewareSettings = HSTSMiddlewarePartialOptions & {\n /**\n * If it's not `true`, it won't return the middleware.\n */\n enabled?: boolean;\n};\n/**\n * Generates a middleware that includes the HSTS header on the responses.\n *\n * @see {@link https://tools.ietf.org/html/rfc6797}\n * @group Middleware Classes\n * @group Middlewares/HSTS\n * @prettierignore\n */\nexport class HSTS {\n /**\n * The customization options for the header.\n */\n protected readonly _options: HSTSMiddlewareOptions;\n /**\n * The value of the header that will be included in the responses.\n */\n protected readonly _header: string;\n /**\n * @param options The options to construct the class.\n */\n constructor(options: HSTSMiddlewarePartialOptions = {}) {\n this._options = {\n maxAge: 31536000,\n includeSubDomains: true,\n preload: false,\n ...options,\n };\n this._header = this._buildHeader();\n }\n /**\n * Generates the middleware that includes the HSTS header on the responses.\n */\n getMiddleware(): ExpressMiddleware {\n return (_, res, next) => {\n res.setHeader('Strict-Transport-Security', this._header);\n next();\n };\n }\n /**\n * The customization options.\n */\n get options(): Readonly<HSTSMiddlewareOptions> {\n return { ...this._options };\n }\n /**\n * The value of the header that will be included in the responses.\n */\n get header(): string {\n return this._header;\n }\n /**\n * Creates the header value based on the customization options.\n */\n protected _buildHeader(): string {\n const { maxAge, includeSubDomains, preload } = this._options;\n const directives = [`max-age=${maxAge}`];\n if (includeSubDomains) {\n directives.push('includeSubDomains');\n }\n\n if (preload) {\n directives.push('preload');\n }\n\n return directives.join('; ');\n }\n}\n/**\n * Creates the middleware that includes the HSTS header on the responses.\n *\n * @group Middlewares\n * @group Middlewares/HSTS\n */\nexport const hstsMiddleware = middlewareCreator(\n (options: HSTSMiddlewareSettings = {}) =>\n (app) => {\n const setting = app.getConfig<HSTSMiddlewareSettings | undefined>('hsts');\n if (\n !setting?.enabled ||\n (typeof options.enabled !== 'undefined' && !options.enabled)\n )\n return undefined;\n return new HSTS(options).getMiddleware();\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkC;AA0D3B,MAAM,KAAK;AAAA;AAAA;AAAA;AAAA,EAYhB,YAAY,UAAwC,CAAC,GAAG;AARxD;AAAA;AAAA;AAAA,wBAAmB;AAInB;AAAA;AAAA;AAAA,wBAAmB;AAKjB,SAAK,WAAW;AAAA,MACd,QAAQ;AAAA,MACR,mBAAmB;AAAA,MACnB,SAAS;AAAA,MACT,GAAG;AAAA,IACL;AACA,SAAK,UAAU,KAAK,aAAa;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA,EAIA,gBAAmC;AACjC,WAAO,CAAC,GAAG,KAAK,SAAS;AACvB,UAAI,UAAU,6BAA6B,KAAK,OAAO;AACvD,WAAK;AAAA,IACP;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,UAA2C;AAC7C,WAAO,EAAE,GAAG,KAAK,SAAS;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,SAAiB;AACnB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAIU,eAAuB;AAC/B,UAAM,EAAE,QAAQ,mBAAmB,QAAQ,IAAI,KAAK;AACpD,UAAM,aAAa,CAAC,WAAW,MAAM,EAAE;AACvC,QAAI,mBAAmB;AACrB,iBAAW,KAAK,mBAAmB;AAAA,IACrC;AAEA,QAAI,SAAS;AACX,iBAAW,KAAK,SAAS;AAAA,IAC3B;AAEA,WAAO,WAAW,KAAK,IAAI;AAAA,EAC7B;AACF;AAOO,MAAM,qBAAiB;AAAA,EAC5B,CAAC,UAAkC,CAAC,MAClC,CAAC,QAAQ;AACP,UAAM,UAAU,IAAI,UAA8C,MAAM;AACxE,QACE,CAAC,SAAS,WACT,OAAO,QAAQ,YAAY,eAAe,CAAC,QAAQ;AAEpD,aAAO;AACT,WAAO,IAAI,KAAK,OAAO,EAAE,cAAc;AAAA,EACzC;AACJ;","names":[]}
@@ -0,0 +1,22 @@
1
+ export { ErrorHandler, ErrorHandlerConstructorOptions, ErrorHandlerOptions, ErrorHandlerPartialOptions, ErrorHandlerResponseOptions, errorHandlerMiddleware } from './errorHandler.mjs';
2
+ export { ForceHTTPS, ForceHTTPSOptions, ForceHTTPSPartialOptions, forceHTTPSMiddleware } from './forceHTTPS.mjs';
3
+ export { HSTS, HSTSMiddlewareOptions, HSTSMiddlewarePartialOptions, HSTSMiddlewareSettings, hstsMiddleware } from './hsts.mjs';
4
+ import '@homer0/jimple';
5
+ import '../../utils/fns/statuses.mjs';
6
+ import 'statuses';
7
+ import '../../index-efeb437e.js';
8
+ import '../../types/express.mjs';
9
+ import 'express';
10
+ import '../../types/http.mjs';
11
+ import 'https';
12
+ import 'http';
13
+ import 'spdy';
14
+ import 'node-fetch';
15
+ import '../../types/utils.mjs';
16
+ import '@homer0/path-utils';
17
+ import '@homer0/simple-logger';
18
+ import '@homer0/simple-config';
19
+ import '@homer0/events-hub';
20
+ import '../../services/common/httpError.mjs';
21
+ import '../../services/common/appError.mjs';
22
+ import '../../services/http/responsesBuilder.mjs';
@@ -4,8 +4,7 @@ export { HSTS, HSTSMiddlewareOptions, HSTSMiddlewarePartialOptions, HSTSMiddlewa
4
4
  import '@homer0/jimple';
5
5
  import '../../utils/fns/statuses.js';
6
6
  import 'statuses';
7
- import '../../jimpex-7eaee271.js';
8
- import '@homer0/events-hub';
7
+ import '../../index-b2a04c78.js';
9
8
  import '../../types/express.js';
10
9
  import 'express';
11
10
  import '../../types/http.js';
@@ -13,9 +12,11 @@ import 'https';
13
12
  import 'http';
14
13
  import 'spdy';
15
14
  import 'node-fetch';
16
- import '@homer0/simple-config';
17
15
  import '../../types/utils.js';
16
+ import '@homer0/path-utils';
18
17
  import '@homer0/simple-logger';
18
+ import '@homer0/simple-config';
19
+ import '@homer0/events-hub';
19
20
  import '../../services/common/httpError.js';
20
21
  import '../../services/common/appError.js';
21
22
  import '../../services/http/responsesBuilder.js';
@@ -18,4 +18,10 @@ module.exports = __toCommonJS(common_exports);
18
18
  __reExport(common_exports, require("./errorHandler"), module.exports);
19
19
  __reExport(common_exports, require("./forceHTTPS"), module.exports);
20
20
  __reExport(common_exports, require("./hsts"), module.exports);
21
+ // Annotate the CommonJS export names for ESM import in node:
22
+ 0 && (module.exports = {
23
+ ...require("./errorHandler"),
24
+ ...require("./forceHTTPS"),
25
+ ...require("./hsts")
26
+ });
21
27
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,180 @@
1
+ import * as _homer0_jimple from '@homer0/jimple';
2
+ import { l as Events, J as Jimpex, R as MiddlewareConnectFn } from '../../index-efeb437e.js';
3
+ import { AsyncExpressMiddleware } from '../../types/express.mjs';
4
+ import { SendFile } from '../../services/common/sendFile.mjs';
5
+ import { HTMLGenerator } from '../../services/html/htmlGenerator.mjs';
6
+ import { Response, NextFunction } from 'express';
7
+ import '../../types/http.mjs';
8
+ import 'https';
9
+ import 'http';
10
+ import 'spdy';
11
+ import 'node-fetch';
12
+ import '../../types/utils.mjs';
13
+ import '@homer0/path-utils';
14
+ import '@homer0/simple-logger';
15
+ import '@homer0/simple-config';
16
+ import '@homer0/events-hub';
17
+ import '../../services/frontend/frontendFs.mjs';
18
+ import 'fs/promises';
19
+ import '@homer0/deferred';
20
+
21
+ /**
22
+ * The options to customize the behavior of the middleware.
23
+ *
24
+ * @group Middlewares/FastHTML
25
+ */
26
+ type FastHTMLOptions = {
27
+ /**
28
+ * The name of the file the middleware will serve. If the {@link HTMLGenerator} service
29
+ * is available, it will be overriden by the service.
30
+ *
31
+ * @default 'index.html'
32
+ */
33
+ file: string;
34
+ /**
35
+ * A list of regular expressions to match request paths that should be ignored by the
36
+ * middleware.
37
+ *
38
+ * @default [/\.ico$/i]
39
+ */
40
+ ignoredRoutes: RegExp[];
41
+ /**
42
+ * If `true`, {@link FastHTML} will get the list of all the routes controlled by the
43
+ * application, and will use them to validate the incoming requests (in addition to the
44
+ * `ignore` list): If a request URL doesn't match with any of the "controlled routes",
45
+ * it will serve the HTML file.
46
+ *
47
+ * @default true
48
+ */
49
+ useAppRoutes: boolean;
50
+ };
51
+ /**
52
+ * The options to construct a {@link FastHTML}.
53
+ *
54
+ * @group Middlewares/FastHTML
55
+ */
56
+ type FastHTMLConstructorOptions = Partial<FastHTMLOptions> & {
57
+ /**
58
+ * A dictionary with the dependencies to inject.
59
+ */
60
+ inject: {
61
+ sendFile: SendFile;
62
+ events: Events;
63
+ /**
64
+ * A function to get a possible {@link HTMLGenerator}. This is injected as a "getter"
65
+ * to not interrupt the DIC "lifecycle": middlewares are initialized right when the
66
+ * app starts, and injecting a reference would force the service to be initialized
67
+ * too, even if a request is not being made.
68
+ */
69
+ getHTMLGenerator?: () => HTMLGenerator | undefined;
70
+ };
71
+ };
72
+ /**
73
+ * The options for the middleware creator that will mount an instance of {@link FastHTML}.
74
+ *
75
+ * @group Middlewares/FastHTML
76
+ */
77
+ type FastHTMLMiddlewareOptions = Partial<FastHTMLOptions> & {
78
+ /**
79
+ * The name of an {@link HTMLGenerator} service already available in the application.
80
+ *
81
+ * @default 'htmlGenerator'
82
+ */
83
+ htmlGeneratorServiceName?: string;
84
+ };
85
+ /**
86
+ * It's common for an app to show an HTML view when no route was able to handle a request,
87
+ * so the idea behind this middleware is to avoid going to every middleware and controller
88
+ * and just specify that if the request is not for a route handled by a controller, just
89
+ * serve the HTML and avoid processing unnecessary data.
90
+ *
91
+ * A simple example: The app has a route `/backend` that a frontend uses to get
92
+ * information.
93
+ * This middleware can be used to only allow the execution of middlewares and controllers
94
+ * when the request route is for `/backend`.
95
+ *
96
+ * **Disclaimer**: Managing statics files with Express is not a best practice, but there
97
+ * are scenarios where there is not other choice.
98
+ *
99
+ * @group Middleware Classes
100
+ * @group Middlewares/FastHTML
101
+ * @prettierignore
102
+ */
103
+ declare class FastHTML {
104
+ /**
105
+ * The service that serves a file.
106
+ */
107
+ protected readonly _sendFile: SendFile;
108
+ /**
109
+ * The application envent bus, to listen and get the list of "controlled routes" after
110
+ * the application is started.
111
+ */
112
+ protected readonly _events: Events;
113
+ /**
114
+ * A function to get a possible {@link HTMLGenerator}. This is injected as a "getter"
115
+ * to not interrupt the DIC "lifecycle": middlewares are initialized right when the
116
+ * app starts, and injecting a reference would force the service to be initialized
117
+ * too, even if a request is not being made.
118
+ */
119
+ protected readonly _getHTMLGenerator: () => HTMLGenerator | undefined;
120
+ /**
121
+ * The customization options for the middleware.
122
+ */
123
+ protected _options: FastHTMLOptions;
124
+ /**
125
+ * Whether or not the file is ready to be served. In case the middleware uses an
126
+ * {@link HTMLGenerator} service, the file needs to be generated before being available,
127
+ * and that's why this flag exists.
128
+ */
129
+ protected _fileReady: boolean;
130
+ /**
131
+ * A list of regular expression that match the routes controlled by the application.
132
+ * This is in case the `useAppRoutes` option is set to `true`; when the application gets
133
+ * started, an event listener will obtain all the top controlled routes, create regular
134
+ * expressions, and save them on this property.
135
+ */
136
+ protected _routeExpressions: RegExp[];
137
+ /**
138
+ * @param options The options to construct the class.
139
+ * @throws If `ignoredRoutes` is empty and `useAppRoutes` is set to `false`.
140
+ */
141
+ constructor({ inject, ...options }: FastHTMLConstructorOptions);
142
+ /**
143
+ * Generates the middleware that serves the HTML file.
144
+ */
145
+ getMiddleware(): AsyncExpressMiddleware;
146
+ /**
147
+ * The customization options.
148
+ */
149
+ get options(): Readonly<FastHTMLOptions>;
150
+ /**
151
+ * Serves the HTML file to the response.
152
+ *
153
+ * @param res The response object generated by the application.
154
+ * @param next The function to call the next middleware.
155
+ */
156
+ protected _sendResponse(res: Response, next: NextFunction): void;
157
+ /**
158
+ * Adds the event listener that obtains the list of "controlled routes" when
159
+ * `useAppRoutes` is set to `true`.
160
+ */
161
+ protected _setupEvents(): void;
162
+ /**
163
+ * Validates whether a route should be ignored or not. The method checks first against
164
+ * the `ignore` option, and then against the list of "controlled routes" if
165
+ * `useAppRoutes` is set to `true`.
166
+ *
167
+ * @param route The route to validate.
168
+ */
169
+ protected _shouldIgnoreRoute(route: string): boolean;
170
+ }
171
+ /**
172
+ * Creates the middleware that filters the routes and serves an HTML before the
173
+ * application gets to evaluate whether there's a controller for the request or not.
174
+ *
175
+ * @group Middlewares
176
+ * @group Middlewares/FastHTML
177
+ */
178
+ declare const fastHTMLMiddleware: _homer0_jimple.ResourceCreator<"middleware", "connect", (options?: FastHTMLMiddlewareOptions) => <ContainerType extends Jimpex = Jimpex>(app: ContainerType) => AsyncExpressMiddleware, MiddlewareConnectFn>;
179
+
180
+ export { FastHTML, FastHTMLConstructorOptions, FastHTMLMiddlewareOptions, FastHTMLOptions, fastHTMLMiddleware };
@@ -1,19 +1,19 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { l as Events, J as Jimpex, R as MiddlewareConnectFn } from '../../jimpex-7eaee271.js';
2
+ import { l as Events, J as Jimpex, R as MiddlewareConnectFn } from '../../index-b2a04c78.js';
3
3
  import { AsyncExpressMiddleware } from '../../types/express.js';
4
4
  import { SendFile } from '../../services/common/sendFile.js';
5
5
  import { HTMLGenerator } from '../../services/html/htmlGenerator.js';
6
6
  import { Response, NextFunction } from 'express';
7
- import '@homer0/events-hub';
8
7
  import '../../types/http.js';
9
8
  import 'https';
10
9
  import 'http';
11
10
  import 'spdy';
12
11
  import 'node-fetch';
13
- import '@homer0/simple-config';
14
12
  import '../../types/utils.js';
15
- import '@homer0/simple-logger';
16
13
  import '@homer0/path-utils';
14
+ import '@homer0/simple-logger';
15
+ import '@homer0/simple-config';
16
+ import '@homer0/events-hub';
17
17
  import '../../services/frontend/frontendFs.js';
18
18
  import 'fs/promises';
19
19
  import '@homer0/deferred';
@@ -29,12 +29,43 @@ __export(fastHTML_exports, {
29
29
  module.exports = __toCommonJS(fastHTML_exports);
30
30
  var import_utils = require("../../utils");
31
31
  class FastHTML {
32
+ /**
33
+ * @param options The options to construct the class.
34
+ * @throws If `ignoredRoutes` is empty and `useAppRoutes` is set to `false`.
35
+ */
32
36
  constructor({ inject, ...options }) {
37
+ /**
38
+ * The service that serves a file.
39
+ */
33
40
  __publicField(this, "_sendFile");
41
+ /**
42
+ * The application envent bus, to listen and get the list of "controlled routes" after
43
+ * the application is started.
44
+ */
34
45
  __publicField(this, "_events");
46
+ /**
47
+ * A function to get a possible {@link HTMLGenerator}. This is injected as a "getter"
48
+ * to not interrupt the DIC "lifecycle": middlewares are initialized right when the
49
+ * app starts, and injecting a reference would force the service to be initialized
50
+ * too, even if a request is not being made.
51
+ */
35
52
  __publicField(this, "_getHTMLGenerator");
53
+ /**
54
+ * The customization options for the middleware.
55
+ */
36
56
  __publicField(this, "_options");
57
+ /**
58
+ * Whether or not the file is ready to be served. In case the middleware uses an
59
+ * {@link HTMLGenerator} service, the file needs to be generated before being available,
60
+ * and that's why this flag exists.
61
+ */
37
62
  __publicField(this, "_fileReady", false);
63
+ /**
64
+ * A list of regular expression that match the routes controlled by the application.
65
+ * This is in case the `useAppRoutes` option is set to `true`; when the application gets
66
+ * started, an event listener will obtain all the top controlled routes, create regular
67
+ * expressions, and save them on this property.
68
+ */
38
69
  __publicField(this, "_routeExpressions", []);
39
70
  this._sendFile = inject.sendFile;
40
71
  this._events = inject.events;
@@ -52,6 +83,9 @@ class FastHTML {
52
83
  this._setupEvents();
53
84
  }
54
85
  }
86
+ /**
87
+ * Generates the middleware that serves the HTML file.
88
+ */
55
89
  getMiddleware() {
56
90
  return async (req, res, next) => {
57
91
  if (this._shouldIgnoreRoute(req.originalUrl)) {
@@ -78,9 +112,18 @@ class FastHTML {
78
112
  }
79
113
  };
80
114
  }
115
+ /**
116
+ * The customization options.
117
+ */
81
118
  get options() {
82
119
  return { ...this._options };
83
120
  }
121
+ /**
122
+ * Serves the HTML file to the response.
123
+ *
124
+ * @param res The response object generated by the application.
125
+ * @param next The function to call the next middleware.
126
+ */
84
127
  _sendResponse(res, next) {
85
128
  res.setHeader("Content-Type", "text/html");
86
129
  this._sendFile({
@@ -89,6 +132,10 @@ class FastHTML {
89
132
  filepath: this._options.file
90
133
  });
91
134
  }
135
+ /**
136
+ * Adds the event listener that obtains the list of "controlled routes" when
137
+ * `useAppRoutes` is set to `true`.
138
+ */
92
139
  _setupEvents() {
93
140
  this._events.once("afterStart", ({ app }) => {
94
141
  const [routeExpressions] = app.routes.reduce(
@@ -106,6 +153,13 @@ class FastHTML {
106
153
  this._routeExpressions.push(...routeExpressions);
107
154
  });
108
155
  }
156
+ /**
157
+ * Validates whether a route should be ignored or not. The method checks first against
158
+ * the `ignore` option, and then against the list of "controlled routes" if
159
+ * `useAppRoutes` is set to `true`.
160
+ *
161
+ * @param route The route to validate.
162
+ */
109
163
  _shouldIgnoreRoute(route) {
110
164
  return this._options.ignoredRoutes.some((expression) => route.match(expression)) || this._routeExpressions.some((expression) => route.match(expression));
111
165
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/middlewares/html/fastHTML.ts"],"sourcesContent":["import { createRouteExpression, middlewareCreator, removeSlashes } from '../../utils';\nimport type { HTMLGenerator, SendFile } from '../../services';\nimport type { AsyncExpressMiddleware, Response, NextFunction, Events } from '../../types';\n/**\n * The options to customize the behavior of the middleware.\n *\n * @group Middlewares/FastHTML\n */\nexport type FastHTMLOptions = {\n /**\n * The name of the file the middleware will serve. If the {@link HTMLGenerator} service\n * is available, it will be overriden by the service.\n *\n * @default 'index.html'\n */\n file: string;\n /**\n * A list of regular expressions to match request paths that should be ignored by the\n * middleware.\n *\n * @default [/\\.ico$/i]\n */\n ignoredRoutes: RegExp[];\n /**\n * If `true`, {@link FastHTML} will get the list of all the routes controlled by the\n * application, and will use them to validate the incoming requests (in addition to the\n * `ignore` list): If a request URL doesn't match with any of the \"controlled routes\",\n * it will serve the HTML file.\n *\n * @default true\n */\n useAppRoutes: boolean;\n};\n/**\n * The options to construct a {@link FastHTML}.\n *\n * @group Middlewares/FastHTML\n */\nexport type FastHTMLConstructorOptions = Partial<FastHTMLOptions> & {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n sendFile: SendFile;\n events: Events;\n /**\n * A function to get a possible {@link HTMLGenerator}. This is injected as a \"getter\"\n * to not interrupt the DIC \"lifecycle\": middlewares are initialized right when the\n * app starts, and injecting a reference would force the service to be initialized\n * too, even if a request is not being made.\n */\n getHTMLGenerator?: () => HTMLGenerator | undefined;\n };\n};\n/**\n * The options for the middleware creator that will mount an instance of {@link FastHTML}.\n *\n * @group Middlewares/FastHTML\n */\nexport type FastHTMLMiddlewareOptions = Partial<FastHTMLOptions> & {\n /**\n * The name of an {@link HTMLGenerator} service already available in the application.\n *\n * @default 'htmlGenerator'\n */\n htmlGeneratorServiceName?: string;\n};\n/**\n * It's common for an app to show an HTML view when no route was able to handle a request,\n * so the idea behind this middleware is to avoid going to every middleware and controller\n * and just specify that if the request is not for a route handled by a controller, just\n * serve the HTML and avoid processing unnecessary data.\n *\n * A simple example: The app has a route `/backend` that a frontend uses to get\n * information.\n * This middleware can be used to only allow the execution of middlewares and controllers\n * when the request route is for `/backend`.\n *\n * **Disclaimer**: Managing statics files with Express is not a best practice, but there\n * are scenarios where there is not other choice.\n *\n * @group Middleware Classes\n * @group Middlewares/FastHTML\n * @prettierignore\n */\nexport class FastHTML {\n /**\n * The service that serves a file.\n */\n protected readonly _sendFile: SendFile;\n /**\n * The application envent bus, to listen and get the list of \"controlled routes\" after\n * the application is started.\n */\n protected readonly _events: Events;\n /**\n * A function to get a possible {@link HTMLGenerator}. This is injected as a \"getter\"\n * to not interrupt the DIC \"lifecycle\": middlewares are initialized right when the\n * app starts, and injecting a reference would force the service to be initialized\n * too, even if a request is not being made.\n */\n protected readonly _getHTMLGenerator: () => HTMLGenerator | undefined;\n /**\n * The customization options for the middleware.\n */\n protected _options: FastHTMLOptions;\n /**\n * Whether or not the file is ready to be served. In case the middleware uses an\n * {@link HTMLGenerator} service, the file needs to be generated before being available,\n * and that's why this flag exists.\n */\n protected _fileReady: boolean = false;\n /**\n * A list of regular expression that match the routes controlled by the application.\n * This is in case the `useAppRoutes` option is set to `true`; when the application gets\n * started, an event listener will obtain all the top controlled routes, create regular\n * expressions, and save them on this property.\n */\n protected _routeExpressions: RegExp[] = [];\n /**\n * @param options The options to construct the class.\n * @throws If `ignoredRoutes` is empty and `useAppRoutes` is set to `false`.\n */\n constructor({ inject, ...options }: FastHTMLConstructorOptions) {\n this._sendFile = inject.sendFile;\n this._events = inject.events;\n this._getHTMLGenerator = inject.getHTMLGenerator || (() => undefined);\n this._options = {\n file: 'index.html',\n ignoredRoutes: [/\\.ico$/i],\n useAppRoutes: true,\n ...options,\n };\n\n if (!this._options.ignoredRoutes.length && !this._options.useAppRoutes) {\n throw new Error('You must provide either `ignoredRoutes` or `useAppRoutes`');\n }\n\n if (this._options.useAppRoutes) {\n this._setupEvents();\n }\n }\n /**\n * Generates the middleware that serves the HTML file.\n */\n getMiddleware(): AsyncExpressMiddleware {\n return async (req, res, next) => {\n // If the route should be ignored, move to the next middleware.\n if (this._shouldIgnoreRoute(req.originalUrl)) {\n next();\n return;\n }\n\n // If the file is ready to be served, serve it.\n if (this._fileReady) {\n this._sendResponse(res, next);\n return;\n }\n\n const htmlGenerator = this._getHTMLGenerator();\n // If there's no generator, switch the flag and just serve the file.\n if (!htmlGenerator) {\n this._fileReady = true;\n this._sendResponse(res, next);\n return;\n }\n\n try {\n // Wait for the HTML to be generated.\n await htmlGenerator.whenReady();\n // Update the local option.\n this._options.file = htmlGenerator.options.file;\n // Switch the flag and serve the file.\n this._fileReady = true;\n this._sendResponse(res, next);\n } catch (error) {\n next(error);\n }\n };\n }\n /**\n * The customization options.\n */\n get options(): Readonly<FastHTMLOptions> {\n return { ...this._options };\n }\n /**\n * Serves the HTML file to the response.\n *\n * @param res The response object generated by the application.\n * @param next The function to call the next middleware.\n */\n protected _sendResponse(res: Response, next: NextFunction): void {\n res.setHeader('Content-Type', 'text/html');\n this._sendFile({\n res,\n next,\n filepath: this._options.file,\n });\n }\n /**\n * Adds the event listener that obtains the list of \"controlled routes\" when\n * `useAppRoutes` is set to `true`.\n */\n protected _setupEvents() {\n this._events.once('afterStart', ({ app }) => {\n const [routeExpressions] = app.routes.reduce<[RegExp[], string[]]>(\n (acc, route) => {\n const [expressions, processed] = acc;\n const clean = removeSlashes(route).trim();\n if (!clean || processed.includes(clean)) return acc;\n expressions.push(createRouteExpression(clean));\n processed.push(clean);\n return acc;\n },\n [[], []],\n );\n this._routeExpressions.push(...routeExpressions);\n });\n }\n /**\n * Validates whether a route should be ignored or not. The method checks first against\n * the `ignore` option, and then against the list of \"controlled routes\" if\n * `useAppRoutes` is set to `true`.\n *\n * @param route The route to validate.\n */\n protected _shouldIgnoreRoute(route: string): boolean {\n return (\n this._options.ignoredRoutes.some((expression) => route.match(expression)) ||\n this._routeExpressions.some((expression) => route.match(expression))\n );\n }\n}\n/**\n * Creates the middleware that filters the routes and serves an HTML before the\n * application gets to evaluate whether there's a controller for the request or not.\n *\n * @group Middlewares\n * @group Middlewares/FastHTML\n */\nexport const fastHTMLMiddleware = middlewareCreator(\n (options: FastHTMLMiddlewareOptions = {}) =>\n (app) => {\n const { htmlGeneratorServiceName = 'htmlGenerator', ...rest } = options;\n return new FastHTML({\n inject: {\n events: app.get('events'),\n sendFile: app.get('sendFile'),\n getHTMLGenerator: () => app.try(htmlGeneratorServiceName),\n },\n ...rest,\n }).getMiddleware();\n },\n);\n"],"mappings":"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","names":[]}
1
+ {"version":3,"sources":["../../../src/middlewares/html/fastHTML.ts"],"sourcesContent":["import { createRouteExpression, middlewareCreator, removeSlashes } from '../../utils';\nimport type { HTMLGenerator, SendFile } from '../../services';\nimport type { AsyncExpressMiddleware, Response, NextFunction, Events } from '../../types';\n/**\n * The options to customize the behavior of the middleware.\n *\n * @group Middlewares/FastHTML\n */\nexport type FastHTMLOptions = {\n /**\n * The name of the file the middleware will serve. If the {@link HTMLGenerator} service\n * is available, it will be overriden by the service.\n *\n * @default 'index.html'\n */\n file: string;\n /**\n * A list of regular expressions to match request paths that should be ignored by the\n * middleware.\n *\n * @default [/\\.ico$/i]\n */\n ignoredRoutes: RegExp[];\n /**\n * If `true`, {@link FastHTML} will get the list of all the routes controlled by the\n * application, and will use them to validate the incoming requests (in addition to the\n * `ignore` list): If a request URL doesn't match with any of the \"controlled routes\",\n * it will serve the HTML file.\n *\n * @default true\n */\n useAppRoutes: boolean;\n};\n/**\n * The options to construct a {@link FastHTML}.\n *\n * @group Middlewares/FastHTML\n */\nexport type FastHTMLConstructorOptions = Partial<FastHTMLOptions> & {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n sendFile: SendFile;\n events: Events;\n /**\n * A function to get a possible {@link HTMLGenerator}. This is injected as a \"getter\"\n * to not interrupt the DIC \"lifecycle\": middlewares are initialized right when the\n * app starts, and injecting a reference would force the service to be initialized\n * too, even if a request is not being made.\n */\n getHTMLGenerator?: () => HTMLGenerator | undefined;\n };\n};\n/**\n * The options for the middleware creator that will mount an instance of {@link FastHTML}.\n *\n * @group Middlewares/FastHTML\n */\nexport type FastHTMLMiddlewareOptions = Partial<FastHTMLOptions> & {\n /**\n * The name of an {@link HTMLGenerator} service already available in the application.\n *\n * @default 'htmlGenerator'\n */\n htmlGeneratorServiceName?: string;\n};\n/**\n * It's common for an app to show an HTML view when no route was able to handle a request,\n * so the idea behind this middleware is to avoid going to every middleware and controller\n * and just specify that if the request is not for a route handled by a controller, just\n * serve the HTML and avoid processing unnecessary data.\n *\n * A simple example: The app has a route `/backend` that a frontend uses to get\n * information.\n * This middleware can be used to only allow the execution of middlewares and controllers\n * when the request route is for `/backend`.\n *\n * **Disclaimer**: Managing statics files with Express is not a best practice, but there\n * are scenarios where there is not other choice.\n *\n * @group Middleware Classes\n * @group Middlewares/FastHTML\n * @prettierignore\n */\nexport class FastHTML {\n /**\n * The service that serves a file.\n */\n protected readonly _sendFile: SendFile;\n /**\n * The application envent bus, to listen and get the list of \"controlled routes\" after\n * the application is started.\n */\n protected readonly _events: Events;\n /**\n * A function to get a possible {@link HTMLGenerator}. This is injected as a \"getter\"\n * to not interrupt the DIC \"lifecycle\": middlewares are initialized right when the\n * app starts, and injecting a reference would force the service to be initialized\n * too, even if a request is not being made.\n */\n protected readonly _getHTMLGenerator: () => HTMLGenerator | undefined;\n /**\n * The customization options for the middleware.\n */\n protected _options: FastHTMLOptions;\n /**\n * Whether or not the file is ready to be served. In case the middleware uses an\n * {@link HTMLGenerator} service, the file needs to be generated before being available,\n * and that's why this flag exists.\n */\n protected _fileReady: boolean = false;\n /**\n * A list of regular expression that match the routes controlled by the application.\n * This is in case the `useAppRoutes` option is set to `true`; when the application gets\n * started, an event listener will obtain all the top controlled routes, create regular\n * expressions, and save them on this property.\n */\n protected _routeExpressions: RegExp[] = [];\n /**\n * @param options The options to construct the class.\n * @throws If `ignoredRoutes` is empty and `useAppRoutes` is set to `false`.\n */\n constructor({ inject, ...options }: FastHTMLConstructorOptions) {\n this._sendFile = inject.sendFile;\n this._events = inject.events;\n this._getHTMLGenerator = inject.getHTMLGenerator || (() => undefined);\n this._options = {\n file: 'index.html',\n ignoredRoutes: [/\\.ico$/i],\n useAppRoutes: true,\n ...options,\n };\n\n if (!this._options.ignoredRoutes.length && !this._options.useAppRoutes) {\n throw new Error('You must provide either `ignoredRoutes` or `useAppRoutes`');\n }\n\n if (this._options.useAppRoutes) {\n this._setupEvents();\n }\n }\n /**\n * Generates the middleware that serves the HTML file.\n */\n getMiddleware(): AsyncExpressMiddleware {\n return async (req, res, next) => {\n // If the route should be ignored, move to the next middleware.\n if (this._shouldIgnoreRoute(req.originalUrl)) {\n next();\n return;\n }\n\n // If the file is ready to be served, serve it.\n if (this._fileReady) {\n this._sendResponse(res, next);\n return;\n }\n\n const htmlGenerator = this._getHTMLGenerator();\n // If there's no generator, switch the flag and just serve the file.\n if (!htmlGenerator) {\n this._fileReady = true;\n this._sendResponse(res, next);\n return;\n }\n\n try {\n // Wait for the HTML to be generated.\n await htmlGenerator.whenReady();\n // Update the local option.\n this._options.file = htmlGenerator.options.file;\n // Switch the flag and serve the file.\n this._fileReady = true;\n this._sendResponse(res, next);\n } catch (error) {\n next(error);\n }\n };\n }\n /**\n * The customization options.\n */\n get options(): Readonly<FastHTMLOptions> {\n return { ...this._options };\n }\n /**\n * Serves the HTML file to the response.\n *\n * @param res The response object generated by the application.\n * @param next The function to call the next middleware.\n */\n protected _sendResponse(res: Response, next: NextFunction): void {\n res.setHeader('Content-Type', 'text/html');\n this._sendFile({\n res,\n next,\n filepath: this._options.file,\n });\n }\n /**\n * Adds the event listener that obtains the list of \"controlled routes\" when\n * `useAppRoutes` is set to `true`.\n */\n protected _setupEvents() {\n this._events.once('afterStart', ({ app }) => {\n const [routeExpressions] = app.routes.reduce<[RegExp[], string[]]>(\n (acc, route) => {\n const [expressions, processed] = acc;\n const clean = removeSlashes(route).trim();\n if (!clean || processed.includes(clean)) return acc;\n expressions.push(createRouteExpression(clean));\n processed.push(clean);\n return acc;\n },\n [[], []],\n );\n this._routeExpressions.push(...routeExpressions);\n });\n }\n /**\n * Validates whether a route should be ignored or not. The method checks first against\n * the `ignore` option, and then against the list of \"controlled routes\" if\n * `useAppRoutes` is set to `true`.\n *\n * @param route The route to validate.\n */\n protected _shouldIgnoreRoute(route: string): boolean {\n return (\n this._options.ignoredRoutes.some((expression) => route.match(expression)) ||\n this._routeExpressions.some((expression) => route.match(expression))\n );\n }\n}\n/**\n * Creates the middleware that filters the routes and serves an HTML before the\n * application gets to evaluate whether there's a controller for the request or not.\n *\n * @group Middlewares\n * @group Middlewares/FastHTML\n */\nexport const fastHTMLMiddleware = middlewareCreator(\n (options: FastHTMLMiddlewareOptions = {}) =>\n (app) => {\n const { htmlGeneratorServiceName = 'htmlGenerator', ...rest } = options;\n return new FastHTML({\n inject: {\n events: app.get('events'),\n sendFile: app.get('sendFile'),\n getHTMLGenerator: () => app.try(htmlGeneratorServiceName),\n },\n ...rest,\n }).getMiddleware();\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwE;AAqFjE,MAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAsCpB,YAAY,EAAE,QAAQ,GAAG,QAAQ,GAA+B;AAlChE;AAAA;AAAA;AAAA,wBAAmB;AAKnB;AAAA;AAAA;AAAA;AAAA,wBAAmB;AAOnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAmB;AAInB;AAAA;AAAA;AAAA,wBAAU;AAMV;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAU,cAAsB;AAOhC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAU,qBAA8B,CAAC;AAMvC,SAAK,YAAY,OAAO;AACxB,SAAK,UAAU,OAAO;AACtB,SAAK,oBAAoB,OAAO,qBAAqB,MAAM;AAC3D,SAAK,WAAW;AAAA,MACd,MAAM;AAAA,MACN,eAAe,CAAC,SAAS;AAAA,MACzB,cAAc;AAAA,MACd,GAAG;AAAA,IACL;AAEA,QAAI,CAAC,KAAK,SAAS,cAAc,UAAU,CAAC,KAAK,SAAS,cAAc;AACtE,YAAM,IAAI,MAAM,2DAA2D;AAAA,IAC7E;AAEA,QAAI,KAAK,SAAS,cAAc;AAC9B,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAIA,gBAAwC;AACtC,WAAO,OAAO,KAAK,KAAK,SAAS;AAE/B,UAAI,KAAK,mBAAmB,IAAI,WAAW,GAAG;AAC5C,aAAK;AACL;AAAA,MACF;AAGA,UAAI,KAAK,YAAY;AACnB,aAAK,cAAc,KAAK,IAAI;AAC5B;AAAA,MACF;AAEA,YAAM,gBAAgB,KAAK,kBAAkB;AAE7C,UAAI,CAAC,eAAe;AAClB,aAAK,aAAa;AAClB,aAAK,cAAc,KAAK,IAAI;AAC5B;AAAA,MACF;AAEA,UAAI;AAEF,cAAM,cAAc,UAAU;AAE9B,aAAK,SAAS,OAAO,cAAc,QAAQ;AAE3C,aAAK,aAAa;AAClB,aAAK,cAAc,KAAK,IAAI;AAAA,MAC9B,SAAS,OAAO;AACd,aAAK,KAAK;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,UAAqC;AACvC,WAAO,EAAE,GAAG,KAAK,SAAS;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOU,cAAc,KAAe,MAA0B;AAC/D,QAAI,UAAU,gBAAgB,WAAW;AACzC,SAAK,UAAU;AAAA,MACb;AAAA,MACA;AAAA,MACA,UAAU,KAAK,SAAS;AAAA,IAC1B,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA,EAKU,eAAe;AACvB,SAAK,QAAQ,KAAK,cAAc,CAAC,EAAE,IAAI,MAAM;AAC3C,YAAM,CAAC,gBAAgB,IAAI,IAAI,OAAO;AAAA,QACpC,CAAC,KAAK,UAAU;AACd,gBAAM,CAAC,aAAa,SAAS,IAAI;AACjC,gBAAM,YAAQ,4BAAc,KAAK,EAAE,KAAK;AACxC,cAAI,CAAC,SAAS,UAAU,SAAS,KAAK;AAAG,mBAAO;AAChD,sBAAY,SAAK,oCAAsB,KAAK,CAAC;AAC7C,oBAAU,KAAK,KAAK;AACpB,iBAAO;AAAA,QACT;AAAA,QACA,CAAC,CAAC,GAAG,CAAC,CAAC;AAAA,MACT;AACA,WAAK,kBAAkB,KAAK,GAAG,gBAAgB;AAAA,IACjD,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQU,mBAAmB,OAAwB;AACnD,WACE,KAAK,SAAS,cAAc,KAAK,CAAC,eAAe,MAAM,MAAM,UAAU,CAAC,KACxE,KAAK,kBAAkB,KAAK,CAAC,eAAe,MAAM,MAAM,UAAU,CAAC;AAAA,EAEvE;AACF;AAQO,MAAM,yBAAqB;AAAA,EAChC,CAAC,UAAqC,CAAC,MACrC,CAAC,QAAQ;AACP,UAAM,EAAE,2BAA2B,iBAAiB,GAAG,KAAK,IAAI;AAChE,WAAO,IAAI,SAAS;AAAA,MAClB,QAAQ;AAAA,QACN,QAAQ,IAAI,IAAI,QAAQ;AAAA,QACxB,UAAU,IAAI,IAAI,UAAU;AAAA,QAC5B,kBAAkB,MAAM,IAAI,IAAI,wBAAwB;AAAA,MAC1D;AAAA,MACA,GAAG;AAAA,IACL,CAAC,EAAE,cAAc;AAAA,EACnB;AACJ;","names":[]}
@@ -0,0 +1,21 @@
1
+ export { FastHTML, FastHTMLConstructorOptions, FastHTMLMiddlewareOptions, FastHTMLOptions, fastHTMLMiddleware } from './fastHTML.mjs';
2
+ export { ShowHTML, ShowHTMLConstructorOptions, ShowHTMLMiddlewareOptions, ShowHTMLOptions, showHTMLMiddleware } from './showHTML.mjs';
3
+ import '@homer0/jimple';
4
+ import '../../index-efeb437e.js';
5
+ import '../../types/express.mjs';
6
+ import 'express';
7
+ import '../../types/http.mjs';
8
+ import 'https';
9
+ import 'http';
10
+ import 'spdy';
11
+ import 'node-fetch';
12
+ import '../../types/utils.mjs';
13
+ import '@homer0/path-utils';
14
+ import '@homer0/simple-logger';
15
+ import '@homer0/simple-config';
16
+ import '@homer0/events-hub';
17
+ import '../../services/common/sendFile.mjs';
18
+ import '../../services/html/htmlGenerator.mjs';
19
+ import '../../services/frontend/frontendFs.mjs';
20
+ import 'fs/promises';
21
+ import '@homer0/deferred';
@@ -1,8 +1,7 @@
1
1
  export { FastHTML, FastHTMLConstructorOptions, FastHTMLMiddlewareOptions, FastHTMLOptions, fastHTMLMiddleware } from './fastHTML.js';
2
2
  export { ShowHTML, ShowHTMLConstructorOptions, ShowHTMLMiddlewareOptions, ShowHTMLOptions, showHTMLMiddleware } from './showHTML.js';
3
3
  import '@homer0/jimple';
4
- import '../../jimpex-7eaee271.js';
5
- import '@homer0/events-hub';
4
+ import '../../index-b2a04c78.js';
6
5
  import '../../types/express.js';
7
6
  import 'express';
8
7
  import '../../types/http.js';
@@ -10,11 +9,12 @@ import 'https';
10
9
  import 'http';
11
10
  import 'spdy';
12
11
  import 'node-fetch';
13
- import '@homer0/simple-config';
14
12
  import '../../types/utils.js';
13
+ import '@homer0/path-utils';
15
14
  import '@homer0/simple-logger';
15
+ import '@homer0/simple-config';
16
+ import '@homer0/events-hub';
16
17
  import '../../services/common/sendFile.js';
17
- import '@homer0/path-utils';
18
18
  import '../../services/html/htmlGenerator.js';
19
19
  import '../../services/frontend/frontendFs.js';
20
20
  import 'fs/promises';
@@ -17,4 +17,9 @@ var html_exports = {};
17
17
  module.exports = __toCommonJS(html_exports);
18
18
  __reExport(html_exports, require("./fastHTML"), module.exports);
19
19
  __reExport(html_exports, require("./showHTML"), module.exports);
20
+ // Annotate the CommonJS export names for ESM import in node:
21
+ 0 && (module.exports = {
22
+ ...require("./fastHTML"),
23
+ ...require("./showHTML")
24
+ });
20
25
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,127 @@
1
+ import * as _homer0_jimple from '@homer0/jimple';
2
+ import { J as Jimpex, R as MiddlewareConnectFn } from '../../index-efeb437e.js';
3
+ import { AsyncExpressMiddleware } from '../../types/express.mjs';
4
+ import { SendFile } from '../../services/common/sendFile.mjs';
5
+ import { HTMLGenerator } from '../../services/html/htmlGenerator.mjs';
6
+ import { Response, NextFunction } from 'express';
7
+ import '../../types/http.mjs';
8
+ import 'https';
9
+ import 'http';
10
+ import 'spdy';
11
+ import 'node-fetch';
12
+ import '../../types/utils.mjs';
13
+ import '@homer0/path-utils';
14
+ import '@homer0/simple-logger';
15
+ import '@homer0/simple-config';
16
+ import '@homer0/events-hub';
17
+ import '../../services/frontend/frontendFs.mjs';
18
+ import 'fs/promises';
19
+ import '@homer0/deferred';
20
+
21
+ /**
22
+ * The options to customize the behavior of the middleware.
23
+ *
24
+ * @group Middlewares/ShowHTML
25
+ */
26
+ type ShowHTMLOptions = {
27
+ /**
28
+ * The name of the file the middleware will serve. If the {@link HTMLGenerator} service
29
+ * is available, it will be overriden by the service.
30
+ *
31
+ * @default 'index.html'
32
+ */
33
+ file: string;
34
+ };
35
+ /**
36
+ * The options to construct a {@link ShowHTML}.
37
+ *
38
+ * @group Middlewares/ShowHTML
39
+ */
40
+ type ShowHTMLConstructorOptions = Partial<ShowHTMLOptions> & {
41
+ /**
42
+ * A dictionary with the dependencies to inject.
43
+ */
44
+ inject: {
45
+ sendFile: SendFile;
46
+ /**
47
+ * A function to get a possible {@link HTMLGenerator}. This is injected as a "getter"
48
+ * to not interrupt the DIC "lifecycle": middlewares are initialized right when the
49
+ * app starts, and injecting a reference would force the service to be initialized
50
+ * too, even if a request is not being made.
51
+ */
52
+ getHTMLGenerator?: () => HTMLGenerator | undefined;
53
+ };
54
+ };
55
+ /**
56
+ * The options for the middleware creator that will mount an instance of {@link ShowHTML}.
57
+ *
58
+ * @group Middlewares/ShowHTML
59
+ */
60
+ type ShowHTMLMiddlewareOptions = Partial<ShowHTMLOptions> & {
61
+ /**
62
+ * The name of an {@link HTMLGenerator} service already available in the application.
63
+ *
64
+ * @default 'htmlGenerator'
65
+ */
66
+ htmlGeneratorServiceName?: string;
67
+ };
68
+ /**
69
+ * A very simple middleware service to send an HTML on a server response. The special
70
+ * _'feature'_ of this service is that it can be hooked up to an {@link HTMLGenerator}
71
+ * service and it will automatically server the file generated by it.
72
+ *
73
+ * @group Middleware Classes
74
+ * @group Middlewares/ShowHTML
75
+ * @prettierignore
76
+ */
77
+ declare class ShowHTML {
78
+ /**
79
+ * The service that serves a file.
80
+ */
81
+ protected readonly _sendFile: SendFile;
82
+ /**
83
+ * A function to get a possible {@link HTMLGenerator}. This is injected as a "getter"
84
+ * to not interrupt the DIC "lifecycle": middlewares are initialized right when the
85
+ * app starts, and injecting a reference would force the service to be initialized
86
+ * too, even if a request is not being made.
87
+ */
88
+ protected readonly _getHTMLGenerator: () => HTMLGenerator | undefined;
89
+ /**
90
+ * The customization options for the middleware.
91
+ */
92
+ protected _options: ShowHTMLOptions;
93
+ /**
94
+ * Whether or not the file is ready to be served. In case the middleware uses an
95
+ * {@link HTMLGenerator} service, the file needs to be generated before being available,
96
+ * and that's why this flag exists.
97
+ */
98
+ protected _fileReady: boolean;
99
+ /**
100
+ * @param options The options to construct the class.
101
+ */
102
+ constructor({ inject, ...options }: ShowHTMLConstructorOptions);
103
+ /**
104
+ * Generates the middleware that serves the HTML file.
105
+ */
106
+ getMiddleware(): AsyncExpressMiddleware;
107
+ /**
108
+ * The customization options.
109
+ */
110
+ get options(): Readonly<ShowHTMLOptions>;
111
+ /**
112
+ * Serves the HTML file to the response.
113
+ *
114
+ * @param res The response object generated by the application.
115
+ * @param next The function to call the next middleware.
116
+ */
117
+ protected _sendResponse(res: Response, next: NextFunction): void;
118
+ }
119
+ /**
120
+ * Creates the middleware that serves an HTML file in the response.
121
+ *
122
+ * @group Middlewares
123
+ * @group Middlewares/ShowHTML
124
+ */
125
+ declare const showHTMLMiddleware: _homer0_jimple.ResourceCreator<"middleware", "connect", (options?: ShowHTMLMiddlewareOptions) => <ContainerType extends Jimpex = Jimpex>(app: ContainerType) => AsyncExpressMiddleware, MiddlewareConnectFn>;
126
+
127
+ export { ShowHTML, ShowHTMLConstructorOptions, ShowHTMLMiddlewareOptions, ShowHTMLOptions, showHTMLMiddleware };
@@ -1,19 +1,19 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex, R as MiddlewareConnectFn } from '../../jimpex-7eaee271.js';
2
+ import { J as Jimpex, R as MiddlewareConnectFn } from '../../index-b2a04c78.js';
3
3
  import { AsyncExpressMiddleware } from '../../types/express.js';
4
4
  import { SendFile } from '../../services/common/sendFile.js';
5
5
  import { HTMLGenerator } from '../../services/html/htmlGenerator.js';
6
6
  import { Response, NextFunction } from 'express';
7
- import '@homer0/events-hub';
8
7
  import '../../types/http.js';
9
8
  import 'https';
10
9
  import 'http';
11
10
  import 'spdy';
12
11
  import 'node-fetch';
13
- import '@homer0/simple-config';
14
12
  import '../../types/utils.js';
15
- import '@homer0/simple-logger';
16
13
  import '@homer0/path-utils';
14
+ import '@homer0/simple-logger';
15
+ import '@homer0/simple-config';
16
+ import '@homer0/events-hub';
17
17
  import '../../services/frontend/frontendFs.js';
18
18
  import 'fs/promises';
19
19
  import '@homer0/deferred';