milkio 0.0.6 → 0.0.8

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.
@@ -38,13 +38,14 @@ export const defineApiTestHandler = async <Paths extends Array<keyof (typeof sch
38
38
  const csStartedAt = new Date().getTime();
39
39
  const clear = setTimeout(() => {
40
40
  console.error(`------`);
41
- console.error(`❌ TIMEOUT -- More than ${cs.timeout ?? 6000}ms`);
41
+ console.error(`❌ TIMEOUT -- More than ${cs.timeout ?? 8192}ms`);
42
42
  console.error(` ${cs.name} | Path: src/apps/${path as string}.ts | Case: ${i}`);
43
43
  console.error(`------`);
44
44
  exit(1);
45
- }, cs.timeout ?? 6000);
45
+ }, cs.timeout ?? 8192);
46
46
  await cs.handler({
47
47
  execute: async (params: any, headers?: any, options?: any) => app.execute(path, params, headers ?? {}, options),
48
+ executeOther: async (path: any, params: any, headers?: any, options?: any) => app.execute(path, params, headers ?? {}, options),
48
49
  reject: (message?: string) => {
49
50
  console.error(`------`);
50
51
  console.error(`❌ REJECT -- ${message ?? "Test not satisfied"}`);
@@ -52,7 +53,7 @@ export const defineApiTestHandler = async <Paths extends Array<keyof (typeof sch
52
53
  console.error(`------`);
53
54
  exit(1);
54
55
  }
55
- });
56
+ } as any);
56
57
  clearTimeout(clear);
57
58
  console.log(`✅ DIRECT -- ${cs.name} | Path: src/apps/${path as string}.ts | Case: ${i} | Time: ${new Date().getTime() - csStartedAt}ms`);
58
59
  }
@@ -1,4 +1,5 @@
1
1
  import { type Api, type ExecuteResult, type ExecuteOptions } from "..";
2
+ import type schema from "../../../generate/api-schema";
2
3
 
3
4
  export function defineApiTest<ApiT extends Api>(_api: ApiT, cases: Array<ApiTestCases<ApiT>>) {
4
5
  return {
@@ -8,7 +9,14 @@ export function defineApiTest<ApiT extends Api>(_api: ApiT, cases: Array<ApiTest
8
9
  }
9
10
 
10
11
  export type ApiTestCases<ApiT extends Api> = {
11
- handler: (test: { execute: (params: Parameters<ApiT["action"]>[0], headers?: Record<string, string>, options?: ExecuteOptions) => Promise<ExecuteResult<Awaited<ReturnType<ApiT["action"]>>>>; reject: (message?: string) => void }) => Promise<void> | void;
12
+ handler: (test: {
13
+ // execute
14
+ execute: (params: Parameters<ApiT["action"]>[0], headers?: Record<string, string>, options?: ExecuteOptions) => Promise<ExecuteResult<Awaited<ReturnType<ApiT["action"]>>>>;
15
+ // execute other
16
+ executeOther: <Path extends keyof (typeof schema)["apiMethodsTypeSchema"], Result extends Awaited<ReturnType<(typeof schema)["apiMethodsTypeSchema"][Path]["api"]["action"]>>>(path: Path, params: Parameters<(typeof schema)["apiMethodsTypeSchema"][Path]["api"]["action"]>[0] | string, headers?: Record<string, string>, options?: ExecuteOptions) => Promise<ExecuteResult<Result>>;
17
+ // reject
18
+ reject: (message?: string) => void;
19
+ }) => Promise<void> | void;
12
20
  name: string;
13
21
  timeout?: number;
14
22
  };
package/kernel/milkio.ts CHANGED
@@ -4,7 +4,7 @@ import schema from "../../../generate/api-schema";
4
4
  import type { Context } from "../../../src/context";
5
5
  import { failCode } from "../../../src/fail-code";
6
6
  import type { MilkioContext } from "./context";
7
- import { type Mixin, type ExecuteId, type Fail, type FailEnumerates, loggerPushTags, loggerSubmit, runtime, TSON, type Logger, useLogger } from "..";
7
+ import { type Mixin, type ExecuteId, type Fail, type FailEnumerates, loggerPushTags, loggerSubmit, runtime, TSON, type Logger, useLogger, configMilkio } from "..";
8
8
  import { hanldeCatchError } from "../utils/handle-catch-error";
9
9
  import { _validate } from "./validate";
10
10
  import { cwd, exit } from "node:process";
@@ -40,6 +40,8 @@ export type MilkioAppOptions = {
40
40
  };
41
41
 
42
42
  export async function createMilkioApp(MilkioAppOptions: MilkioAppOptions = {}) {
43
+ if (process.argv[2].startsWith("--run-mode:")) configMilkio.milkioRunMode = process.argv[2].split(":")[1];
44
+
43
45
  if (MilkioAppOptions?.enableMaxRequestLimit && MilkioAppOptions.enableMaxRequestLimit >= 1) {
44
46
  runtime.maxRequest.expected = MilkioAppOptions.enableMaxRequestLimit;
45
47
  runtime.maxRequest.enable = true;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "milkio",
3
3
  "type": "module",
4
4
  "module": "index.ts",
5
- "version": "0.0.6",
5
+ "version": "0.0.8",
6
6
  "peerDependencies": {
7
7
  "typescript": "^5.4.2"
8
8
  },