@miqro/core 1.5.21 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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/dist/common/api-router-helpers.js.map +0 -1
- package/src/proxy.func.test.js +0 -65
|
@@ -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/package.json
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miqro/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-router-helpers.js","sourceRoot":"","sources":["../../src/common/api-router-helpers.ts"],"names":[],"mappings":""}
|
package/src/proxy.func.test.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
const {fake, requireMock} = require("@miqro/test");
|
|
2
|
-
const {resolve} = require("path");
|
|
3
|
-
const {strictEqual} = require("assert");
|
|
4
|
-
const {distPath, basePath} = require("./setup-test.js");
|
|
5
|
-
const {TestHelper} = require("@miqro/test-http");
|
|
6
|
-
const {request} = require("@miqro/request");
|
|
7
|
-
|
|
8
|
-
const testFilePath = resolve(distPath, "proxy.js");
|
|
9
|
-
|
|
10
|
-
describe("proxy functional tests2", () => {
|
|
11
|
-
describe("simple post", () => {
|
|
12
|
-
setTestTimeout(10000);
|
|
13
|
-
const lib = requireMock(distPath, {});
|
|
14
|
-
let server;
|
|
15
|
-
const port = 9595;
|
|
16
|
-
before(async () => {
|
|
17
|
-
const serverApp = new lib.App();
|
|
18
|
-
serverApp.use(lib.JSONParser());
|
|
19
|
-
serverApp.use(async (ctx) => {
|
|
20
|
-
ctx.logger.info("serverApp hit with %o", ctx.body);
|
|
21
|
-
});
|
|
22
|
-
serverApp.post("/api/login", async (ctx) => {
|
|
23
|
-
ctx.logger.info("login hit with %o", ctx.body);
|
|
24
|
-
await ctx.json(ctx.body);
|
|
25
|
-
});
|
|
26
|
-
server = await serverApp.listen(9595);
|
|
27
|
-
|
|
28
|
-
await (async function testServerApp() {
|
|
29
|
-
const response = await request({
|
|
30
|
-
url: `http://localhost:${port}/api/login`,
|
|
31
|
-
method: "POST",
|
|
32
|
-
data: {
|
|
33
|
-
testUP: "1"
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
strictEqual(response.status, 200);
|
|
37
|
-
})()
|
|
38
|
-
});
|
|
39
|
-
after(async () => {
|
|
40
|
-
await server.close();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("happy path", async () => {
|
|
44
|
-
const proxyApp = new lib.App();
|
|
45
|
-
proxyApp.use(lib.JSONParser());
|
|
46
|
-
proxyApp.use(async (ctx) => {
|
|
47
|
-
ctx.logger.info("proxy hit with %o", ctx.body);
|
|
48
|
-
});
|
|
49
|
-
proxyApp.use(lib.Proxy({
|
|
50
|
-
url: "http://localhost:" + port
|
|
51
|
-
}), "/proxy");
|
|
52
|
-
const response = await TestHelper(proxyApp, {
|
|
53
|
-
disableThrow: true,
|
|
54
|
-
url: `/proxy/api/login`,
|
|
55
|
-
method: "POST",
|
|
56
|
-
data: {
|
|
57
|
-
userName: "hello",
|
|
58
|
-
password: "world"
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
strictEqual(response.status, 200);
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
})
|
|
65
|
-
});
|