@adaas/a-server 0.0.20 → 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 +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- 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/tsconfig.build.json +0 -28
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { A_Concept,
|
|
2
|
-
import { A_Config, A_Logger, A_Channel, A_Manifest } from '@adaas/a-utils';
|
|
3
|
-
import http, { createServer } from 'http';
|
|
1
|
+
import { A_Concept, A_Inject, A_Feature, A_Scope, A_Container, A_Caller, A_Error, A_Entity, ASEID, A_Context, A_IdentityHelper, A_Fragment, A_Component, A_Feature_Define, A_Feature_Extend, A_TypeGuards } from '@adaas/a-concept';
|
|
2
|
+
import { A_Polyfill, A_Config, A_Logger, A_Channel, A_Manifest } from '@adaas/a-utils';
|
|
4
3
|
import crypto from 'crypto';
|
|
5
|
-
import https from 'https';
|
|
6
4
|
import fs from 'fs';
|
|
7
5
|
import path from 'path';
|
|
8
6
|
import { URL as URL$1 } from 'url';
|
|
@@ -606,7 +604,7 @@ var A_Response = class extends A_Entity {
|
|
|
606
604
|
}
|
|
607
605
|
};
|
|
608
606
|
var A_Service = class extends A_Container {
|
|
609
|
-
async load() {
|
|
607
|
+
async load(polyfill) {
|
|
610
608
|
let config;
|
|
611
609
|
if (!this.scope.has(A_Config)) {
|
|
612
610
|
const config2 = new A_Config({
|
|
@@ -626,7 +624,8 @@ var A_Service = class extends A_Container {
|
|
|
626
624
|
});
|
|
627
625
|
}
|
|
628
626
|
this.port = config.get("A_SERVER_PORT");
|
|
629
|
-
|
|
627
|
+
const http = await polyfill.http();
|
|
628
|
+
this.server = http.createServer(this.onRequest.bind(this));
|
|
630
629
|
}
|
|
631
630
|
listen() {
|
|
632
631
|
return new Promise((resolve, reject) => {
|
|
@@ -708,7 +707,8 @@ var A_Service = class extends A_Container {
|
|
|
708
707
|
}
|
|
709
708
|
};
|
|
710
709
|
__decorateClass([
|
|
711
|
-
A_Concept.Load()
|
|
710
|
+
A_Concept.Load(),
|
|
711
|
+
__decorateParam(0, A_Inject(A_Polyfill))
|
|
712
712
|
], A_Service.prototype, "load");
|
|
713
713
|
__decorateClass([
|
|
714
714
|
A_Concept.Start()
|
|
@@ -1513,8 +1513,8 @@ var A_ServerProxy = class extends A_Component {
|
|
|
1513
1513
|
config.configs.map((c) => c.route).join("\n")
|
|
1514
1514
|
);
|
|
1515
1515
|
}
|
|
1516
|
-
async onRequest(req, res, proxyConfig, logger) {
|
|
1517
|
-
return new Promise((resolve, reject) => {
|
|
1516
|
+
async onRequest(req, res, proxyConfig, logger, polyfill) {
|
|
1517
|
+
return new Promise(async (resolve, reject) => {
|
|
1518
1518
|
const { method, url } = req;
|
|
1519
1519
|
const route = new A_Route(url, method);
|
|
1520
1520
|
const config = proxyConfig.config(route.toString());
|
|
@@ -1526,7 +1526,7 @@ var A_ServerProxy = class extends A_Component {
|
|
|
1526
1526
|
`Proxying request ${method} ${url} to ${config.hostname}`,
|
|
1527
1527
|
config
|
|
1528
1528
|
);
|
|
1529
|
-
const client = config.protocol === "https:" ? https : http;
|
|
1529
|
+
const client = await (config.protocol === "https:" ? polyfill.https() : polyfill.http());
|
|
1530
1530
|
const proxyReq = client.request(
|
|
1531
1531
|
{
|
|
1532
1532
|
method: config.route.method,
|
|
@@ -1563,7 +1563,8 @@ __decorateClass([
|
|
|
1563
1563
|
__decorateParam(0, A_Inject(A_Request)),
|
|
1564
1564
|
__decorateParam(1, A_Inject(A_Response)),
|
|
1565
1565
|
__decorateParam(2, A_Inject(A_ProxyConfig)),
|
|
1566
|
-
__decorateParam(3, A_Inject(A_Logger))
|
|
1566
|
+
__decorateParam(3, A_Inject(A_Logger)),
|
|
1567
|
+
__decorateParam(4, A_Inject(A_Polyfill))
|
|
1567
1568
|
], A_ServerProxy.prototype, "onRequest");
|
|
1568
1569
|
|
|
1569
1570
|
// src/components/A-ServerCORS/A_ServerCORS.component.defaults.ts
|