@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.
@@ -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 | undefined) => Router;
17
+ export declare const FeatureRouter: (options: FeatureRouterOptions, logger?: Logger) => Router;
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=api-router-helpers.js.map
3
+ //# sourceMappingURL=api-router.js.map
@@ -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[] | undefined) => 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 | undefined) => ConfigOutput;
11
- export declare const loadConfigFile: (envFilePath: string, combined?: ConfigOutput | undefined, logger?: Logger | undefined) => ConfigOutput;
12
- export declare const loadConfig: (configDirname?: string, logger?: Logger | undefined) => LoadConfigOut;
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 {};
@@ -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";
@@ -1,6 +1,6 @@
1
1
  export * from "./context";
2
2
  export * from "./router-helpers";
3
- export * from "./api-router-helpers";
3
+ export * from "./api-router";
4
4
  export * from "./session";
5
5
  export * from "./error";
6
6
  export * from "./config";
@@ -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-helpers"), exports);
19
+ __exportStar(require("./api-router"), exports);
20
20
  __exportStar(require("./session"), exports);
21
21
  __exportStar(require("./error"), exports);
22
22
  __exportStar(require("./config"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,mDAAiC;AACjC,uDAAqC;AACrC,4CAA0B;AAC1B,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB"}
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 | undefined;
7
- transports?: LoggerTransport[] | undefined;
8
- } | undefined, useCache?: boolean) => Logger;
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 | undefined) => PathPart[];
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 | undefined;
5
- timeout?: number | undefined;
6
- } | undefined) => Handler<void>;
4
+ limit?: number;
5
+ timeout?: number;
6
+ }) => Handler<void>;
@@ -5,4 +5,4 @@ export interface CORSOptions {
5
5
  methods?: string;
6
6
  preflightContinue?: boolean;
7
7
  }
8
- export declare const CORS: (options?: CORSOptions | undefined) => Handler<void>;
8
+ export declare const CORS: (options?: CORSOptions) => Handler<void>;
@@ -1,6 +1,6 @@
1
1
  import { Handler } from "../common";
2
2
  export declare const URLEncodedParser: (options?: {
3
- limit?: number | undefined;
4
- maxKeys?: number | undefined;
5
- type?: string | undefined;
6
- } | undefined) => Handler<void>;
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 | undefined;
4
- strict?: boolean | undefined;
5
- type?: string | undefined;
6
- } | undefined) => Handler<void>;
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 | undefined) => Handler<void>;
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 | undefined) => Handler;
3
+ export declare const ResultParser: (options: ParseOptions | ParseOptions[] | string, parser?: ParserInterface) => Handler;
@@ -1,4 +1,4 @@
1
1
  import { Handler } from "../common";
2
2
  export declare const TagResponse: (options?: {
3
- uuid?: boolean | undefined;
4
- } | undefined) => Handler<void>;
3
+ uuid?: boolean;
4
+ }) => Handler<void>;
@@ -1,5 +1,5 @@
1
1
  import { Handler } from "../common";
2
2
  export declare const TextParser: (options?: {
3
- limit?: number | undefined;
4
- type?: string | undefined;
5
- } | undefined) => Handler<void>;
3
+ limit?: number;
4
+ type?: string;
5
+ }) => Handler<void>;
package/package.json CHANGED
@@ -1,25 +1,24 @@
1
1
  {
2
2
  "name": "@miqro/core",
3
- "version": "1.5.21",
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.1",
20
- "@miqro/test-http": "0.0.5",
18
+ "@miqro/test": "0.2.4",
19
+ "@miqro/test-http": "0.0.7",
21
20
  "@types/node": "17.0.23",
22
- "typescript": "4.6.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/request": "^0.0.10",
32
- "@miqro/parser": "^0.1.4",
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-helpers";
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";
@@ -1,6 +1,6 @@
1
1
  export * from "./context";
2
2
  export * from "./router-helpers";
3
- export * from "./api-router-helpers";
3
+ export * from "./api-router";
4
4
  export * from "./session";
5
5
  export * from "./error";
6
6
  export * from "./config";
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-router-helpers.js","sourceRoot":"","sources":["../../src/common/api-router-helpers.ts"],"names":[],"mappings":""}
@@ -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
- });