@adaas/a-server 0.0.19 → 0.0.21

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 (179) hide show
  1. package/dist/index.d.mts +739 -0
  2. package/dist/index.d.ts +739 -36
  3. package/dist/index.js +1903 -102
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +1863 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +6 -4
  8. package/src/components/A-ServerLogger/A_ServerLogger.component.ts +1 -1
  9. package/src/components/A-ServerProxy/A-ServerProxy.component.ts +8 -7
  10. package/src/components/A-StaticLoader/A-StaticLoader.component.types.ts +5 -107
  11. package/src/containers/A-Service/A-Service.container.ts +11 -7
  12. package/src/entities/A-Request/A-Request.entity.ts +1 -1
  13. package/src/entities/A-Request/A-Request.entity.types.ts +1 -1
  14. package/src/entities/A-Response/A-Response.entity.ts +1 -1
  15. package/src/entities/A-Response/A-Response.entity.types.ts +1 -1
  16. package/src/index.ts +75 -0
  17. package/tsconfig.json +1 -1
  18. package/tsup.config.ts +15 -0
  19. package/dist/src/channels/A-Http/A-Http.channel.constants.d.ts +0 -5
  20. package/dist/src/channels/A-Http/A-Http.channel.constants.js +0 -10
  21. package/dist/src/channels/A-Http/A-Http.channel.constants.js.map +0 -1
  22. package/dist/src/channels/A-Http/A-Http.channel.d.ts +0 -29
  23. package/dist/src/channels/A-Http/A-Http.channel.error.d.ts +0 -4
  24. package/dist/src/channels/A-Http/A-Http.channel.error.js +0 -9
  25. package/dist/src/channels/A-Http/A-Http.channel.error.js.map +0 -1
  26. package/dist/src/channels/A-Http/A-Http.channel.js +0 -154
  27. package/dist/src/channels/A-Http/A-Http.channel.js.map +0 -1
  28. package/dist/src/channels/A-Http/A-Http.channel.types.d.ts +0 -59
  29. package/dist/src/channels/A-Http/A-Http.channel.types.js +0 -3
  30. package/dist/src/channels/A-Http/A-Http.channel.types.js.map +0 -1
  31. package/dist/src/channels/A-Websockets/A-Websockets.channel.d.ts +0 -4
  32. package/dist/src/channels/A-Websockets/A-Websockets.channel.js +0 -22
  33. package/dist/src/channels/A-Websockets/A-Websockets.channel.js.map +0 -1
  34. package/dist/src/components/A-CommandController/A-CommandController.component.d.ts +0 -8
  35. package/dist/src/components/A-CommandController/A-CommandController.component.js +0 -55
  36. package/dist/src/components/A-CommandController/A-CommandController.component.js.map +0 -1
  37. package/dist/src/components/A-Controller/A-Controller.component.d.ts +0 -9
  38. package/dist/src/components/A-Controller/A-Controller.component.js +0 -60
  39. package/dist/src/components/A-Controller/A-Controller.component.js.map +0 -1
  40. package/dist/src/components/A-Controller/A-Controller.component.types.d.ts +0 -0
  41. package/dist/src/components/A-Controller/A-Controller.component.types.js +0 -2
  42. package/dist/src/components/A-Controller/A-Controller.component.types.js.map +0 -1
  43. package/dist/src/components/A-EntityController/A-EntityController.component.d.ts +0 -26
  44. package/dist/src/components/A-EntityController/A-EntityController.component.js +0 -226
  45. package/dist/src/components/A-EntityController/A-EntityController.component.js.map +0 -1
  46. package/dist/src/components/A-EntityController/A-EntityController.component.types.d.ts +0 -0
  47. package/dist/src/components/A-EntityController/A-EntityController.component.types.js +0 -2
  48. package/dist/src/components/A-EntityController/A-EntityController.component.types.js.map +0 -1
  49. package/dist/src/components/A-EntityRepository/A-EntityRepository.component.d.ts +0 -9
  50. package/dist/src/components/A-EntityRepository/A-EntityRepository.component.js +0 -118
  51. package/dist/src/components/A-EntityRepository/A-EntityRepository.component.js.map +0 -1
  52. package/dist/src/components/A-EntityRepository/A-EntityRepository.error.d.ts +0 -0
  53. package/dist/src/components/A-EntityRepository/A-EntityRepository.error.js +0 -2
  54. package/dist/src/components/A-EntityRepository/A-EntityRepository.error.js.map +0 -1
  55. package/dist/src/components/A-EntityRepository/A-EntityRepository.types.d.ts +0 -0
  56. package/dist/src/components/A-EntityRepository/A-EntityRepository.types.js +0 -2
  57. package/dist/src/components/A-EntityRepository/A-EntityRepository.types.js.map +0 -1
  58. package/dist/src/components/A-ListingController/A-ListingController.component.d.ts +0 -10
  59. package/dist/src/components/A-ListingController/A-ListingController.component.js +0 -72
  60. package/dist/src/components/A-ListingController/A-ListingController.component.js.map +0 -1
  61. package/dist/src/components/A-ListingController/A-ListingController.component.types.d.ts +0 -0
  62. package/dist/src/components/A-ListingController/A-ListingController.component.types.js +0 -2
  63. package/dist/src/components/A-ListingController/A-ListingController.component.types.js.map +0 -1
  64. package/dist/src/components/A-Router/A-Router.component.d.ts +0 -63
  65. package/dist/src/components/A-Router/A-Router.component.js +0 -221
  66. package/dist/src/components/A-Router/A-Router.component.js.map +0 -1
  67. package/dist/src/components/A-Router/A-Router.component.types.d.ts +0 -26
  68. package/dist/src/components/A-Router/A-Router.component.types.js +0 -17
  69. package/dist/src/components/A-Router/A-Router.component.types.js.map +0 -1
  70. package/dist/src/components/A-ServerCORS/A_ServerCORS.component.d.ts +0 -9
  71. package/dist/src/components/A-ServerCORS/A_ServerCORS.component.defaults.d.ts +0 -2
  72. package/dist/src/components/A-ServerCORS/A_ServerCORS.component.defaults.js +0 -11
  73. package/dist/src/components/A-ServerCORS/A_ServerCORS.component.defaults.js.map +0 -1
  74. package/dist/src/components/A-ServerCORS/A_ServerCORS.component.js +0 -70
  75. package/dist/src/components/A-ServerCORS/A_ServerCORS.component.js.map +0 -1
  76. package/dist/src/components/A-ServerCORS/A_ServerCORS.component.types.d.ts +0 -7
  77. package/dist/src/components/A-ServerCORS/A_ServerCORS.component.types.js +0 -3
  78. package/dist/src/components/A-ServerCORS/A_ServerCORS.component.types.js.map +0 -1
  79. package/dist/src/components/A-ServerError/A-ServerError.class.d.ts +0 -7
  80. package/dist/src/components/A-ServerError/A-ServerError.class.js +0 -88
  81. package/dist/src/components/A-ServerError/A-ServerError.class.js.map +0 -1
  82. package/dist/src/components/A-ServerError/A-ServerError.constants.d.ts +0 -0
  83. package/dist/src/components/A-ServerError/A-ServerError.constants.js +0 -2
  84. package/dist/src/components/A-ServerError/A-ServerError.constants.js.map +0 -1
  85. package/dist/src/components/A-ServerError/A-ServerError.types.d.ts +0 -13
  86. package/dist/src/components/A-ServerError/A-ServerError.types.js +0 -3
  87. package/dist/src/components/A-ServerError/A-ServerError.types.js.map +0 -1
  88. package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.d.ts +0 -7
  89. package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.js +0 -81
  90. package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.js.map +0 -1
  91. package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.types.d.ts +0 -0
  92. package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.types.js +0 -2
  93. package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.types.js.map +0 -1
  94. package/dist/src/components/A-ServerLogger/A-ServerLogger.constants.d.ts +0 -22
  95. package/dist/src/components/A-ServerLogger/A-ServerLogger.constants.js +0 -31
  96. package/dist/src/components/A-ServerLogger/A-ServerLogger.constants.js.map +0 -1
  97. package/dist/src/components/A-ServerLogger/A_ServerLogger.component.d.ts +0 -43
  98. package/dist/src/components/A-ServerLogger/A_ServerLogger.component.js +0 -167
  99. package/dist/src/components/A-ServerLogger/A_ServerLogger.component.js.map +0 -1
  100. package/dist/src/components/A-ServerLogger/A_ServerLogger.component.types.d.ts +0 -9
  101. package/dist/src/components/A-ServerLogger/A_ServerLogger.component.types.js +0 -3
  102. package/dist/src/components/A-ServerLogger/A_ServerLogger.component.types.js.map +0 -1
  103. package/dist/src/components/A-ServerProxy/A-ServerProxy.component.d.ts +0 -9
  104. package/dist/src/components/A-ServerProxy/A-ServerProxy.component.js +0 -88
  105. package/dist/src/components/A-ServerProxy/A-ServerProxy.component.js.map +0 -1
  106. package/dist/src/components/A-StaticLoader/A-StaticLoader.component.d.ts +0 -12
  107. package/dist/src/components/A-StaticLoader/A-StaticLoader.component.js +0 -126
  108. package/dist/src/components/A-StaticLoader/A-StaticLoader.component.js.map +0 -1
  109. package/dist/src/components/A-StaticLoader/A-StaticLoader.component.types.d.ts +0 -10
  110. package/dist/src/components/A-StaticLoader/A-StaticLoader.component.types.js +0 -109
  111. package/dist/src/components/A-StaticLoader/A-StaticLoader.component.types.js.map +0 -1
  112. package/dist/src/constants/env.constants.d.ts +0 -10
  113. package/dist/src/constants/env.constants.js +0 -20
  114. package/dist/src/constants/env.constants.js.map +0 -1
  115. package/dist/src/containers/A-Service/A-Service.container.d.ts +0 -30
  116. package/dist/src/containers/A-Service/A-Service.container.js +0 -200
  117. package/dist/src/containers/A-Service/A-Service.container.js.map +0 -1
  118. package/dist/src/containers/A-Service/A-Service.container.types.d.ts +0 -36
  119. package/dist/src/containers/A-Service/A-Service.container.types.js +0 -27
  120. package/dist/src/containers/A-Service/A-Service.container.types.js.map +0 -1
  121. package/dist/src/context/A-EntityFactory/A-EntityFactory.context.d.ts +0 -39
  122. package/dist/src/context/A-EntityFactory/A-EntityFactory.context.js +0 -69
  123. package/dist/src/context/A-EntityFactory/A-EntityFactory.context.js.map +0 -1
  124. package/dist/src/context/A-EntityFactory/A-EntityFactory.context.types.d.ts +0 -5
  125. package/dist/src/context/A-EntityFactory/A-EntityFactory.context.types.js +0 -3
  126. package/dist/src/context/A-EntityFactory/A-EntityFactory.context.types.js.map +0 -1
  127. package/dist/src/context/A-HttpChannel/A-HttpChannel.context.d.ts +0 -12
  128. package/dist/src/context/A-HttpChannel/A-HttpChannel.context.js +0 -16
  129. package/dist/src/context/A-HttpChannel/A-HttpChannel.context.js.map +0 -1
  130. package/dist/src/context/A-ListQueryFilter/A_ListQueryFilter.context.d.ts +0 -10
  131. package/dist/src/context/A-ListQueryFilter/A_ListQueryFilter.context.js +0 -30
  132. package/dist/src/context/A-ListQueryFilter/A_ListQueryFilter.context.js.map +0 -1
  133. package/dist/src/context/A-ProxyConfig/A_ProxyConfig.constants.d.ts +0 -2
  134. package/dist/src/context/A-ProxyConfig/A_ProxyConfig.constants.js +0 -12
  135. package/dist/src/context/A-ProxyConfig/A_ProxyConfig.constants.js.map +0 -1
  136. package/dist/src/context/A-ProxyConfig/A_ProxyConfig.context.d.ts +0 -29
  137. package/dist/src/context/A-ProxyConfig/A_ProxyConfig.context.js +0 -60
  138. package/dist/src/context/A-ProxyConfig/A_ProxyConfig.context.js.map +0 -1
  139. package/dist/src/context/A-ProxyConfig/A_ProxyConfig.types.d.ts +0 -18
  140. package/dist/src/context/A-ProxyConfig/A_ProxyConfig.types.js +0 -3
  141. package/dist/src/context/A-ProxyConfig/A_ProxyConfig.types.js.map +0 -1
  142. package/dist/src/context/A-Server/A_Server.context.d.ts +0 -17
  143. package/dist/src/context/A-Server/A_Server.context.js +0 -22
  144. package/dist/src/context/A-Server/A_Server.context.js.map +0 -1
  145. package/dist/src/context/A-Server/A_Server.context.types.d.ts +0 -7
  146. package/dist/src/context/A-Server/A_Server.context.types.js +0 -3
  147. package/dist/src/context/A-Server/A_Server.context.types.js.map +0 -1
  148. package/dist/src/context/A-StaticConfig/A-StaticConfig.context.d.ts +0 -16
  149. package/dist/src/context/A-StaticConfig/A-StaticConfig.context.js +0 -28
  150. package/dist/src/context/A-StaticConfig/A-StaticConfig.context.js.map +0 -1
  151. package/dist/src/context/A-StaticConfig/A-StaticConfig.context.types.d.ts +0 -0
  152. package/dist/src/context/A-StaticConfig/A-StaticConfig.context.types.js +0 -2
  153. package/dist/src/context/A-StaticConfig/A-StaticConfig.context.types.js.map +0 -1
  154. package/dist/src/entities/A-Request/A-Request.entity.d.ts +0 -31
  155. package/dist/src/entities/A-Request/A-Request.entity.js +0 -125
  156. package/dist/src/entities/A-Request/A-Request.entity.js.map +0 -1
  157. package/dist/src/entities/A-Request/A-Request.entity.types.d.ts +0 -21
  158. package/dist/src/entities/A-Request/A-Request.entity.types.js +0 -12
  159. package/dist/src/entities/A-Request/A-Request.entity.types.js.map +0 -1
  160. package/dist/src/entities/A-Response/A-Response.entity.d.ts +0 -28
  161. package/dist/src/entities/A-Response/A-Response.entity.js +0 -141
  162. package/dist/src/entities/A-Response/A-Response.entity.js.map +0 -1
  163. package/dist/src/entities/A-Response/A-Response.entity.types.d.ts +0 -19
  164. package/dist/src/entities/A-Response/A-Response.entity.types.js +0 -12
  165. package/dist/src/entities/A-Response/A-Response.entity.types.js.map +0 -1
  166. package/dist/src/entities/A-Route/A-Route.entity.d.ts +0 -17
  167. package/dist/src/entities/A-Route/A-Route.entity.js +0 -76
  168. package/dist/src/entities/A-Route/A-Route.entity.js.map +0 -1
  169. package/dist/src/entities/A-Route/A-Route.entity.types.d.ts +0 -0
  170. package/dist/src/entities/A-Route/A-Route.entity.types.js +0 -2
  171. package/dist/src/entities/A-Route/A-Route.entity.types.js.map +0 -1
  172. package/dist/src/entities/A_EntityList/A_EntityList.entity.d.ts +0 -46
  173. package/dist/src/entities/A_EntityList/A_EntityList.entity.js +0 -91
  174. package/dist/src/entities/A_EntityList/A_EntityList.entity.js.map +0 -1
  175. package/dist/src/entities/A_EntityList/A_EntityList.entity.types.d.ts +0 -21
  176. package/dist/src/entities/A_EntityList/A_EntityList.entity.types.js +0 -8
  177. package/dist/src/entities/A_EntityList/A_EntityList.entity.types.js.map +0 -1
  178. package/index.ts +0 -75
  179. package/tsconfig.build.json +0 -62
@@ -1,81 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- };
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
31
- var __param = (this && this.__param) || function (paramIndex, decorator) {
32
- return function (target, key) { decorator(target, key, paramIndex); }
33
- };
34
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
35
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
36
- return new (P || (P = Promise))(function (resolve, reject) {
37
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
38
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
39
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
40
- step((generator = generator.apply(thisArg, _arguments || [])).next());
41
- });
42
- };
43
- Object.defineProperty(exports, "__esModule", { value: true });
44
- exports.A_ServerHealthMonitor = void 0;
45
- const a_concept_1 = require("@adaas/a-concept");
46
- const A_Router_component_1 = require("../A-Router/A-Router.component");
47
- const A_Request_entity_1 = require("../../entities/A-Request/A-Request.entity");
48
- const A_Response_entity_1 = require("../../entities/A-Response/A-Response.entity");
49
- const a_utils_1 = require("@adaas/a-utils");
50
- class A_ServerHealthMonitor extends a_concept_1.A_Component {
51
- // =======================================================
52
- // ================ Method Definition=====================
53
- // =======================================================
54
- get(config, request, response, logger) {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- var _a;
57
- logger.log('Health check requested', config.get('A_CONCEPT_ROOT_FOLDER'));
58
- const packageJSON = yield Promise.resolve(`${`${config.get('A_CONCEPT_ROOT_FOLDER')}/package.json`}`).then(s => __importStar(require(s)));
59
- const exposedProperties = ((_a = config.get('EXPOSED_PROPERTIES')) === null || _a === void 0 ? void 0 : _a.split(',')) || [
60
- 'name',
61
- 'version',
62
- 'description',
63
- ];
64
- exposedProperties.forEach(prop => response.add(prop, packageJSON[prop]));
65
- console.log(`Health check accessed: ${request.method} ${request.url}`);
66
- });
67
- }
68
- }
69
- exports.A_ServerHealthMonitor = A_ServerHealthMonitor;
70
- __decorate([
71
- A_Router_component_1.A_Router.Get({
72
- path: '/',
73
- prefix: 'health',
74
- version: 'v1',
75
- }),
76
- __param(0, (0, a_concept_1.A_Inject)(a_utils_1.A_Config)),
77
- __param(1, (0, a_concept_1.A_Inject)(A_Request_entity_1.A_Request)),
78
- __param(2, (0, a_concept_1.A_Inject)(A_Response_entity_1.A_Response)),
79
- __param(3, (0, a_concept_1.A_Inject)(a_utils_1.A_Logger))
80
- ], A_ServerHealthMonitor.prototype, "get", null);
81
- //# sourceMappingURL=A-ServerHealthMonitor.component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A-ServerHealthMonitor.component.js","sourceRoot":"","sources":["../../../../src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAyD;AACzD,uEAA0D;AAC1D,0FAAgF;AAChF,6FAAmF;AACnF,4CAAoD;AAIpD,MAAa,qBAAsB,SAAQ,uBAAW;IAGlD,0DAA0D;IAC1D,0DAA0D;IAC1D,0DAA0D;IAOpD,GAAG,CACe,MAAwD,EACvD,OAAkB,EACjB,QAAoB,EACtB,MAAgB;;;YAEpC,MAAM,CAAC,GAAG,CAAC,wBAAwB,EAAE,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC;YAE1E,MAAM,WAAW,GAAG,yBAAa,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,eAAe,uCAAC,CAAC;YACxF,MAAM,iBAAiB,GAAkB,CAAA,MAAA,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,0CAAE,KAAK,CAAC,GAAG,CAAC,KAAI;gBACrF,MAAM;gBACN,SAAS;gBACT,aAAa;aAChB,CAAC;YAEF,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAEzE,OAAO,CAAC,GAAG,CAAC,0BAA0B,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC3E,CAAC;KAAA;CACJ;AA/BD,sDA+BC;AAnBS;IALL,6BAAQ,CAAC,GAAG,CAAC;QACV,IAAI,EAAE,GAAG;QACT,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE,IAAI;KAChB,CAAC;IAEG,WAAA,IAAA,oBAAQ,EAAC,kBAAQ,CAAC,CAAA;IAClB,WAAA,IAAA,oBAAQ,EAAC,4BAAS,CAAC,CAAA;IACnB,WAAA,IAAA,oBAAQ,EAAC,8BAAU,CAAC,CAAA;IACpB,WAAA,IAAA,oBAAQ,EAAC,kBAAQ,CAAC,CAAA;gDActB"}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=A-ServerHealthMonitor.component.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A-ServerHealthMonitor.component.types.js","sourceRoot":"","sources":["../../../../src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.types.ts"],"names":[],"mappings":""}
@@ -1,22 +0,0 @@
1
- export declare const A_SERVER__A_SERVER_LOGGER_ENV_VARIABLES: {
2
- /**
3
- * Enable logging of 200 responses
4
- */
5
- readonly SERVER_IGNORE_LOG_200: "SERVER_IGNORE_LOG_200";
6
- /**
7
- * Enable logging of 404 responses
8
- */
9
- readonly SERVER_IGNORE_LOG_404: "SERVER_IGNORE_LOG_404";
10
- /**
11
- * Enable logging of 500 responses
12
- */
13
- readonly SERVER_IGNORE_LOG_500: "SERVER_IGNORE_LOG_500";
14
- /**
15
- * Enable logging of 400 responses
16
- */
17
- readonly SERVER_IGNORE_LOG_400: "SERVER_IGNORE_LOG_400";
18
- /**
19
- * Enable logging of default responses
20
- */
21
- readonly SERVER_IGNORE_LOG_DEFAULT: "SERVER_IGNORE_LOG_DEFAULT";
22
- };
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.A_SERVER__A_SERVER_LOGGER_ENV_VARIABLES = void 0;
4
- exports.A_SERVER__A_SERVER_LOGGER_ENV_VARIABLES = {
5
- // ----------------------------------------------------------
6
- // A-ServerLogger Environment Variables
7
- // ----------------------------------------------------------
8
- // These environment variables are used by A-Concept core to configure the application
9
- // ----------------------------------------------------------
10
- /**
11
- * Enable logging of 200 responses
12
- */
13
- SERVER_IGNORE_LOG_200: 'SERVER_IGNORE_LOG_200',
14
- /**
15
- * Enable logging of 404 responses
16
- */
17
- SERVER_IGNORE_LOG_404: 'SERVER_IGNORE_LOG_404',
18
- /**
19
- * Enable logging of 500 responses
20
- */
21
- SERVER_IGNORE_LOG_500: 'SERVER_IGNORE_LOG_500',
22
- /**
23
- * Enable logging of 400 responses
24
- */
25
- SERVER_IGNORE_LOG_400: 'SERVER_IGNORE_LOG_400',
26
- /**
27
- * Enable logging of default responses
28
- */
29
- SERVER_IGNORE_LOG_DEFAULT: 'SERVER_IGNORE_LOG_DEFAULT',
30
- };
31
- //# sourceMappingURL=A-ServerLogger.constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A-ServerLogger.constants.js","sourceRoot":"","sources":["../../../../src/components/A-ServerLogger/A-ServerLogger.constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,uCAAuC,GAAG;IACnD,6DAA6D;IAC7D,uCAAuC;IACvC,6DAA6D;IAC7D,sFAAsF;IACtF,6DAA6D;IAC7D;;OAEG;IACH,qBAAqB,EAAE,uBAAuB;IAC9C;;OAEG;IACH,qBAAqB,EAAE,uBAAuB;IAC9C;;OAEG;IACH,qBAAqB,EAAE,uBAAuB;IAC9C;;OAEG;IACH,qBAAqB,EAAE,uBAAuB;IAC9C;;OAEG;IACH,yBAAyB,EAAE,2BAA2B;CAChD,CAAA"}
@@ -1,43 +0,0 @@
1
- import { A_Server } from "../../context/A-Server/A_Server.context";
2
- import { A_SERVER_TYPES__ServerLoggerEnvVariables, A_SERVER_TYPES__ServerLoggerRouteParams } from "./A_ServerLogger.component.types";
3
- import { A_Service } from "../../containers/A-Service/A-Service.container";
4
- import { A_Request } from "../../entities/A-Request/A-Request.entity";
5
- import { A_Response } from "../../entities/A-Response/A-Response.entity";
6
- import { A_Route } from "../../entities/A-Route/A-Route.entity";
7
- import { A_Config, A_Logger } from "@adaas/a-utils";
8
- export declare class A_ServerLogger extends A_Logger {
9
- protected config: A_Config<A_SERVER_TYPES__ServerLoggerEnvVariables>;
10
- onRequestEnd(request: A_Request, response: A_Response): Promise<void>;
11
- onRequestError(request: A_Request): Promise<void>;
12
- logStart(container: A_Service): void;
13
- logStop(server: A_Server): void;
14
- metrics(): void;
15
- routes(routes: Array<A_Route>): void;
16
- /**
17
- * Logs the route information based on status code
18
- *
19
- * @param route
20
- */
21
- route(route: A_SERVER_TYPES__ServerLoggerRouteParams): void;
22
- log200(route: A_SERVER_TYPES__ServerLoggerRouteParams): void;
23
- log404(route: A_SERVER_TYPES__ServerLoggerRouteParams): void;
24
- log500(route: A_SERVER_TYPES__ServerLoggerRouteParams): void;
25
- log400(route: A_SERVER_TYPES__ServerLoggerRouteParams): void;
26
- logDefault(route: A_SERVER_TYPES__ServerLoggerRouteParams): void;
27
- serverReady(params: {
28
- port: number;
29
- app: {
30
- name: string;
31
- version?: string;
32
- };
33
- }): void;
34
- /**
35
- * Displays a proxy routes
36
- *
37
- * @param params
38
- */
39
- proxy(params: {
40
- original: string;
41
- destination: string;
42
- }): void;
43
- }
@@ -1,167 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __param = (this && this.__param) || function (paramIndex, decorator) {
9
- return function (target, key) { decorator(target, key, paramIndex); }
10
- };
11
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
- return new (P || (P = Promise))(function (resolve, reject) {
14
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
- step((generator = generator.apply(thisArg, _arguments || [])).next());
18
- });
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.A_ServerLogger = void 0;
22
- const a_concept_1 = require("@adaas/a-concept");
23
- const A_Service_container_types_1 = require("../../containers/A-Service/A-Service.container.types");
24
- const A_Server_context_1 = require("../../context/A-Server/A_Server.context");
25
- const A_Service_container_1 = require("../../containers/A-Service/A-Service.container");
26
- const A_Request_entity_1 = require("../../entities/A-Request/A-Request.entity");
27
- const A_Response_entity_1 = require("../../entities/A-Response/A-Response.entity");
28
- const A_Response_entity_types_1 = require("../../entities/A-Response/A-Response.entity.types");
29
- const A_Request_entity_types_1 = require("../../entities/A-Request/A-Request.entity.types");
30
- const a_utils_1 = require("@adaas/a-utils");
31
- class A_ServerLogger extends a_utils_1.A_Logger {
32
- onRequestEnd(request, response) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- this.route({
35
- method: request.method,
36
- url: request.url,
37
- status: response.statusCode,
38
- responseTime: response.duration
39
- });
40
- });
41
- }
42
- onRequestError(request) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- });
45
- }
46
- logStart(container) {
47
- this.serverReady({
48
- port: container.port,
49
- app: {
50
- name: container.name,
51
- }
52
- });
53
- }
54
- logStop(server) {
55
- this.log('red', `Server ${server.name} stopped`);
56
- }
57
- metrics() {
58
- }
59
- routes(routes) {
60
- const time = this.getTime();
61
- console.log(`\x1b[36m[${this.scope.name}] |${time}| Exposed Routes:
62
- ${' '.repeat(this.scopeLength + 3)}|-------------------------------
63
- ${routes.map(route => `${' '.repeat(this.scopeLength + 3)}| [${route.method.toUpperCase()}]${' '.repeat(7 - route.method.length)} ${route.path}`).join('\n')}
64
- ${' '.repeat(this.scopeLength + 3)}|-------------------------------\x1b[0m`);
65
- }
66
- /**
67
- * Logs the route information based on status code
68
- *
69
- * @param route
70
- */
71
- route(route) {
72
- switch (route.status) {
73
- case 200:
74
- this.log200(route);
75
- break;
76
- case 404:
77
- this.log404(route);
78
- break;
79
- case 500:
80
- this.log500(route);
81
- break;
82
- case 400:
83
- this.log400(route);
84
- break;
85
- default:
86
- this.logDefault(route);
87
- break;
88
- }
89
- }
90
- log200(route) {
91
- if (this.config.get('SERVER_IGNORE_LOG_200'))
92
- return;
93
- console.log(`\x1b[32m[${this.scope.name}] |${this.getTime()}| ${route.status} | [${route.method.toUpperCase()}]${' '.repeat(7 - route.method.length)} ${route.url} | ${route.responseTime}ms\x1b[0m`);
94
- }
95
- log404(route) {
96
- if (this.config.get('SERVER_IGNORE_LOG_404'))
97
- return;
98
- console.log(`\x1b[33m[${this.scope.name}] |${this.getTime()}| ${route.status} | [${route.method.toUpperCase()}]${' '.repeat(7 - route.method.length)} ${route.url} | ${route.responseTime}ms\x1b[0m`);
99
- }
100
- log500(route) {
101
- if (this.config.get('SERVER_IGNORE_LOG_500'))
102
- return;
103
- console.log(`\x1b[31m[${this.scope.name}] |${this.getTime()}| ${route.status} | [${route.method.toUpperCase()}]${' '.repeat(7 - route.method.length)} ${route.url} | ${route.responseTime}ms\x1b[0m`);
104
- }
105
- log400(route) {
106
- if (this.config.get('SERVER_IGNORE_LOG_400'))
107
- return;
108
- console.log(`\x1b[33m[${this.scope.name}] |${this.getTime()}| ${route.status} | [${route.method.toUpperCase()}]${' '.repeat(7 - route.method.length)} ${route.url} | ${route.responseTime}ms\x1b[0m`);
109
- }
110
- logDefault(route) {
111
- if (this.config.get('SERVER_IGNORE_LOG_DEFAULT'))
112
- return;
113
- console.log(`\x1b[36m[${this.scope.name}] |${this.getTime()}| ${route.status} | [${route.method.toUpperCase()}]${' '.repeat(7 - route.method.length)} ${route.url} | ${route.responseTime}ms\x1b[0m`);
114
- }
115
- serverReady(params) {
116
- const processId = process.pid;
117
- console.log(`\x1b[36m[${this.scope.name}] |${this.getTime()}| Server Ready:
118
- ${' '.repeat(this.scopeLength + 3)}|-------------------------------
119
- ${' '.repeat(this.scopeLength + 3)}| ${params.app.name} v${params.app.version || '0.0.1'} is running on port ${params.port}
120
- ${' '.repeat(this.scopeLength + 3)}| Process ID: ${processId}
121
- ${' '.repeat(this.scopeLength + 3)}|-------------------------------
122
- ${' '.repeat(this.scopeLength + 3)}| ==============================
123
- ${' '.repeat(this.scopeLength + 3)}| LISTENING...
124
- ${' '.repeat(this.scopeLength + 3)}| ==============================
125
- \x1b[0m`);
126
- }
127
- /**
128
- * Displays a proxy routes
129
- *
130
- * @param params
131
- */
132
- proxy(params) {
133
- console.log(`\x1b[35m[${this.scope.name}] |${this.getTime()}| Proxy:
134
- ${' '.repeat(this.scopeLength + 3)}| ${params.original} -> ${params.destination}
135
- ${' '.repeat(this.scopeLength + 3)}|-------------------------------\x1b[0m`);
136
- }
137
- }
138
- exports.A_ServerLogger = A_ServerLogger;
139
- __decorate([
140
- a_concept_1.A_Feature.Extend({
141
- name: A_Response_entity_types_1.A_SERVER_TYPES__ResponseEvent.Finish,
142
- scope: [A_Response_entity_1.A_Response]
143
- }),
144
- __param(0, (0, a_concept_1.A_Inject)(A_Request_entity_1.A_Request)),
145
- __param(1, (0, a_concept_1.A_Inject)(A_Response_entity_1.A_Response))
146
- ], A_ServerLogger.prototype, "onRequestEnd", null);
147
- __decorate([
148
- a_concept_1.A_Feature.Extend({
149
- name: A_Request_entity_types_1.A_SERVER_TYPES__RequestEvent.Error,
150
- }),
151
- __param(0, (0, a_concept_1.A_Inject)(A_Request_entity_1.A_Request))
152
- ], A_ServerLogger.prototype, "onRequestError", null);
153
- __decorate([
154
- a_concept_1.A_Feature.Extend({
155
- name: A_Service_container_types_1.A_SERVER_TYPES__ServerFeature.afterStart,
156
- scope: [A_Service_container_1.A_Service]
157
- }),
158
- __param(0, (0, a_concept_1.A_Inject)(A_Service_container_1.A_Service))
159
- ], A_ServerLogger.prototype, "logStart", null);
160
- __decorate([
161
- a_concept_1.A_Feature.Extend({
162
- name: A_Service_container_types_1.A_SERVER_TYPES__ServerFeature.afterStop,
163
- scope: [A_Service_container_1.A_Service]
164
- }),
165
- __param(0, (0, a_concept_1.A_Inject)(A_Server_context_1.A_Server))
166
- ], A_ServerLogger.prototype, "logStop", null);
167
- //# sourceMappingURL=A_ServerLogger.component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A_ServerLogger.component.js","sourceRoot":"","sources":["../../../../src/components/A-ServerLogger/A_ServerLogger.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,gDAAqE;AACrE,8GAA+G;AAC/G,wFAA6E;AAE7E,kGAAqF;AACrF,0FAAgF;AAChF,6FAAmF;AACnF,yGAA4G;AAE5G,sGAAyG;AACzG,4CAAoD;AAGpD,MAAa,cAAe,SAAQ,kBAAQ;I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G,CAAC,CAAC,yCAAyC,CAAC,CAAC;IACzE,CAAC;CAEJ;AApLD,wCAoLC;AA3KS;IAJL,qBAAS,CAAC,MAAM,CAAC;QACd,IAAI,EAAE,uDAA6B,CAAC,MAAM;QAC1C,KAAK,EAAE,CAAC,8BAAU,CAAC;KACtB,CAAC;IAEG,WAAA,IAAA,oBAAQ,EAAC,4BAAS,CAAC,CAAA;IACnB,WAAA,IAAA,oBAAQ,EAAC,8BAAU,CAAC,CAAA;kDASxB;AAMK;IAHL,qBAAS,CAAC,MAAM,CAAC;QACd,IAAI,EAAE,qDAA4B,CAAC,KAAK;KAC3C,CAAC;IAEG,WAAA,IAAA,oBAAQ,EAAC,4BAAS,CAAC,CAAA;oDAEvB;AAOD;IAJC,qBAAS,CAAC,MAAM,CAAC;QACd,IAAI,EAAE,yDAA6B,CAAC,UAAU;QAC9C,KAAK,EAAE,CAAC,+BAAS,CAAC;KACrB,CAAC;IAEG,WAAA,IAAA,oBAAQ,EAAC,+BAAS,CAAC,CAAA;8CAQvB;AASD;IAJC,qBAAS,CAAC,MAAM,CAAC;QACd,IAAI,EAAE,yDAA6B,CAAC,SAAS;QAC7C,KAAK,EAAE,CAAC,+BAAS,CAAC;KACrB,CAAC;IAEG,WAAA,IAAA,oBAAQ,EAAC,2BAAQ,CAAC,CAAA;6CAGtB"}
@@ -1,9 +0,0 @@
1
- import { A_TYPES__ConceptENVVariables } from "@adaas/a-concept/dist/src/constants/env.constants";
2
- import { A_SERVER__A_SERVER_LOGGER_ENV_VARIABLES } from "./A-ServerLogger.constants";
3
- export type A_SERVER_TYPES__ServerLoggerRouteParams = {
4
- method: string;
5
- url: string;
6
- status: number;
7
- responseTime: number;
8
- };
9
- export type A_SERVER_TYPES__ServerLoggerEnvVariables = Array<keyof typeof A_SERVER__A_SERVER_LOGGER_ENV_VARIABLES> | A_TYPES__ConceptENVVariables;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=A_ServerLogger.component.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A_ServerLogger.component.types.js","sourceRoot":"","sources":["../../../../src/components/A-ServerLogger/A_ServerLogger.component.types.ts"],"names":[],"mappings":""}
@@ -1,9 +0,0 @@
1
- import { A_Component } from "@adaas/a-concept";
2
- import { A_ProxyConfig } from "../../context/A-ProxyConfig/A_ProxyConfig.context";
3
- import { A_Request } from "../../entities/A-Request/A-Request.entity";
4
- import { A_Response } from "../../entities/A-Response/A-Response.entity";
5
- import { A_Logger } from "@adaas/a-utils";
6
- export declare class A_ServerProxy extends A_Component {
7
- load(logger: A_Logger, config: A_ProxyConfig): Promise<void>;
8
- onRequest(req: A_Request, res: A_Response, proxyConfig: A_ProxyConfig, logger: A_Logger): Promise<void>;
9
- }
@@ -1,88 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __param = (this && this.__param) || function (paramIndex, decorator) {
9
- return function (target, key) { decorator(target, key, paramIndex); }
10
- };
11
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
- return new (P || (P = Promise))(function (resolve, reject) {
14
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
- step((generator = generator.apply(thisArg, _arguments || [])).next());
18
- });
19
- };
20
- var __importDefault = (this && this.__importDefault) || function (mod) {
21
- return (mod && mod.__esModule) ? mod : { "default": mod };
22
- };
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.A_ServerProxy = void 0;
25
- const a_concept_1 = require("@adaas/a-concept");
26
- const A_Service_container_types_1 = require("../../containers/A-Service/A-Service.container.types");
27
- const A_ProxyConfig_context_1 = require("../../context/A-ProxyConfig/A_ProxyConfig.context");
28
- const A_Request_entity_1 = require("../../entities/A-Request/A-Request.entity");
29
- const A_Response_entity_1 = require("../../entities/A-Response/A-Response.entity");
30
- const A_Route_entity_1 = require("../../entities/A-Route/A-Route.entity");
31
- const a_utils_1 = require("@adaas/a-utils");
32
- const http_1 = __importDefault(require("http"));
33
- const https_1 = __importDefault(require("https"));
34
- class A_ServerProxy extends a_concept_1.A_Component {
35
- load(logger, config) {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- logger.log('pink', `Proxy routes configured:`, config.configs.map(c => c.route).join('\n'));
38
- });
39
- }
40
- onRequest(req, res, proxyConfig, logger) {
41
- return __awaiter(this, void 0, void 0, function* () {
42
- return new Promise((resolve, reject) => {
43
- const { method, url } = req;
44
- const route = new A_Route_entity_1.A_Route(url, method);
45
- const config = proxyConfig.config(route.toString());
46
- if (!config) {
47
- return resolve(); // nothing to proxy
48
- }
49
- logger.log("yellow", `Proxying request ${method} ${url} to ${config.hostname}`, config);
50
- const client = config.protocol === "https:" ? https_1.default : http_1.default;
51
- const proxyReq = client.request({
52
- method: config.route.method,
53
- hostname: config.hostname,
54
- port: config.port,
55
- headers: config.headers,
56
- path: route.path,
57
- }, (proxyRes) => {
58
- if (!res.headersSent) {
59
- res.writeHead(proxyRes.statusCode || 200, proxyRes.headers);
60
- }
61
- proxyRes.on("end", () => {
62
- logger.log("green", `Proxy request to ${config === null || config === void 0 ? void 0 : config.hostname} completed`);
63
- resolve();
64
- });
65
- proxyRes.pipe(res.original);
66
- });
67
- proxyReq.on("error", (err) => reject(err));
68
- req.pipe(proxyReq);
69
- });
70
- });
71
- }
72
- }
73
- exports.A_ServerProxy = A_ServerProxy;
74
- __decorate([
75
- a_concept_1.A_Concept.Load(),
76
- __param(0, (0, a_concept_1.A_Inject)(a_utils_1.A_Logger)),
77
- __param(1, (0, a_concept_1.A_Inject)(A_ProxyConfig_context_1.A_ProxyConfig))
78
- ], A_ServerProxy.prototype, "load", null);
79
- __decorate([
80
- a_concept_1.A_Feature.Extend({
81
- name: A_Service_container_types_1.A_SERVER_TYPES__ServerFeature.onRequest,
82
- }),
83
- __param(0, (0, a_concept_1.A_Inject)(A_Request_entity_1.A_Request)),
84
- __param(1, (0, a_concept_1.A_Inject)(A_Response_entity_1.A_Response)),
85
- __param(2, (0, a_concept_1.A_Inject)(A_ProxyConfig_context_1.A_ProxyConfig)),
86
- __param(3, (0, a_concept_1.A_Inject)(a_utils_1.A_Logger))
87
- ], A_ServerProxy.prototype, "onRequest", null);
88
- //# sourceMappingURL=A-ServerProxy.component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A-ServerProxy.component.js","sourceRoot":"","sources":["../../../../src/components/A-ServerProxy/A-ServerProxy.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA+E;AAC/E,8GAA+G;AAC/G,uGAA4F;AAC5F,0FAAgF;AAChF,6FAAmF;AACnF,oFAA0E;AAC1E,4CAA0C;AAC1C,gDAAwB;AACxB,kDAA0B;AAG1B,MAAa,aAAc,SAAQ,uBAAW;IAIpC,IAAI,CACc,MAAgB,EACX,MAAqB;;YAE9C,MAAM,CAAC,GAAG,CACN,MAAM,EACN,0BAA0B,EAC1B,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAC9C,CAAC;QACN,CAAC;KAAA;IAOK,SAAS,CACU,GAAc,EACb,GAAe,EACZ,WAA0B,EAC/B,MAAgB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Y,CAAC,CAAC;wBAEtE,OAAO,EAAE,CAAC;oBACd,CAAC,CAAC,CAAC;oBAEH,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAChC,CAAC,CACJ,CAAC;gBAEF,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;gBAE3C,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACvB,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;CAEJ;AAzED,sCAyEC;AArES;IADL,qBAAS,CAAC,IAAI,EAAE;IAEZ,WAAA,IAAA,oBAAQ,EAAC,kBAAQ,CAAC,CAAA;IAClB,WAAA,IAAA,oBAAQ,EAAC,qCAAa,CAAC,CAAA;yCAO3B;AAOK;IAHL,qBAAS,CAAC,MAAM,CAAC;QACd,IAAI,EAAE,yDAA6B,CAAC,SAAS;KAChD,CAAC;IAEG,WAAA,IAAA,oBAAQ,EAAC,4BAAS,CAAC,CAAA;IACnB,WAAA,IAAA,oBAAQ,EAAC,8BAAU,CAAC,CAAA;IACpB,WAAA,IAAA,oBAAQ,EAAC,qCAAa,CAAC,CAAA;IACvB,WAAA,IAAA,oBAAQ,EAAC,kBAAQ,CAAC,CAAA;8CA+CtB"}
@@ -1,12 +0,0 @@
1
- import { A_Component } from "@adaas/a-concept";
2
- import { A_Request } from "../../entities/A-Request/A-Request.entity";
3
- import { A_Response } from "../../entities/A-Response/A-Response.entity";
4
- import { A_StaticConfig } from "../../context/A-StaticConfig/A-StaticConfig.context";
5
- import { A_Logger } from "@adaas/a-utils";
6
- export declare class A_StaticLoader extends A_Component {
7
- load(logger: A_Logger, config: A_StaticConfig): Promise<void>;
8
- onRequest(req: A_Request, res: A_Response, logger: A_Logger, config: A_StaticConfig): Promise<void>;
9
- protected getMimeType(ext: string): string;
10
- protected safeFilePath(staticDir: string, reqUrl: string, host?: string): string;
11
- protected serveFile(filePath: string, res: A_Response): Promise<void>;
12
- }
@@ -1,126 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __param = (this && this.__param) || function (paramIndex, decorator) {
9
- return function (target, key) { decorator(target, key, paramIndex); }
10
- };
11
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
- return new (P || (P = Promise))(function (resolve, reject) {
14
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
- step((generator = generator.apply(thisArg, _arguments || [])).next());
18
- });
19
- };
20
- var __importDefault = (this && this.__importDefault) || function (mod) {
21
- return (mod && mod.__esModule) ? mod : { "default": mod };
22
- };
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.A_StaticLoader = void 0;
25
- const a_concept_1 = require("@adaas/a-concept");
26
- const fs_1 = __importDefault(require("fs"));
27
- const path_1 = __importDefault(require("path"));
28
- const url_1 = require("url");
29
- const A_Request_entity_1 = require("../../entities/A-Request/A-Request.entity");
30
- const A_Response_entity_1 = require("../../entities/A-Response/A-Response.entity");
31
- const A_Service_container_types_1 = require("../../containers/A-Service/A-Service.container.types");
32
- const A_Route_entity_1 = require("../../entities/A-Route/A-Route.entity");
33
- const A_StaticConfig_context_1 = require("../../context/A-StaticConfig/A-StaticConfig.context");
34
- const a_utils_1 = require("@adaas/a-utils");
35
- class A_StaticLoader extends a_concept_1.A_Component {
36
- load(logger, config) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- logger.log('pink', `Static directories configured:`, config.directories.join('\n'));
39
- });
40
- }
41
- // =======================================================
42
- // ================ Method Definition=====================
43
- // =======================================================
44
- onRequest(req, res, logger, config) {
45
- return __awaiter(this, void 0, void 0, function* () {
46
- if (req.method !== 'GET' && req.method !== 'HEAD') {
47
- return; // Only handle GET and HEAD requests
48
- }
49
- const { method, url } = req;
50
- const route = new A_Route_entity_1.A_Route(url, method);
51
- const staticDirConfig = config.has(route.path);
52
- if (!staticDirConfig) {
53
- return; // No static config for this path
54
- }
55
- const staticDir = path_1.default.resolve(process.cwd(), staticDirConfig);
56
- if (!fs_1.default.existsSync(staticDir) || !fs_1.default.statSync(staticDir).isDirectory()) {
57
- logger.log("red", `Static directory ${staticDir} does not exist or is not a directory.`);
58
- return;
59
- }
60
- yield this.serveFile(route.path.startsWith('/') ? route.path.slice(1) : route.path, res);
61
- });
62
- }
63
- getMimeType(ext) {
64
- const mimeTypes = {
65
- ".html": "text/html",
66
- ".js": "application/javascript",
67
- ".css": "text/css",
68
- ".json": "application/json",
69
- ".png": "image/png",
70
- ".jpg": "image/jpeg",
71
- ".jpeg": "image/jpeg",
72
- ".gif": "image/gif",
73
- ".svg": "image/svg+xml",
74
- ".ico": "image/x-icon",
75
- ".txt": "text/plain",
76
- };
77
- return mimeTypes[ext.toLowerCase()] || "application/octet-stream";
78
- }
79
- safeFilePath(staticDir, reqUrl, host) {
80
- const parsedUrl = new url_1.URL(reqUrl || "/", `http://${host || "localhost"}`);
81
- let pathname = decodeURIComponent(parsedUrl.pathname);
82
- // Prevent path traversal attacks
83
- pathname = pathname.replace(/\.\.[\/\\]/g, "");
84
- let filePath = path_1.default.join(staticDir, pathname);
85
- if (!fs_1.default.existsSync(filePath))
86
- throw new Error(`File not found: ${filePath}`);
87
- return filePath;
88
- }
89
- serveFile(filePath, res) {
90
- return new Promise((resolve, reject) => {
91
- if (fs_1.default.existsSync(filePath)) {
92
- const ext = path_1.default.extname(filePath);
93
- const contentType = this.getMimeType(ext);
94
- res.writeHead(200, { "Content-Type": contentType });
95
- const stream = fs_1.default.createReadStream(filePath);
96
- stream.pipe(res.original);
97
- stream.on('end', () => {
98
- resolve();
99
- });
100
- stream.on("error", (err) => {
101
- reject(new Error(`File stream error: ${err.message}`));
102
- });
103
- }
104
- else {
105
- reject(new Error(`File not found: ${filePath}`));
106
- }
107
- resolve();
108
- });
109
- }
110
- }
111
- exports.A_StaticLoader = A_StaticLoader;
112
- __decorate([
113
- a_concept_1.A_Concept.Load(),
114
- __param(0, (0, a_concept_1.A_Inject)(a_utils_1.A_Logger)),
115
- __param(1, (0, a_concept_1.A_Inject)(A_StaticConfig_context_1.A_StaticConfig))
116
- ], A_StaticLoader.prototype, "load", null);
117
- __decorate([
118
- a_concept_1.A_Feature.Extend({
119
- name: A_Service_container_types_1.A_SERVER_TYPES__ServerFeature.onRequest,
120
- }),
121
- __param(0, (0, a_concept_1.A_Inject)(A_Request_entity_1.A_Request)),
122
- __param(1, (0, a_concept_1.A_Inject)(A_Response_entity_1.A_Response)),
123
- __param(2, (0, a_concept_1.A_Inject)(a_utils_1.A_Logger)),
124
- __param(3, (0, a_concept_1.A_Inject)(A_StaticConfig_context_1.A_StaticConfig))
125
- ], A_StaticLoader.prototype, "onRequest", null);
126
- //# sourceMappingURL=A-StaticLoader.component.js.map