@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.
- package/dist/index.d.mts +739 -0
- package/dist/index.d.ts +739 -36
- package/dist/index.js +1903 -102
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1863 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +6 -4
- package/src/components/A-ServerLogger/A_ServerLogger.component.ts +1 -1
- package/src/components/A-ServerProxy/A-ServerProxy.component.ts +8 -7
- package/src/components/A-StaticLoader/A-StaticLoader.component.types.ts +5 -107
- package/src/containers/A-Service/A-Service.container.ts +11 -7
- package/src/entities/A-Request/A-Request.entity.ts +1 -1
- package/src/entities/A-Request/A-Request.entity.types.ts +1 -1
- package/src/entities/A-Response/A-Response.entity.ts +1 -1
- package/src/entities/A-Response/A-Response.entity.types.ts +1 -1
- package/src/index.ts +75 -0
- package/tsconfig.json +1 -1
- package/tsup.config.ts +15 -0
- package/dist/src/channels/A-Http/A-Http.channel.constants.d.ts +0 -5
- package/dist/src/channels/A-Http/A-Http.channel.constants.js +0 -10
- package/dist/src/channels/A-Http/A-Http.channel.constants.js.map +0 -1
- package/dist/src/channels/A-Http/A-Http.channel.d.ts +0 -29
- package/dist/src/channels/A-Http/A-Http.channel.error.d.ts +0 -4
- package/dist/src/channels/A-Http/A-Http.channel.error.js +0 -9
- package/dist/src/channels/A-Http/A-Http.channel.error.js.map +0 -1
- package/dist/src/channels/A-Http/A-Http.channel.js +0 -154
- package/dist/src/channels/A-Http/A-Http.channel.js.map +0 -1
- package/dist/src/channels/A-Http/A-Http.channel.types.d.ts +0 -59
- package/dist/src/channels/A-Http/A-Http.channel.types.js +0 -3
- package/dist/src/channels/A-Http/A-Http.channel.types.js.map +0 -1
- package/dist/src/channels/A-Websockets/A-Websockets.channel.d.ts +0 -4
- package/dist/src/channels/A-Websockets/A-Websockets.channel.js +0 -22
- package/dist/src/channels/A-Websockets/A-Websockets.channel.js.map +0 -1
- package/dist/src/components/A-CommandController/A-CommandController.component.d.ts +0 -8
- package/dist/src/components/A-CommandController/A-CommandController.component.js +0 -55
- package/dist/src/components/A-CommandController/A-CommandController.component.js.map +0 -1
- package/dist/src/components/A-Controller/A-Controller.component.d.ts +0 -9
- package/dist/src/components/A-Controller/A-Controller.component.js +0 -60
- package/dist/src/components/A-Controller/A-Controller.component.js.map +0 -1
- package/dist/src/components/A-Controller/A-Controller.component.types.d.ts +0 -0
- package/dist/src/components/A-Controller/A-Controller.component.types.js +0 -2
- package/dist/src/components/A-Controller/A-Controller.component.types.js.map +0 -1
- package/dist/src/components/A-EntityController/A-EntityController.component.d.ts +0 -26
- package/dist/src/components/A-EntityController/A-EntityController.component.js +0 -226
- package/dist/src/components/A-EntityController/A-EntityController.component.js.map +0 -1
- package/dist/src/components/A-EntityController/A-EntityController.component.types.d.ts +0 -0
- package/dist/src/components/A-EntityController/A-EntityController.component.types.js +0 -2
- package/dist/src/components/A-EntityController/A-EntityController.component.types.js.map +0 -1
- package/dist/src/components/A-EntityRepository/A-EntityRepository.component.d.ts +0 -9
- package/dist/src/components/A-EntityRepository/A-EntityRepository.component.js +0 -118
- package/dist/src/components/A-EntityRepository/A-EntityRepository.component.js.map +0 -1
- package/dist/src/components/A-EntityRepository/A-EntityRepository.error.d.ts +0 -0
- package/dist/src/components/A-EntityRepository/A-EntityRepository.error.js +0 -2
- package/dist/src/components/A-EntityRepository/A-EntityRepository.error.js.map +0 -1
- package/dist/src/components/A-EntityRepository/A-EntityRepository.types.d.ts +0 -0
- package/dist/src/components/A-EntityRepository/A-EntityRepository.types.js +0 -2
- package/dist/src/components/A-EntityRepository/A-EntityRepository.types.js.map +0 -1
- package/dist/src/components/A-ListingController/A-ListingController.component.d.ts +0 -10
- package/dist/src/components/A-ListingController/A-ListingController.component.js +0 -72
- package/dist/src/components/A-ListingController/A-ListingController.component.js.map +0 -1
- package/dist/src/components/A-ListingController/A-ListingController.component.types.d.ts +0 -0
- package/dist/src/components/A-ListingController/A-ListingController.component.types.js +0 -2
- package/dist/src/components/A-ListingController/A-ListingController.component.types.js.map +0 -1
- package/dist/src/components/A-Router/A-Router.component.d.ts +0 -63
- package/dist/src/components/A-Router/A-Router.component.js +0 -221
- package/dist/src/components/A-Router/A-Router.component.js.map +0 -1
- package/dist/src/components/A-Router/A-Router.component.types.d.ts +0 -26
- package/dist/src/components/A-Router/A-Router.component.types.js +0 -17
- package/dist/src/components/A-Router/A-Router.component.types.js.map +0 -1
- package/dist/src/components/A-ServerCORS/A_ServerCORS.component.d.ts +0 -9
- package/dist/src/components/A-ServerCORS/A_ServerCORS.component.defaults.d.ts +0 -2
- package/dist/src/components/A-ServerCORS/A_ServerCORS.component.defaults.js +0 -11
- package/dist/src/components/A-ServerCORS/A_ServerCORS.component.defaults.js.map +0 -1
- package/dist/src/components/A-ServerCORS/A_ServerCORS.component.js +0 -70
- package/dist/src/components/A-ServerCORS/A_ServerCORS.component.js.map +0 -1
- package/dist/src/components/A-ServerCORS/A_ServerCORS.component.types.d.ts +0 -7
- package/dist/src/components/A-ServerCORS/A_ServerCORS.component.types.js +0 -3
- package/dist/src/components/A-ServerCORS/A_ServerCORS.component.types.js.map +0 -1
- package/dist/src/components/A-ServerError/A-ServerError.class.d.ts +0 -7
- package/dist/src/components/A-ServerError/A-ServerError.class.js +0 -88
- package/dist/src/components/A-ServerError/A-ServerError.class.js.map +0 -1
- package/dist/src/components/A-ServerError/A-ServerError.constants.d.ts +0 -0
- package/dist/src/components/A-ServerError/A-ServerError.constants.js +0 -2
- package/dist/src/components/A-ServerError/A-ServerError.constants.js.map +0 -1
- package/dist/src/components/A-ServerError/A-ServerError.types.d.ts +0 -13
- package/dist/src/components/A-ServerError/A-ServerError.types.js +0 -3
- package/dist/src/components/A-ServerError/A-ServerError.types.js.map +0 -1
- package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.d.ts +0 -7
- package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.js +0 -81
- package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.js.map +0 -1
- package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.types.d.ts +0 -0
- package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.types.js +0 -2
- package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.types.js.map +0 -1
- package/dist/src/components/A-ServerLogger/A-ServerLogger.constants.d.ts +0 -22
- package/dist/src/components/A-ServerLogger/A-ServerLogger.constants.js +0 -31
- package/dist/src/components/A-ServerLogger/A-ServerLogger.constants.js.map +0 -1
- package/dist/src/components/A-ServerLogger/A_ServerLogger.component.d.ts +0 -43
- package/dist/src/components/A-ServerLogger/A_ServerLogger.component.js +0 -167
- package/dist/src/components/A-ServerLogger/A_ServerLogger.component.js.map +0 -1
- package/dist/src/components/A-ServerLogger/A_ServerLogger.component.types.d.ts +0 -9
- package/dist/src/components/A-ServerLogger/A_ServerLogger.component.types.js +0 -3
- package/dist/src/components/A-ServerLogger/A_ServerLogger.component.types.js.map +0 -1
- package/dist/src/components/A-ServerProxy/A-ServerProxy.component.d.ts +0 -9
- package/dist/src/components/A-ServerProxy/A-ServerProxy.component.js +0 -88
- package/dist/src/components/A-ServerProxy/A-ServerProxy.component.js.map +0 -1
- package/dist/src/components/A-StaticLoader/A-StaticLoader.component.d.ts +0 -12
- package/dist/src/components/A-StaticLoader/A-StaticLoader.component.js +0 -126
- package/dist/src/components/A-StaticLoader/A-StaticLoader.component.js.map +0 -1
- package/dist/src/components/A-StaticLoader/A-StaticLoader.component.types.d.ts +0 -10
- package/dist/src/components/A-StaticLoader/A-StaticLoader.component.types.js +0 -109
- package/dist/src/components/A-StaticLoader/A-StaticLoader.component.types.js.map +0 -1
- package/dist/src/constants/env.constants.d.ts +0 -10
- package/dist/src/constants/env.constants.js +0 -20
- package/dist/src/constants/env.constants.js.map +0 -1
- package/dist/src/containers/A-Service/A-Service.container.d.ts +0 -30
- package/dist/src/containers/A-Service/A-Service.container.js +0 -200
- package/dist/src/containers/A-Service/A-Service.container.js.map +0 -1
- package/dist/src/containers/A-Service/A-Service.container.types.d.ts +0 -36
- package/dist/src/containers/A-Service/A-Service.container.types.js +0 -27
- package/dist/src/containers/A-Service/A-Service.container.types.js.map +0 -1
- package/dist/src/context/A-EntityFactory/A-EntityFactory.context.d.ts +0 -39
- package/dist/src/context/A-EntityFactory/A-EntityFactory.context.js +0 -69
- package/dist/src/context/A-EntityFactory/A-EntityFactory.context.js.map +0 -1
- package/dist/src/context/A-EntityFactory/A-EntityFactory.context.types.d.ts +0 -5
- package/dist/src/context/A-EntityFactory/A-EntityFactory.context.types.js +0 -3
- package/dist/src/context/A-EntityFactory/A-EntityFactory.context.types.js.map +0 -1
- package/dist/src/context/A-HttpChannel/A-HttpChannel.context.d.ts +0 -12
- package/dist/src/context/A-HttpChannel/A-HttpChannel.context.js +0 -16
- package/dist/src/context/A-HttpChannel/A-HttpChannel.context.js.map +0 -1
- package/dist/src/context/A-ListQueryFilter/A_ListQueryFilter.context.d.ts +0 -10
- package/dist/src/context/A-ListQueryFilter/A_ListQueryFilter.context.js +0 -30
- package/dist/src/context/A-ListQueryFilter/A_ListQueryFilter.context.js.map +0 -1
- package/dist/src/context/A-ProxyConfig/A_ProxyConfig.constants.d.ts +0 -2
- package/dist/src/context/A-ProxyConfig/A_ProxyConfig.constants.js +0 -12
- package/dist/src/context/A-ProxyConfig/A_ProxyConfig.constants.js.map +0 -1
- package/dist/src/context/A-ProxyConfig/A_ProxyConfig.context.d.ts +0 -29
- package/dist/src/context/A-ProxyConfig/A_ProxyConfig.context.js +0 -60
- package/dist/src/context/A-ProxyConfig/A_ProxyConfig.context.js.map +0 -1
- package/dist/src/context/A-ProxyConfig/A_ProxyConfig.types.d.ts +0 -18
- package/dist/src/context/A-ProxyConfig/A_ProxyConfig.types.js +0 -3
- package/dist/src/context/A-ProxyConfig/A_ProxyConfig.types.js.map +0 -1
- package/dist/src/context/A-Server/A_Server.context.d.ts +0 -17
- package/dist/src/context/A-Server/A_Server.context.js +0 -22
- package/dist/src/context/A-Server/A_Server.context.js.map +0 -1
- package/dist/src/context/A-Server/A_Server.context.types.d.ts +0 -7
- package/dist/src/context/A-Server/A_Server.context.types.js +0 -3
- package/dist/src/context/A-Server/A_Server.context.types.js.map +0 -1
- package/dist/src/context/A-StaticConfig/A-StaticConfig.context.d.ts +0 -16
- package/dist/src/context/A-StaticConfig/A-StaticConfig.context.js +0 -28
- package/dist/src/context/A-StaticConfig/A-StaticConfig.context.js.map +0 -1
- package/dist/src/context/A-StaticConfig/A-StaticConfig.context.types.d.ts +0 -0
- package/dist/src/context/A-StaticConfig/A-StaticConfig.context.types.js +0 -2
- package/dist/src/context/A-StaticConfig/A-StaticConfig.context.types.js.map +0 -1
- package/dist/src/entities/A-Request/A-Request.entity.d.ts +0 -31
- package/dist/src/entities/A-Request/A-Request.entity.js +0 -125
- package/dist/src/entities/A-Request/A-Request.entity.js.map +0 -1
- package/dist/src/entities/A-Request/A-Request.entity.types.d.ts +0 -21
- package/dist/src/entities/A-Request/A-Request.entity.types.js +0 -12
- package/dist/src/entities/A-Request/A-Request.entity.types.js.map +0 -1
- package/dist/src/entities/A-Response/A-Response.entity.d.ts +0 -28
- package/dist/src/entities/A-Response/A-Response.entity.js +0 -141
- package/dist/src/entities/A-Response/A-Response.entity.js.map +0 -1
- package/dist/src/entities/A-Response/A-Response.entity.types.d.ts +0 -19
- package/dist/src/entities/A-Response/A-Response.entity.types.js +0 -12
- package/dist/src/entities/A-Response/A-Response.entity.types.js.map +0 -1
- package/dist/src/entities/A-Route/A-Route.entity.d.ts +0 -17
- package/dist/src/entities/A-Route/A-Route.entity.js +0 -76
- package/dist/src/entities/A-Route/A-Route.entity.js.map +0 -1
- package/dist/src/entities/A-Route/A-Route.entity.types.d.ts +0 -0
- package/dist/src/entities/A-Route/A-Route.entity.types.js +0 -2
- package/dist/src/entities/A-Route/A-Route.entity.types.js.map +0 -1
- package/dist/src/entities/A_EntityList/A_EntityList.entity.d.ts +0 -46
- package/dist/src/entities/A_EntityList/A_EntityList.entity.js +0 -91
- package/dist/src/entities/A_EntityList/A_EntityList.entity.js.map +0 -1
- package/dist/src/entities/A_EntityList/A_EntityList.entity.types.d.ts +0 -21
- package/dist/src/entities/A_EntityList/A_EntityList.entity.types.js +0 -8
- package/dist/src/entities/A_EntityList/A_EntityList.entity.types.js.map +0 -1
- package/index.ts +0 -75
- package/tsconfig.build.json +0 -62
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"A-StaticLoader.component.js","sourceRoot":"","sources":["../../../../src/components/A-StaticLoader/A-StaticLoader.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA8E;AAC9E,4CAAoB;AACpB,gDAAwB;AACxB,6BAA0B;AAC1B,0FAAgF;AAChF,6FAAmF;AACnF,8GAA+G;AAC/G,oFAA0E;AAC1E,0GAA+F;AAC/F,4CAA0C;AAG1C,MAAa,cAAe,SAAQ,uBAAW;IAIrC,IAAI,CACc,MAAgB,EACV,MAAsB;;YAEhD,MAAM,CAAC,GAAG,CACN,MAAM,EACN,gCAAgC,EAChC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAChC,CAAC;QACN,CAAC;KAAA;IAGD,0DAA0D;IAC1D,0DAA0D;IAC1D,0DAA0D;IAKpD,SAAS,CACU,GAAc,EACb,GAAe,EACjB,MAAgB,EACV,MAAsB;;YAGhD,IAAI,GAAG,CAAC,MAAM,KAAK,KAAK,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBAChD,OAAO,CAAC,oCAAoC;YAChD,CAAC;YAED,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;YAC5B,MAAM,KAAK,GAAG,IAAI,wBAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAEvC,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,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CAAC;YACP,CAAC;iBAAM,CAAC;gBACJ,MAAM,CAAC,IAAI,KAAK,CAAC,mBAAmB,QAAQ,EAAE,CAAC,CAAC,CAAC;YACrD,CAAC;YAGD,OAAO,EAAE,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC;CAEJ;AAtHD,wCAsHC;AAlHS;IADL,qBAAS,CAAC,IAAI,EAAE;IAEZ,WAAA,IAAA,oBAAQ,EAAC,kBAAQ,CAAC,CAAA;IAClB,WAAA,IAAA,oBAAQ,EAAC,uCAAc,CAAC,CAAA;0CAO5B;AAUK;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,kBAAQ,CAAC,CAAA;IAClB,WAAA,IAAA,oBAAQ,EAAC,uCAAc,CAAC,CAAA;+CAwB5B"}
|
|
@@ -1,10 +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_Logger } from "@adaas/a-utils";
|
|
5
|
-
export declare class A_StaticLoader extends A_Component {
|
|
6
|
-
onRequest(req: A_Request, res: A_Response, logger: A_Logger): Promise<void>;
|
|
7
|
-
protected getMimeType(ext: string): string;
|
|
8
|
-
protected safeFilePath(staticDir: string, reqUrl: string, host?: string): string;
|
|
9
|
-
protected serveFile(filePath: string, res: A_Response): Promise<void>;
|
|
10
|
-
}
|
|
@@ -1,109 +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_utils_1 = require("@adaas/a-utils");
|
|
33
|
-
class A_StaticLoader extends a_concept_1.A_Component {
|
|
34
|
-
// =======================================================
|
|
35
|
-
// ================ Method Definition=====================
|
|
36
|
-
// =======================================================
|
|
37
|
-
onRequest(req, res, logger) {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
|
40
|
-
return; // Only handle GET and HEAD requests
|
|
41
|
-
}
|
|
42
|
-
const staticDir = path_1.default.resolve(process.cwd(), 'public');
|
|
43
|
-
if (!fs_1.default.existsSync(staticDir) || !fs_1.default.statSync(staticDir).isDirectory()) {
|
|
44
|
-
logger.log("red", `Static directory ${staticDir} does not exist or is not a directory.`);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const filePath = this.safeFilePath(staticDir, req.url || "/", req.headers.host);
|
|
48
|
-
yield this.serveFile(filePath, res);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
getMimeType(ext) {
|
|
52
|
-
const mimeTypes = {
|
|
53
|
-
".html": "text/html",
|
|
54
|
-
".js": "application/javascript",
|
|
55
|
-
".css": "text/css",
|
|
56
|
-
".json": "application/json",
|
|
57
|
-
".png": "image/png",
|
|
58
|
-
".jpg": "image/jpeg",
|
|
59
|
-
".jpeg": "image/jpeg",
|
|
60
|
-
".gif": "image/gif",
|
|
61
|
-
".svg": "image/svg+xml",
|
|
62
|
-
".ico": "image/x-icon",
|
|
63
|
-
".txt": "text/plain",
|
|
64
|
-
};
|
|
65
|
-
return mimeTypes[ext.toLowerCase()] || "application/octet-stream";
|
|
66
|
-
}
|
|
67
|
-
safeFilePath(staticDir, reqUrl, host) {
|
|
68
|
-
const parsedUrl = new url_1.URL(reqUrl || "/", `http://${host || "localhost"}`);
|
|
69
|
-
let pathname = decodeURIComponent(parsedUrl.pathname);
|
|
70
|
-
// Prevent path traversal attacks
|
|
71
|
-
pathname = pathname.replace(/\.\.[\/\\]/g, "");
|
|
72
|
-
let filePath = path_1.default.join(staticDir, pathname);
|
|
73
|
-
if (fs_1.default.existsSync(filePath) && fs_1.default.statSync(filePath).isDirectory()) {
|
|
74
|
-
filePath = path_1.default.join(filePath, "index.html");
|
|
75
|
-
}
|
|
76
|
-
return filePath;
|
|
77
|
-
}
|
|
78
|
-
serveFile(filePath, res) {
|
|
79
|
-
return new Promise((resolve, reject) => {
|
|
80
|
-
if (fs_1.default.existsSync(filePath)) {
|
|
81
|
-
const ext = path_1.default.extname(filePath);
|
|
82
|
-
const contentType = this.getMimeType(ext);
|
|
83
|
-
res.writeHead(200, { "Content-Type": contentType });
|
|
84
|
-
const stream = fs_1.default.createReadStream(filePath);
|
|
85
|
-
stream.pipe(res.original);
|
|
86
|
-
stream.on('end', () => {
|
|
87
|
-
resolve();
|
|
88
|
-
});
|
|
89
|
-
stream.on("error", (err) => {
|
|
90
|
-
reject(new Error(`File stream error: ${err.message}`));
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
reject(new Error(`File not found: ${filePath}`));
|
|
95
|
-
}
|
|
96
|
-
resolve();
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
exports.A_StaticLoader = A_StaticLoader;
|
|
101
|
-
__decorate([
|
|
102
|
-
a_concept_1.A_Feature.Extend({
|
|
103
|
-
name: A_Service_container_types_1.A_SERVER_TYPES__ServerFeature.onRequest,
|
|
104
|
-
}),
|
|
105
|
-
__param(0, (0, a_concept_1.A_Inject)(A_Request_entity_1.A_Request)),
|
|
106
|
-
__param(1, (0, a_concept_1.A_Inject)(A_Response_entity_1.A_Response)),
|
|
107
|
-
__param(2, (0, a_concept_1.A_Inject)(a_utils_1.A_Logger))
|
|
108
|
-
], A_StaticLoader.prototype, "onRequest", null);
|
|
109
|
-
//# sourceMappingURL=A-StaticLoader.component.types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"A-StaticLoader.component.types.js","sourceRoot":"","sources":["../../../../src/components/A-StaticLoader/A-StaticLoader.component.types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAmE;AACnE,4CAAoB;AACpB,gDAAwB;AACxB,6BAA0B;AAC1B,0FAAgF;AAChF,6FAAmF;AACnF,8GAA+G;AAC/G,4CAA0C;AAG1C,MAAa,cAAe,SAAQ,uBAAW;IAE3C,0DAA0D;IAC1D,0DAA0D;IAC1D,0DAA0D;IAKpD,SAAS,CACU,GAAc,EACb,GAAe,EACjB,MAAgB;;YAGpC,IAAI,GAAG,CAAC,MAAM,KAAK,KAAK,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBAChD,OAAO,CAAC,oCAAoC;YAChD,CAAC;YAED,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;YAExD,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,YAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;gBACrE,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,oBAAoB,SAAS,wCAAwC,CAAC,CAAC;gBACzF,OAAO;YACX,CAAC;YAED,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAEhF,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QACxC,CAAC;KAAA;IAIS,WAAW,CAAC,GAAW;QAC7B,MAAM,SAAS,GAA2B;YACtC,OAAO,EAAE,WAAW;YACpB,KAAK,EAAE,wBAAwB;YAC/B,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,kBAAkB;YAC3B,MAAM,EAAE,WAAW;YACnB,MAAM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AAE,cAAc,EAAE,WAAW,EAAE,CAAC,CAAC;gBACpD,MAAM,MAAM,GAAG,YAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;gBAC7C,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAE1B,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;oBAClB,OAAO,EAAE,CAAC;gBACd,CAAC,CAAC,CAAC;gBAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;oBACvB,MAAM,CAAC,IAAI,KAAK,CAAC,sBAAsB,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;gBAC3D,CAAC,CAAC,CAAC;YACP,CAAC;iBAAM,CAAC;gBACJ,MAAM,CAAC,IAAI,KAAK,CAAC,mBAAmB,QAAQ,EAAE,CAAC,CAAC,CAAC;YACrD,CAAC;YAGD,OAAO,EAAE,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC;CAEJ;AAjGD,wCAiGC;AAxFS;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,kBAAQ,CAAC,CAAA;+CAiBtB"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES: {
|
|
2
|
-
/**
|
|
3
|
-
* Port for the server to listen on
|
|
4
|
-
* [!] Default is 3000
|
|
5
|
-
* @default 3000
|
|
6
|
-
*/
|
|
7
|
-
readonly A_SERVER_PORT: "A_SERVER_PORT";
|
|
8
|
-
};
|
|
9
|
-
export type A_TYPES__ServerENVVariables = (typeof A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES)[keyof typeof A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES][];
|
|
10
|
-
export declare const A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY: readonly ["A_SERVER_PORT"];
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY = exports.A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES = void 0;
|
|
4
|
-
exports.A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES = {
|
|
5
|
-
// ----------------------------------------------------------
|
|
6
|
-
// A-Server Environment Variables
|
|
7
|
-
// ----------------------------------------------------------
|
|
8
|
-
// These environment variables are used by A-Server to configure the application
|
|
9
|
-
// ----------------------------------------------------------
|
|
10
|
-
/**
|
|
11
|
-
* Port for the server to listen on
|
|
12
|
-
* [!] Default is 3000
|
|
13
|
-
* @default 3000
|
|
14
|
-
*/
|
|
15
|
-
A_SERVER_PORT: 'A_SERVER_PORT',
|
|
16
|
-
};
|
|
17
|
-
exports.A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY = [
|
|
18
|
-
exports.A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES.A_SERVER_PORT,
|
|
19
|
-
];
|
|
20
|
-
//# sourceMappingURL=env.constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env.constants.js","sourceRoot":"","sources":["../../../src/constants/env.constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,yCAAyC,GAAG;IACrD,6DAA6D;IAC7D,iCAAiC;IACjC,6DAA6D;IAC7D,gFAAgF;IAChF,6DAA6D;IAC7D;;;;OAIG;IACH,aAAa,EAAE,eAAe;CAExB,CAAC;AAME,QAAA,+CAA+C,GAAG;IAC3D,iDAAyC,CAAC,aAAa;CACjD,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { IncomingMessage, ServerResponse } from "http";
|
|
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_Container, A_Scope } from "@adaas/a-concept";
|
|
5
|
-
/**
|
|
6
|
-
* A-Service is a container that can run different types of services, such as HTTP servers, workers, etc.
|
|
7
|
-
* Depending on the provided config and configuration, it will load the necessary components and start the service.
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
export declare class A_Service extends A_Container {
|
|
11
|
-
private server;
|
|
12
|
-
port: number;
|
|
13
|
-
load(): Promise<void>;
|
|
14
|
-
protected listen(): Promise<void>;
|
|
15
|
-
protected close(): Promise<void>;
|
|
16
|
-
start(): Promise<void>;
|
|
17
|
-
beforeStart(): Promise<void>;
|
|
18
|
-
afterStart(): Promise<void>;
|
|
19
|
-
stop(): Promise<void>;
|
|
20
|
-
beforeRequest(scope: A_Scope): Promise<void>;
|
|
21
|
-
afterRequest(scope: A_Scope): Promise<void>;
|
|
22
|
-
onRequest(request: IncomingMessage, response: ServerResponse): Promise<void>;
|
|
23
|
-
protected convertToAServer(request: IncomingMessage, response: ServerResponse): Promise<{
|
|
24
|
-
req: A_Request;
|
|
25
|
-
res: A_Response;
|
|
26
|
-
}>;
|
|
27
|
-
protected generateRequestId(method: string, url: string): string;
|
|
28
|
-
beforeStop(): Promise<void>;
|
|
29
|
-
afterStop(): Promise<void>;
|
|
30
|
-
}
|
|
@@ -1,200 +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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.A_Service = void 0;
|
|
22
|
-
const http_1 = require("http");
|
|
23
|
-
const A_Service_container_types_1 = require("./A-Service.container.types");
|
|
24
|
-
const A_Server_context_1 = require("../../context/A-Server/A_Server.context");
|
|
25
|
-
const A_Request_entity_1 = require("../../entities/A-Request/A-Request.entity");
|
|
26
|
-
const A_Response_entity_1 = require("../../entities/A-Response/A-Response.entity");
|
|
27
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
28
|
-
const env_constants_1 = require("../../constants/env.constants");
|
|
29
|
-
const a_concept_1 = require("@adaas/a-concept");
|
|
30
|
-
const a_utils_1 = require("@adaas/a-utils");
|
|
31
|
-
/**
|
|
32
|
-
* A-Service is a container that can run different types of services, such as HTTP servers, workers, etc.
|
|
33
|
-
* Depending on the provided config and configuration, it will load the necessary components and start the service.
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
class A_Service extends a_concept_1.A_Container {
|
|
37
|
-
load() {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
let config;
|
|
40
|
-
let aServer;
|
|
41
|
-
if (!this.scope.has((a_utils_1.A_Config))) {
|
|
42
|
-
const config = new a_utils_1.A_Config({
|
|
43
|
-
variables: [...Array.from(env_constants_1.A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY)],
|
|
44
|
-
defaults: {
|
|
45
|
-
A_SERVER_PORT: 3000
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
this.scope.register(config);
|
|
49
|
-
}
|
|
50
|
-
config = this.scope.resolve(a_utils_1.A_Config);
|
|
51
|
-
if (!this.scope.has(A_Server_context_1.A_Server)) {
|
|
52
|
-
aServer = new A_Server_context_1.A_Server({
|
|
53
|
-
port: config.get('A_SERVER_PORT'),
|
|
54
|
-
name: this.name,
|
|
55
|
-
version: 'v1'
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
// Set the server to listen on port 3000
|
|
59
|
-
this.port = config.get('A_SERVER_PORT');
|
|
60
|
-
// Create the HTTP server
|
|
61
|
-
this.server = (0, http_1.createServer)(this.onRequest.bind(this));
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
listen() {
|
|
65
|
-
return new Promise((resolve, reject) => {
|
|
66
|
-
this.server.listen(this.port, () => {
|
|
67
|
-
resolve();
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
close() {
|
|
72
|
-
return new Promise((resolve, reject) => {
|
|
73
|
-
this.server.close(() => {
|
|
74
|
-
resolve();
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
start() {
|
|
79
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
yield this.beforeStart();
|
|
81
|
-
yield this.listen();
|
|
82
|
-
yield this.afterStart();
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
beforeStart() {
|
|
86
|
-
return __awaiter(this, void 0, void 0, function* () { });
|
|
87
|
-
}
|
|
88
|
-
afterStart() {
|
|
89
|
-
return __awaiter(this, void 0, void 0, function* () { });
|
|
90
|
-
}
|
|
91
|
-
stop() {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
yield this.call(A_Service_container_types_1.A_SERVER_TYPES__ServerFeature.beforeStop);
|
|
94
|
-
yield this.server.close();
|
|
95
|
-
yield this.call(A_Service_container_types_1.A_SERVER_TYPES__ServerFeature.afterStop);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
beforeRequest(scope) {
|
|
99
|
-
return __awaiter(this, void 0, void 0, function* () { });
|
|
100
|
-
}
|
|
101
|
-
afterRequest(scope) {
|
|
102
|
-
return __awaiter(this, void 0, void 0, function* () { });
|
|
103
|
-
}
|
|
104
|
-
onRequest(request, response) {
|
|
105
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
const scope = new a_concept_1.A_Scope({
|
|
107
|
-
name: `a-server-request::${Date.now()}`,
|
|
108
|
-
});
|
|
109
|
-
// We need it to stop feature execution in case request ends
|
|
110
|
-
const { req, res } = yield this.convertToAServer(request, response);
|
|
111
|
-
try {
|
|
112
|
-
scope.register(req);
|
|
113
|
-
scope.register(res);
|
|
114
|
-
scope.inherit(this.scope);
|
|
115
|
-
yield this.beforeRequest(scope);
|
|
116
|
-
yield this.call(A_Service_container_types_1.A_SERVER_TYPES__ServerFeature.onRequest, scope);
|
|
117
|
-
yield this.afterRequest(scope);
|
|
118
|
-
yield res.status(200).send();
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
const logger = this.scope.resolve(a_utils_1.A_Logger);
|
|
122
|
-
logger.error(error);
|
|
123
|
-
return res.failed(error);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
convertToAServer(request, response) {
|
|
128
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
-
if (!request.method || !request.url)
|
|
130
|
-
throw new Error('Request method or url is missing');
|
|
131
|
-
const id = this.generateRequestId(request.method, request.url);
|
|
132
|
-
const req = new A_Request_entity_1.A_Request({ id, request, scope: this.scope.name });
|
|
133
|
-
const res = new A_Response_entity_1.A_Response({ id, response, scope: this.scope.name });
|
|
134
|
-
yield req.init();
|
|
135
|
-
yield res.init();
|
|
136
|
-
return { req, res };
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
generateRequestId(method, url) {
|
|
140
|
-
// Use the current time, request URL, and a few other details to create a unique ID
|
|
141
|
-
const hash = crypto_1.default.createHash('sha256');
|
|
142
|
-
const timeId = a_concept_1.A_IdentityHelper.generateTimeId();
|
|
143
|
-
const randomValue = Math.random().toString(); // Adds extra randomness
|
|
144
|
-
hash.update(`${timeId}-${method}-${url}-${randomValue}`);
|
|
145
|
-
return `${timeId}-${hash.digest('hex')}`;
|
|
146
|
-
}
|
|
147
|
-
beforeStop() {
|
|
148
|
-
return __awaiter(this, void 0, void 0, function* () { });
|
|
149
|
-
}
|
|
150
|
-
afterStop() {
|
|
151
|
-
return __awaiter(this, void 0, void 0, function* () { });
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
exports.A_Service = A_Service;
|
|
155
|
-
__decorate([
|
|
156
|
-
a_concept_1.A_Concept.Load()
|
|
157
|
-
], A_Service.prototype, "load", null);
|
|
158
|
-
__decorate([
|
|
159
|
-
a_concept_1.A_Concept.Start()
|
|
160
|
-
/**
|
|
161
|
-
* Start the server
|
|
162
|
-
*/
|
|
163
|
-
], A_Service.prototype, "start", null);
|
|
164
|
-
__decorate([
|
|
165
|
-
a_concept_1.A_Feature.Define({ invoke: true })
|
|
166
|
-
], A_Service.prototype, "beforeStart", null);
|
|
167
|
-
__decorate([
|
|
168
|
-
a_concept_1.A_Feature.Define({ invoke: true })
|
|
169
|
-
], A_Service.prototype, "afterStart", null);
|
|
170
|
-
__decorate([
|
|
171
|
-
a_concept_1.A_Concept.Stop()
|
|
172
|
-
/**
|
|
173
|
-
* Stop service
|
|
174
|
-
*/
|
|
175
|
-
], A_Service.prototype, "stop", null);
|
|
176
|
-
__decorate([
|
|
177
|
-
a_concept_1.A_Feature.Define({
|
|
178
|
-
name: A_Service_container_types_1.A_SERVER_TYPES__ServerFeature.beforeRequest,
|
|
179
|
-
invoke: true
|
|
180
|
-
})
|
|
181
|
-
], A_Service.prototype, "beforeRequest", null);
|
|
182
|
-
__decorate([
|
|
183
|
-
a_concept_1.A_Feature.Define({
|
|
184
|
-
name: A_Service_container_types_1.A_SERVER_TYPES__ServerFeature.beforeRequest,
|
|
185
|
-
invoke: true
|
|
186
|
-
})
|
|
187
|
-
], A_Service.prototype, "afterRequest", null);
|
|
188
|
-
__decorate([
|
|
189
|
-
a_concept_1.A_Feature.Define({
|
|
190
|
-
name: A_Service_container_types_1.A_SERVER_TYPES__ServerFeature.onRequest,
|
|
191
|
-
invoke: false
|
|
192
|
-
})
|
|
193
|
-
], A_Service.prototype, "onRequest", null);
|
|
194
|
-
__decorate([
|
|
195
|
-
a_concept_1.A_Feature.Define({ invoke: true })
|
|
196
|
-
], A_Service.prototype, "beforeStop", null);
|
|
197
|
-
__decorate([
|
|
198
|
-
a_concept_1.A_Feature.Define({ invoke: true })
|
|
199
|
-
], A_Service.prototype, "afterStop", null);
|
|
200
|
-
//# sourceMappingURL=A-Service.container.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"A-Service.container.js","sourceRoot":"","sources":["../../../../src/containers/A-Service/A-Service.container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,+BAA6E;AAC7E,2EAA4G;AAC5G,wFAA6E;AAC7E,0FAAgF;AAChF,6FAAmF;AACnF,oDAA4B;AAC5B,2EAAuI;AACvI,gDAAgG;AAChG,4CAAoD;AAKpD;;;;GAIG;AACH,MAAa,SAAU,SAAQ,uBAAW;IAMhC,IAAI;;YAEN,IAAI,MAA6C,CAAC;YAClD,IAAI,OAAiB,CAAC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,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;0CACd"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { A_Component, A_Fragment } from "@adaas/a-concept";
|
|
2
|
-
export type A_SERVER_TYPES__ServerFeatures = [
|
|
3
|
-
A_SERVER_TYPES__ServerFeature.beforeStart,
|
|
4
|
-
A_SERVER_TYPES__ServerFeature.afterStart,
|
|
5
|
-
A_SERVER_TYPES__ServerFeature.beforeStop,
|
|
6
|
-
A_SERVER_TYPES__ServerFeature.afterStop,
|
|
7
|
-
A_SERVER_TYPES__ServerFeature.onRequest
|
|
8
|
-
];
|
|
9
|
-
export declare enum A_SERVER_TYPES__ServerFeature {
|
|
10
|
-
beforeStart = "beforeStart",
|
|
11
|
-
afterStart = "afterStart",
|
|
12
|
-
beforeStop = "beforeStop",
|
|
13
|
-
afterStop = "afterStop",
|
|
14
|
-
beforeRequest = "beforeRequest",
|
|
15
|
-
onRequest = "onRequest",
|
|
16
|
-
afterRequest = "afterRequest"
|
|
17
|
-
}
|
|
18
|
-
export type A_SERVER_TYPES__ServerConstructor = {
|
|
19
|
-
name: string;
|
|
20
|
-
version: string;
|
|
21
|
-
controllers: Array<A_Component>;
|
|
22
|
-
entities: Array<A_Fragment>;
|
|
23
|
-
extensions: Array<A_Component>;
|
|
24
|
-
};
|
|
25
|
-
export declare enum A_SERVER_TYPES__ServerMethod {
|
|
26
|
-
GET = "GET",
|
|
27
|
-
POST = "POST",
|
|
28
|
-
PUT = "PUT",
|
|
29
|
-
DELETE = "DELETE",
|
|
30
|
-
PATCH = "PATCH",
|
|
31
|
-
OPTIONS = "OPTIONS",
|
|
32
|
-
HEAD = "HEAD",
|
|
33
|
-
CONNECT = "CONNECT",
|
|
34
|
-
TRACE = "TRACE",
|
|
35
|
-
DEFAULT = "DEFAULT"
|
|
36
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.A_SERVER_TYPES__ServerMethod = exports.A_SERVER_TYPES__ServerFeature = void 0;
|
|
4
|
-
var A_SERVER_TYPES__ServerFeature;
|
|
5
|
-
(function (A_SERVER_TYPES__ServerFeature) {
|
|
6
|
-
A_SERVER_TYPES__ServerFeature["beforeStart"] = "beforeStart";
|
|
7
|
-
A_SERVER_TYPES__ServerFeature["afterStart"] = "afterStart";
|
|
8
|
-
A_SERVER_TYPES__ServerFeature["beforeStop"] = "beforeStop";
|
|
9
|
-
A_SERVER_TYPES__ServerFeature["afterStop"] = "afterStop";
|
|
10
|
-
A_SERVER_TYPES__ServerFeature["beforeRequest"] = "beforeRequest";
|
|
11
|
-
A_SERVER_TYPES__ServerFeature["onRequest"] = "onRequest";
|
|
12
|
-
A_SERVER_TYPES__ServerFeature["afterRequest"] = "afterRequest";
|
|
13
|
-
})(A_SERVER_TYPES__ServerFeature || (exports.A_SERVER_TYPES__ServerFeature = A_SERVER_TYPES__ServerFeature = {}));
|
|
14
|
-
var A_SERVER_TYPES__ServerMethod;
|
|
15
|
-
(function (A_SERVER_TYPES__ServerMethod) {
|
|
16
|
-
A_SERVER_TYPES__ServerMethod["GET"] = "GET";
|
|
17
|
-
A_SERVER_TYPES__ServerMethod["POST"] = "POST";
|
|
18
|
-
A_SERVER_TYPES__ServerMethod["PUT"] = "PUT";
|
|
19
|
-
A_SERVER_TYPES__ServerMethod["DELETE"] = "DELETE";
|
|
20
|
-
A_SERVER_TYPES__ServerMethod["PATCH"] = "PATCH";
|
|
21
|
-
A_SERVER_TYPES__ServerMethod["OPTIONS"] = "OPTIONS";
|
|
22
|
-
A_SERVER_TYPES__ServerMethod["HEAD"] = "HEAD";
|
|
23
|
-
A_SERVER_TYPES__ServerMethod["CONNECT"] = "CONNECT";
|
|
24
|
-
A_SERVER_TYPES__ServerMethod["TRACE"] = "TRACE";
|
|
25
|
-
A_SERVER_TYPES__ServerMethod["DEFAULT"] = "DEFAULT";
|
|
26
|
-
})(A_SERVER_TYPES__ServerMethod || (exports.A_SERVER_TYPES__ServerMethod = A_SERVER_TYPES__ServerMethod = {}));
|
|
27
|
-
//# sourceMappingURL=A-Service.container.types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"A-Service.container.types.js","sourceRoot":"","sources":["../../../../src/containers/A-Service/A-Service.container.types.ts"],"names":[],"mappings":";;;AAWA,IAAY,6BAQX;AARD,WAAY,6BAA6B;IACrC,4DAA2B,CAAA;IAC3B,0DAAyB,CAAA;IACzB,0DAAyB,CAAA;IACzB,wDAAuB,CAAA;IACvB,gEAA+B,CAAA;IAC/B,wDAAuB,CAAA;IACvB,8DAA6B,CAAA;AACjC,CAAC,EARW,6BAA6B,6CAA7B,6BAA6B,QAQxC;AAaD,IAAY,4BAWX;AAXD,WAAY,4BAA4B;IACpC,2CAAW,CAAA;IACX,6CAAa,CAAA;IACb,2CAAW,CAAA;IACX,iDAAiB,CAAA;IACjB,+CAAe,CAAA;IACf,mDAAmB,CAAA;IACnB,6CAAa,CAAA;IACb,mDAAmB,CAAA;IACnB,+CAAe,CAAA;IACf,mDAAmB,CAAA;AACvB,CAAC,EAXW,4BAA4B,4CAA5B,4BAA4B,QAWvC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { A_Entity, A_Fragment, ASEID } from "@adaas/a-concept";
|
|
2
|
-
import { A_SERVER_TYPES__AEntityFactoryConstructor1, A_SERVER_TYPES__AEntityFactoryConstructor2 } from "./A-EntityFactory.context.types";
|
|
3
|
-
export declare class A_EntityFactory extends A_Fragment {
|
|
4
|
-
private _entities;
|
|
5
|
-
constructor(map: A_SERVER_TYPES__AEntityFactoryConstructor1);
|
|
6
|
-
constructor(entities: A_SERVER_TYPES__AEntityFactoryConstructor2);
|
|
7
|
-
constructor(map: A_SERVER_TYPES__AEntityFactoryConstructor1, entities: A_SERVER_TYPES__AEntityFactoryConstructor2);
|
|
8
|
-
protected _setEntities(entities?: A_SERVER_TYPES__AEntityFactoryConstructor2 | A_SERVER_TYPES__AEntityFactoryConstructor1): void;
|
|
9
|
-
add(key: string, entity: typeof A_Entity): void;
|
|
10
|
-
add(entity: typeof A_Entity): void;
|
|
11
|
-
has(aseid: ASEID): boolean;
|
|
12
|
-
has(
|
|
13
|
-
/**
|
|
14
|
-
* The name of the entity
|
|
15
|
-
*/
|
|
16
|
-
entity: string): boolean;
|
|
17
|
-
has(
|
|
18
|
-
/**
|
|
19
|
-
* The ASEID of the entity
|
|
20
|
-
*/
|
|
21
|
-
aseid: string): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Resolves the entity constructor by the entity name
|
|
24
|
-
*
|
|
25
|
-
* @param entity
|
|
26
|
-
*/
|
|
27
|
-
resolve(entity: string): {
|
|
28
|
-
new (...args: any[]): A_Entity;
|
|
29
|
-
} | undefined;
|
|
30
|
-
resolve(aseid: string): {
|
|
31
|
-
new (...args: any[]): A_Entity;
|
|
32
|
-
} | undefined;
|
|
33
|
-
resolve(aseid: ASEID): {
|
|
34
|
-
new (...args: any[]): A_Entity;
|
|
35
|
-
} | undefined;
|
|
36
|
-
resolveByName(name: string): {
|
|
37
|
-
new (...args: any[]): A_Entity;
|
|
38
|
-
} | undefined;
|
|
39
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.A_EntityFactory = void 0;
|
|
4
|
-
const a_concept_1 = require("@adaas/a-concept");
|
|
5
|
-
class A_EntityFactory extends a_concept_1.A_Fragment {
|
|
6
|
-
constructor(param1, param2) {
|
|
7
|
-
super();
|
|
8
|
-
this._entities = new Map();
|
|
9
|
-
this._setEntities(param1);
|
|
10
|
-
this._setEntities(param2);
|
|
11
|
-
}
|
|
12
|
-
_setEntities(entities = []) {
|
|
13
|
-
if (Array.isArray(entities)) {
|
|
14
|
-
entities.forEach((entity) => {
|
|
15
|
-
this._entities.set(entity.entity, entity);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
Object.keys(entities).forEach((key) => {
|
|
20
|
-
this._entities.set(key, entities[key]);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
add(param1, param2) {
|
|
25
|
-
switch (true) {
|
|
26
|
-
case typeof param1 === 'string' && !!param2:
|
|
27
|
-
this._entities.set(param1, param2);
|
|
28
|
-
break;
|
|
29
|
-
case typeof param1 !== 'string':
|
|
30
|
-
this._entities.set(param1.entity, param1);
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
has(param1) {
|
|
35
|
-
let name;
|
|
36
|
-
switch (true) {
|
|
37
|
-
case param1 instanceof a_concept_1.ASEID:
|
|
38
|
-
name = param1.entity;
|
|
39
|
-
break;
|
|
40
|
-
case !(param1 instanceof a_concept_1.ASEID) && a_concept_1.ASEID.isASEID(param1):
|
|
41
|
-
name = new a_concept_1.ASEID(param1).entity;
|
|
42
|
-
break;
|
|
43
|
-
default:
|
|
44
|
-
name = param1;
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
return this._entities.has(name);
|
|
48
|
-
}
|
|
49
|
-
resolve(param1) {
|
|
50
|
-
let name;
|
|
51
|
-
switch (true) {
|
|
52
|
-
case param1 instanceof a_concept_1.ASEID:
|
|
53
|
-
name = param1.entity;
|
|
54
|
-
break;
|
|
55
|
-
case typeof param1 === 'string' && a_concept_1.ASEID.isASEID(param1):
|
|
56
|
-
name = new a_concept_1.ASEID(param1).entity;
|
|
57
|
-
break;
|
|
58
|
-
default:
|
|
59
|
-
name = param1;
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
return this._entities.get(name);
|
|
63
|
-
}
|
|
64
|
-
resolveByName(name) {
|
|
65
|
-
return this._entities.get(name);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
exports.A_EntityFactory = A_EntityFactory;
|
|
69
|
-
//# sourceMappingURL=A-EntityFactory.context.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A-EntityFactory/A-EntityFactory.context.types.ts"],"names":[],"mappings":""}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { A_Fragment } from "@adaas/a-concept";
|
|
2
|
-
import { A_SERVER_TYPES__ServerMethod } from "../../containers/A-Service/A-Service.container.types";
|
|
3
|
-
import { A_SERVER_TYPES__HttpChannelRequestParams } from "../../channels/A-Http/A-Http.channel.types";
|
|
4
|
-
export declare class A_HTTPChannel_RequestContext<T extends any = any> extends A_Fragment {
|
|
5
|
-
url: string;
|
|
6
|
-
method: A_SERVER_TYPES__ServerMethod;
|
|
7
|
-
data?: any;
|
|
8
|
-
config?: Partial<A_SERVER_TYPES__HttpChannelRequestParams['config']>;
|
|
9
|
-
constructor(params: A_SERVER_TYPES__HttpChannelRequestParams);
|
|
10
|
-
result?: T;
|
|
11
|
-
error?: any;
|
|
12
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.A_HTTPChannel_RequestContext = void 0;
|
|
4
|
-
const a_concept_1 = require("@adaas/a-concept");
|
|
5
|
-
class A_HTTPChannel_RequestContext extends a_concept_1.A_Fragment {
|
|
6
|
-
constructor(params) {
|
|
7
|
-
super();
|
|
8
|
-
const { method, url, data, config, } = params;
|
|
9
|
-
this.url = url;
|
|
10
|
-
this.method = method;
|
|
11
|
-
this.data = data;
|
|
12
|
-
this.config = config;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.A_HTTPChannel_RequestContext = A_HTTPChannel_RequestContext;
|
|
16
|
-
//# sourceMappingURL=A-HttpChannel.context.js.map
|