@miqro/core 1.5.20 → 1.6.1
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/common/api-router-utils.d.ts +1 -1
- package/dist/common/{api-router-helpers.d.ts → api-router.d.ts} +0 -0
- package/dist/common/{api-router-helpers.js → api-router.js} +1 -1
- package/dist/common/api-router.js.map +1 -0
- package/dist/common/config/config.d.ts +1 -1
- package/dist/common/config/loader.d.ts +3 -3
- package/dist/common/context.d.ts +2 -0
- package/dist/common/index.d.ts +1 -1
- package/dist/common/index.js +1 -1
- package/dist/common/index.js.map +1 -1
- package/dist/common/logger/factory.d.ts +3 -3
- package/dist/common/tokenize-match.d.ts +1 -1
- package/dist/middleware/buffer.d.ts +3 -3
- package/dist/middleware/cors.d.ts +1 -1
- package/dist/middleware/form.d.ts +4 -4
- package/dist/middleware/json.d.ts +4 -4
- package/dist/middleware/parse.d.ts +1 -1
- package/dist/middleware/result.d.ts +1 -1
- package/dist/middleware/tag.d.ts +2 -2
- package/dist/middleware/text.d.ts +3 -3
- package/dist/proxy.js +6 -3
- package/dist/proxy.js.map +1 -1
- package/package.json +8 -9
- package/src/common/api-router-utils.ts +1 -1
- package/src/common/{api-router-helpers.ts → api-router.ts} +0 -0
- package/src/common/index.ts +1 -1
- package/src/proxy.ts +9 -4
- package/src/proxy.unit.test.js +3 -1
- package/dist/common/api-router-helpers.js.map +0 -1
|
@@ -14,4 +14,4 @@ export interface FeatureRouterPathOptions {
|
|
|
14
14
|
export declare type FeatureRouterOptions = {
|
|
15
15
|
[name: string]: FeatureRouterPathOptions;
|
|
16
16
|
};
|
|
17
|
-
export declare const FeatureRouter: (options: FeatureRouterOptions, logger?: Logger
|
|
17
|
+
export declare const FeatureRouter: (options: FeatureRouterOptions, logger?: Logger) => Router;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-router.js","sourceRoot":"","sources":["../../src/common/api-router.ts"],"names":[],"mappings":""}
|
|
@@ -16,4 +16,4 @@ export declare abstract class ConfigStore {
|
|
|
16
16
|
static keys(): string[];
|
|
17
17
|
static getConfig(key: string, defaultValue?: string): string | null;
|
|
18
18
|
}
|
|
19
|
-
export declare const checkEnvVariables: (requiredEnvVariables: string[], defaults?: string[]
|
|
19
|
+
export declare const checkEnvVariables: (requiredEnvVariables: string[], defaults?: string[]) => string[];
|
|
@@ -7,7 +7,7 @@ interface Logger {
|
|
|
7
7
|
warn(message?: any, ...optionalParams: any[]): void;
|
|
8
8
|
error(message?: any, ...optionalParams: any[]): void;
|
|
9
9
|
}
|
|
10
|
-
export declare const loadConfigString: (envFileContent: string, combined?: ConfigOutput
|
|
11
|
-
export declare const loadConfigFile: (envFilePath: string, combined?: ConfigOutput
|
|
12
|
-
export declare const loadConfig: (configDirname?: string, logger?: Logger
|
|
10
|
+
export declare const loadConfigString: (envFileContent: string, combined?: ConfigOutput) => ConfigOutput;
|
|
11
|
+
export declare const loadConfigFile: (envFilePath: string, combined?: ConfigOutput, logger?: Logger) => ConfigOutput;
|
|
12
|
+
export declare const loadConfig: (configDirname?: string, logger?: Logger) => LoadConfigOut;
|
|
13
13
|
export {};
|
package/dist/common/context.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
2
4
|
import { Logger } from "./logger";
|
|
3
5
|
import { Session } from "./session";
|
|
4
6
|
import { IncomingHttpHeaders, IncomingMessage, OutgoingHttpHeaders, ServerResponse } from "http";
|
package/dist/common/index.d.ts
CHANGED
package/dist/common/index.js
CHANGED
|
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./context"), exports);
|
|
18
18
|
__exportStar(require("./router-helpers"), exports);
|
|
19
|
-
__exportStar(require("./api-router
|
|
19
|
+
__exportStar(require("./api-router"), exports);
|
|
20
20
|
__exportStar(require("./session"), exports);
|
|
21
21
|
__exportStar(require("./error"), exports);
|
|
22
22
|
__exportStar(require("./config"), exports);
|
package/dist/common/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,mDAAiC;AACjC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,mDAAiC;AACjC,+CAA6B;AAC7B,4CAA0B;AAC1B,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB"}
|
|
@@ -3,9 +3,9 @@ import { LoggerFormatter } from "./formatter";
|
|
|
3
3
|
import { LoggerTransport } from "./transport";
|
|
4
4
|
import { LogLevel } from "./common";
|
|
5
5
|
export declare const getLogger: (identifier: string, options?: {
|
|
6
|
-
formatter?: LoggerFormatter
|
|
7
|
-
transports?: LoggerTransport[]
|
|
8
|
-
}
|
|
6
|
+
formatter?: LoggerFormatter;
|
|
7
|
+
transports?: LoggerTransport[];
|
|
8
|
+
}, useCache?: boolean) => Logger;
|
|
9
9
|
export declare type LoggerFactory = (args: {
|
|
10
10
|
identifier: string;
|
|
11
11
|
level: LogLevel;
|
|
@@ -15,7 +15,7 @@ export interface PathPart {
|
|
|
15
15
|
value: string;
|
|
16
16
|
lower: string;
|
|
17
17
|
}
|
|
18
|
-
export declare const splitPath: (path?: string
|
|
18
|
+
export declare const splitPath: (path?: string) => PathPart[];
|
|
19
19
|
export declare function tokenizePath(path?: string): PathPartToken[];
|
|
20
20
|
export declare function matchTokenizePath(checkAsRouter: boolean, pathTokens: PathPartToken[], requestParts: PathPart[]): {
|
|
21
21
|
match: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Handler } from "../common";
|
|
2
2
|
export declare const DEFAULT_READ_BUFFER_LIMIT: number;
|
|
3
3
|
export declare const ReadBuffer: (options?: {
|
|
4
|
-
limit?: number
|
|
5
|
-
timeout?: number
|
|
6
|
-
}
|
|
4
|
+
limit?: number;
|
|
5
|
+
timeout?: number;
|
|
6
|
+
}) => Handler<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Handler } from "../common";
|
|
2
2
|
export declare const URLEncodedParser: (options?: {
|
|
3
|
-
limit?: number
|
|
4
|
-
maxKeys?: number
|
|
5
|
-
type?: string
|
|
6
|
-
}
|
|
3
|
+
limit?: number;
|
|
4
|
+
maxKeys?: number;
|
|
5
|
+
type?: string;
|
|
6
|
+
}) => Handler<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Handler } from "../common";
|
|
2
2
|
export declare const JSONParser: (options?: {
|
|
3
|
-
limit?: number
|
|
4
|
-
strict?: boolean
|
|
5
|
-
type?: string
|
|
6
|
-
}
|
|
3
|
+
limit?: number;
|
|
4
|
+
strict?: boolean;
|
|
5
|
+
type?: string;
|
|
6
|
+
}) => Handler<void>;
|
|
@@ -6,4 +6,4 @@ export interface ParseRequestOptions {
|
|
|
6
6
|
params?: ParseOptions | boolean | ParseOptions[] | string;
|
|
7
7
|
body?: ParseOptions | boolean | ParseOptions[] | string;
|
|
8
8
|
}
|
|
9
|
-
export declare const ParseRequest: (options: ParseRequestOptions, parser?: ParserInterface
|
|
9
|
+
export declare const ParseRequest: (options: ParseRequestOptions, parser?: ParserInterface) => Handler<void>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ParseOptions, ParserInterface } from "@miqro/parser";
|
|
2
2
|
import { Handler } from "../common/context";
|
|
3
|
-
export declare const ResultParser: (options: ParseOptions | ParseOptions[] | string, parser?: ParserInterface
|
|
3
|
+
export declare const ResultParser: (options: ParseOptions | ParseOptions[] | string, parser?: ParserInterface) => Handler;
|
package/dist/middleware/tag.d.ts
CHANGED
package/dist/proxy.js
CHANGED
|
@@ -21,21 +21,24 @@ class ProxyRouter extends router_1.Router {
|
|
|
21
21
|
const nUrl = new url_1.URL(this.proxyURL.toString());
|
|
22
22
|
nUrl.pathname = nUrl.pathname + relative;
|
|
23
23
|
const url = nUrl.toString();
|
|
24
|
-
ctx.logger.info("proxy to %s", url.toString());
|
|
25
24
|
const headers = {
|
|
26
25
|
...ctx.headers
|
|
27
26
|
};
|
|
28
27
|
delete headers["connection"];
|
|
29
28
|
delete headers["keep-alive"];
|
|
30
|
-
const
|
|
29
|
+
const requestArgs = {
|
|
31
30
|
url: url.toString(),
|
|
31
|
+
query: ctx.query,
|
|
32
32
|
disableThrow: true,
|
|
33
33
|
rejectUnauthorized: this.rejectUnauthorized,
|
|
34
34
|
disableUserAgent: true,
|
|
35
35
|
method: ctx.method,
|
|
36
36
|
headers,
|
|
37
37
|
data: ctx.method !== "GET" ? ctx.buffer : undefined
|
|
38
|
-
}
|
|
38
|
+
};
|
|
39
|
+
ctx.logger.info("proxy to %s", url.toString());
|
|
40
|
+
ctx.logger.debug("proxy with %o", requestArgs);
|
|
41
|
+
const response = await (0, request_1.request)(requestArgs);
|
|
39
42
|
const responseHeaders = {
|
|
40
43
|
...response.headers
|
|
41
44
|
};
|
package/dist/proxy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":";;;AACA,4CAAuD;AACvD,qCAA+C;AAC/C,4DAAqE;AACrE,6BAAwB;AAOxB,MAAM,WAAY,SAAQ,eAAM;IAI9B,YAAY,OAA2B;QACrC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,QAAQ,GAAG,IAAI,SAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACtC,QAAQ,CAAC,QAAQ,GAAG,IAAA,8BAAa,EAA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gBACtB,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,OAAO;gBACP,IAAI,EAAE,GAAG,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;aACpD,CAAC;YAEF,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC/C,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;YAE/C,MAAM,QAAQ,GAAG,MAAM,IAAA,iBAAO,EAAC,WAAW,CAAC,CAAC;YAE5C,MAAM,eAAe,GAAG;gBACtB,GAAG,QAAQ,CAAC,OAAO;aACpB,CAAC;YACF,OAAO,eAAe,CAAC,YAAY,CAAC,CAAC;YACrC,OAAO,eAAe,CAAC,YAAY,CAAC,CAAC;YAErC,MAAM,GAAG,CAAC,GAAG,CAAC;gBACZ,OAAO,EAAE,eAAe;gBACxB,IAAI,EAAE,QAAQ,CAAC,MAAM;gBACrB,MAAM,EAAE,QAAQ,CAAC,MAAM;aACxB,CAAC,CAAC;SACJ;QACD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC;IAC9B,CAAC;CACF;AAEM,MAAM,KAAK,GAAG,CAAC,OAA2B,EAAE,EAAE;IACnD,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC,CAAA;AAFY,QAAA,KAAK,SAEjB"}
|
package/package.json
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miqro/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "commonjs",
|
|
7
8
|
"scripts": {
|
|
8
9
|
"prepare": "npm run build",
|
|
9
10
|
"prebuild": "rm -Rf dist/;",
|
|
10
11
|
"build": "tsc",
|
|
11
12
|
"pretest": "npm run build",
|
|
12
|
-
"test": "LOG_LEVEL=debug NODE_ENV=test npx miqro-test -r src/ test/*.test.js -n "
|
|
13
|
-
"test:unit": "LOG_LEVEL=debug NODE_ENV=test npx miqro-test -r src/ -n ",
|
|
14
|
-
"test:func": "LOG_LEVEL=debug NODE_ENV=test npx miqro-test test/*.test.js -n "
|
|
13
|
+
"test": "LOG_LEVEL=debug NODE_ENV=test npx miqro-test -r src/ test/*.test.js -n "
|
|
15
14
|
},
|
|
16
15
|
"author": "claukers",
|
|
17
16
|
"license": "ISC",
|
|
18
17
|
"devDependencies": {
|
|
19
|
-
"@miqro/test": "0.2.
|
|
20
|
-
"@miqro/test-http": "0.0.
|
|
18
|
+
"@miqro/test": "0.2.4",
|
|
19
|
+
"@miqro/test-http": "0.0.7",
|
|
21
20
|
"@types/node": "17.0.23",
|
|
22
|
-
"typescript": "4.
|
|
21
|
+
"typescript": "4.7.4",
|
|
23
22
|
"@types/cookie": "0.4.1",
|
|
24
23
|
"@types/uuid": "8.3.4"
|
|
25
24
|
},
|
|
@@ -28,8 +27,8 @@
|
|
|
28
27
|
"npm": ">=6.0.0"
|
|
29
28
|
},
|
|
30
29
|
"dependencies": {
|
|
31
|
-
"@miqro/
|
|
32
|
-
"@miqro/
|
|
30
|
+
"@miqro/parser": "^0.1.5",
|
|
31
|
+
"@miqro/request": "^0.1.1",
|
|
33
32
|
"cookie": "0.5.0",
|
|
34
33
|
"uuid": "8.3.2"
|
|
35
34
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {lstatSync, readdirSync} from "fs";
|
|
2
2
|
import {join, parse as pathParse, resolve} from "path";
|
|
3
3
|
import {Logger} from "./logger";
|
|
4
|
-
import {APIRoute} from "./api-router
|
|
4
|
+
import {APIRoute} from "./api-router";
|
|
5
5
|
import {normalizePath} from "./tokenize-match";
|
|
6
6
|
import {isFeatureEnabled} from "./config";
|
|
7
7
|
import {Router} from "../router";
|
|
File without changes
|
package/src/common/index.ts
CHANGED
package/src/proxy.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {Context} from "./common";
|
|
2
|
-
import {request} from "@miqro/request";
|
|
2
|
+
import {request, RequestOptions} from "@miqro/request";
|
|
3
3
|
import {Router, RouterOptions} from "./router";
|
|
4
4
|
import {normalizePath, PathPartToken} from "./common/tokenize-match";
|
|
5
5
|
import {URL} from "url";
|
|
@@ -32,7 +32,6 @@ class ProxyRouter extends Router {
|
|
|
32
32
|
const nUrl = new URL(this.proxyURL.toString());
|
|
33
33
|
nUrl.pathname = nUrl.pathname + relative;
|
|
34
34
|
const url = nUrl.toString();
|
|
35
|
-
ctx.logger.info("proxy to %s", url.toString());
|
|
36
35
|
|
|
37
36
|
const headers = {
|
|
38
37
|
...ctx.headers
|
|
@@ -41,15 +40,21 @@ class ProxyRouter extends Router {
|
|
|
41
40
|
delete headers["connection"];
|
|
42
41
|
delete headers["keep-alive"];
|
|
43
42
|
|
|
44
|
-
const
|
|
43
|
+
const requestArgs: RequestOptions = {
|
|
45
44
|
url: url.toString(),
|
|
45
|
+
query: ctx.query,
|
|
46
46
|
disableThrow: true,
|
|
47
47
|
rejectUnauthorized: this.rejectUnauthorized,
|
|
48
48
|
disableUserAgent: true,
|
|
49
49
|
method: ctx.method,
|
|
50
50
|
headers,
|
|
51
51
|
data: ctx.method !== "GET" ? ctx.buffer : undefined
|
|
52
|
-
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
ctx.logger.info("proxy to %s", url.toString());
|
|
55
|
+
ctx.logger.debug("proxy with %o", requestArgs);
|
|
56
|
+
|
|
57
|
+
const response = await request(requestArgs);
|
|
53
58
|
|
|
54
59
|
const responseHeaders = {
|
|
55
60
|
...response.headers
|
package/src/proxy.unit.test.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-router-helpers.js","sourceRoot":"","sources":["../../src/common/api-router-helpers.ts"],"names":[],"mappings":""}
|