milkio 0.0.1 → 0.0.3

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/c.ts CHANGED
@@ -14,18 +14,18 @@ const params = argv.slice(3) as Parameters<(typeof commands)[keyof typeof comman
14
14
 
15
15
  const commands = {
16
16
  async gen() {
17
- await exec(rootPath, ["bun", "./node_modules/loongbao/scripts/generate.ts"]);
17
+ await exec(rootPath, ["bun", "./node_modules/milkio/scripts/generate.ts"]);
18
18
  },
19
19
  async "gen:database"() {
20
- await exec(rootPath, ["bun", "./node_modules/loongbao/scripts/generate-database.ts"]);
20
+ await exec(rootPath, ["bun", "./node_modules/milkio/scripts/generate-database.ts"]);
21
21
  },
22
22
  async "build:cookbook"() {
23
- await exec(rootPath, ["bun", "./node_modules/loongbao/scripts/build-cookbook.ts"]);
23
+ await exec(rootPath, ["bun", "./node_modules/milkio/scripts/build-cookbook.ts"]);
24
24
  },
25
25
  async "build:dto"() {
26
26
  await exec(join(rootPath, "packages", "dto"), ["bun", "i"]);
27
- await exec(rootPath, ["bun", "./node_modules/loongbao/scripts/generate.ts"]);
28
- await exec(rootPath, ["bun", "./node_modules/loongbao/scripts/build-dto.ts"]);
27
+ await exec(rootPath, ["bun", "./node_modules/milkio/scripts/generate.ts"]);
28
+ await exec(rootPath, ["bun", "./node_modules/milkio/scripts/build-dto.ts"]);
29
29
  },
30
30
  async test(files?: string, reserved?: string) {
31
31
  const run = async () => {
@@ -34,19 +34,19 @@ const commands = {
34
34
  // Therefore, temporarily switch to another implementation.
35
35
  // await $`${{ raw: packageJson.scripts.start }}`.env({
36
36
  // ...env,
37
- // LOONGBAO_RUN_MODE: "API_TEST",
38
- // LOONGBAO_TEST: files ?? "1"
37
+ // milkio_RUN_MODE: "API_TEST",
38
+ // milkio_TEST: files ?? "1"
39
39
  // });
40
40
  //
41
41
  await exec(rootPath, ["bash", "-c", packageJson.scripts.start as string], {
42
42
  env: {
43
43
  ...env,
44
- LOONGBAO_RUN_MODE: "API_TEST",
45
- LOONGBAO_TEST: files ?? "1"
44
+ milkio_RUN_MODE: "API_TEST",
45
+ milkio_TEST: files ?? "1"
46
46
  }
47
47
  });
48
48
  };
49
- if (!env.LOONGBAO_TEST_RESERVED && reserved !== "1") {
49
+ if (!env.milkio_TEST_RESERVED && reserved !== "1") {
50
50
  // Normal test
51
51
  await run();
52
52
  } else {
@@ -1,10 +1,10 @@
1
1
  /* eslint-disable @typescript-eslint/no-unsafe-argument, no-console, @typescript-eslint/no-explicit-any */
2
2
  import { exit } from "node:process";
3
3
  import schema from "../../../generate/api-schema";
4
- import { type LoongbaoApp } from "..";
4
+ import { type MilkioApp } from "..";
5
5
 
6
- export const defineApiTestHandler = async <Paths extends Array<keyof (typeof schema)["apiTestsSchema"]>>(app: LoongbaoApp, paths: Paths | string | 1 | undefined) => {
7
- console.log(`🧊 Loongbao Api Testing..\n`);
6
+ export const defineApiTestHandler = async <Paths extends Array<keyof (typeof schema)["apiTestsSchema"]>>(app: MilkioApp, paths: Paths | string | 1 | undefined) => {
7
+ console.log(`🧊 Milkio Api Testing..\n`);
8
8
 
9
9
  if (!paths) {
10
10
  console.log("🧊 No paths specified.");
@@ -65,6 +65,6 @@ export const defineApiTestHandler = async <Paths extends Array<keyof (typeof sch
65
65
  const endedAt = new Date().getTime();
66
66
 
67
67
  console.log(`\nāœ… All tests passed.`);
68
- console.log(`🧊 Loongbao Api Testing took ${((endedAt - startedAt) / 1000).toFixed(2)}s\n`);
68
+ console.log(`🧊 Milkio Api Testing took ${((endedAt - startedAt) / 1000).toFixed(2)}s\n`);
69
69
  exit(0);
70
70
  };
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-console */
2
2
  import { configFramework, loggerPushTags, loggerSubmit, useLogger, loggerSubmitAll, runtime, MiddlewareEvent } from "..";
3
- import type { ExecuteId, LoongbaoApp, Mixin } from "..";
3
+ import type { ExecuteId, MilkioApp, Mixin } from "..";
4
4
  import { hanldeCatchError } from "../utils/handle-catch-error";
5
5
  import { routerHandler } from "../../../src/router";
6
6
  import schema from "../../../generate/api-schema";
@@ -20,7 +20,7 @@ export type ExecuteHttpServerOptions = {
20
20
  executeIdGenerator?: (request: Request) => string | Promise<string>;
21
21
  };
22
22
 
23
- export function defineHttpHandler(app: LoongbaoApp, options: ExecuteHttpServerOptions = {}) {
23
+ export function defineHttpHandler(app: MilkioApp, options: ExecuteHttpServerOptions = {}) {
24
24
  // If an unexpected error occurs, exit the process.
25
25
  // For modern production environments such as Serverless, Kubernetes, or Docker Compose:
26
26
  // The process will automatically restart after exiting.
@@ -33,7 +33,7 @@ export function defineHttpHandler(app: LoongbaoApp, options: ExecuteHttpServerOp
33
33
  exit(1);
34
34
  });
35
35
 
36
- const fetch = async (request: LoongbaoHTTPRequest) => {
36
+ const fetch = async (request: milkioHTTPRequest) => {
37
37
  const fullurl = new URL(request.request.url, `http://${request.request.headers.get("host") ?? "localhost"}`);
38
38
  const executeId = (options?.executeIdGenerator ? await options.executeIdGenerator(request.request) : createUlid()) as ExecuteId;
39
39
  runtime.execute.executeIds.add(executeId);
@@ -50,7 +50,7 @@ export function defineHttpHandler(app: LoongbaoApp, options: ExecuteHttpServerOp
50
50
  timein: new Date().getTime()
51
51
  });
52
52
 
53
- const response: LoongbaoHTTPResponse = {
53
+ const response: milkioHTTPResponse = {
54
54
  body: "",
55
55
  status: 200,
56
56
  headers: {
@@ -92,7 +92,7 @@ export function defineHttpHandler(app: LoongbaoApp, options: ExecuteHttpServerOp
92
92
  loggerPushTags(executeId, {
93
93
  body: rawbody || "no body"
94
94
  });
95
- response.body = `{"executeId":"${executeId}","success":false,"fail":{"code":"not-found","message":${JSON.stringify(failCode["not-found"]())}}}`;
95
+ response.body = `{"executeId":"${executeId}","success":false,"fail":{"code":"NOT_FOUND","message":${JSON.stringify(failCode["NOT_FOUND"]())}}}`;
96
96
 
97
97
  loggerPushTags(executeId, {
98
98
  status: response.status,
@@ -188,11 +188,11 @@ export function defineHttpHandler(app: LoongbaoApp, options: ExecuteHttpServerOp
188
188
  return fetch;
189
189
  }
190
190
 
191
- export type LoongbaoHTTPRequest = {
191
+ export type milkioHTTPRequest = {
192
192
  request: Request;
193
193
  };
194
194
 
195
- export type LoongbaoHTTPResponse = Mixin<
195
+ export type milkioHTTPResponse = Mixin<
196
196
  ResponseInit,
197
197
  {
198
198
  //
package/index.ts CHANGED
@@ -29,5 +29,5 @@ export * from "./kernel/middleware";
29
29
  export * from "./defines/define-http-handler";
30
30
  export * from "./defines/define-api-test-handler";
31
31
 
32
- // loongbao
33
- export * from "./kernel/loongbao";
32
+ // milkio
33
+ export * from "./kernel/milkio";
package/kernel/config.ts CHANGED
@@ -4,8 +4,8 @@ import { envToBoolean, envToNumber, envToString } from "..";
4
4
  export const configFramework = {
5
5
  cwd: cwd(),
6
6
  port: envToNumber(env.PORT, 9000),
7
- loongbaoRunMode: envToString(env.LOONGBAO_RUN_MODE, "DEFAULT"),
8
- loongbaoTest: envToString(env.LOONGBAO_TEST, ""),
7
+ milkioRunMode: envToString(env.milkio_RUN_MODE, "DEFAULT"),
8
+ milkioTest: envToString(env.milkio_TEST, ""),
9
9
  debug: envToBoolean(env.DEBUG, false),
10
10
  redisUrl: envToString(env.REDIS_URL, "redis://:123456@your-not-redis-url:6379"),
11
11
  ignorePathLevel: envToNumber(env.IGNORE_PATH_LEVEL, 0),
package/kernel/context.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { URL } from "node:url";
2
- import type { ExecuteId, Logger, LoongbaoHTTPResponse } from "..";
2
+ import type { ExecuteId, Logger, milkioHTTPResponse } from "..";
3
3
 
4
- export type FrameworkContext = {
4
+ export type MilkioContext = {
5
5
  path: string;
6
6
  executeId: ExecuteId;
7
7
  headers: Headers;
@@ -20,5 +20,5 @@ export type FrameworkHTTPDetail = {
20
20
  fullurl: URL;
21
21
  ip: string;
22
22
  request: Request;
23
- response: LoongbaoHTTPResponse;
23
+ response: milkioHTTPResponse;
24
24
  };
package/kernel/fail.ts CHANGED
@@ -4,7 +4,7 @@ export function reject<Code extends keyof typeof failCode, FailData extends (typ
4
4
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
5
5
  const message = failCode[code]?.(data as any) ?? "";
6
6
  const error = {
7
- name: "LoongbaoReject",
7
+ name: "milkioReject",
8
8
  code,
9
9
  message,
10
10
  data,
@@ -16,7 +16,7 @@ export function reject<Code extends keyof typeof failCode, FailData extends (typ
16
16
  return error;
17
17
  }
18
18
 
19
- export type LoongbaoReject = ReturnType<typeof reject>;
19
+ export type milkioReject = ReturnType<typeof reject>;
20
20
 
21
21
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- export type LoongbaoFailCode = Record<string, (arg: any) => string>;
22
+ export type MilkioFailCode = Record<string, (arg: any) => string>;
@@ -2,9 +2,9 @@
2
2
 
3
3
  import type { Context } from "../../../src/context";
4
4
  import type { FrameworkHTTPDetail } from "./context";
5
- import { type LoongbaoApp } from "loongbao";
5
+ import { type MilkioApp } from "milkio";
6
6
 
7
- export type BootstrapMiddleware = (loongbao: LoongbaoApp) => Promise<void> | void;
7
+ export type BootstrapMiddleware = (milkio: MilkioApp) => Promise<void> | void;
8
8
  export type BeforeExecuteMiddleware = (context: Context) => Promise<void> | void;
9
9
  export type AfterExecuteMiddleware = (context: Context, response: { value: unknown }) => Promise<void> | void;
10
10
  export type AfterHTTPRequestMiddleware = (headers: Headers, detail: FrameworkHTTPDetail) => Promise<void> | void;
@@ -3,24 +3,24 @@ import { type MiddlewareOptions, _middlewares, MiddlewareEvent } from "./middlew
3
3
  import schema from "../../../generate/api-schema";
4
4
  import type { Context } from "../../../src/context";
5
5
  import { failCode } from "../../../src/fail-code";
6
- import type { FrameworkContext } from "./context";
6
+ import type { MilkioContext } from "./context";
7
7
  import { type Mixin, type ExecuteId, type Fail, type FailEnumerates, loggerPushTags, loggerSubmit, runtime, TSON, type Logger, useLogger } from "..";
8
8
  import { hanldeCatchError } from "../utils/handle-catch-error";
9
9
  import { _validate } from "./validate";
10
10
  import { cwd, exit } from "node:process";
11
11
  import { createUlid } from "../utils/create-ulid";
12
12
 
13
- export type LoongbaoAppOptions = {
13
+ export type MilkioAppOptions = {
14
14
  /**
15
15
  * bootstraps
16
16
  * @description
17
- * When Loongbao is launched, all methods in this array will run **in parallel**.
17
+ * When Milkio is launched, all methods in this array will run **in parallel**.
18
18
  */
19
19
  bootstraps?: () => Array</* This type is long, and its intention is to prevent someone from forgetting to add parentheses when adding bootstraps. Therefore, it allows all types except methods */ Promise<unknown> | void | string | number | boolean | null | undefined | Record<string | number | symbol, unknown> | Array<unknown>>;
20
20
  /**
21
21
  * middlewares
22
22
  * @description
23
- * When Loongbao is launched, the closer it is to the front of the array, the more it is on the outer layer of the "onion".
23
+ * When Milkio is launched, the closer it is to the front of the array, the more it is on the outer layer of the "onion".
24
24
  */
25
25
  middlewares?: () => Array<MiddlewareOptions>;
26
26
  /**
@@ -34,44 +34,44 @@ export type LoongbaoAppOptions = {
34
34
  * maxRunningTime (minutes)
35
35
  * @description
36
36
  * When the function runs for a long time, it is possible that the memory will continuously expand (not necessarily due to memory leaks, but also possibly due to having a large number of routes).
37
- * Set the maximum running time (in minutes). When Loongbao's running time reaches this value, terminate the process and automatically restart it from outside (K8S or other means).
37
+ * Set the maximum running time (in minutes). When milkio's running time reaches this value, terminate the process and automatically restart it from outside (K8S or other means).
38
38
  */
39
39
  enableMaxRunningTimeoutLimit?: number | null | undefined;
40
40
  };
41
41
 
42
- export async function createLoongbaoApp(loongbaoAppOptions: LoongbaoAppOptions = {}) {
43
- if (loongbaoAppOptions?.enableMaxRequestLimit && loongbaoAppOptions.enableMaxRequestLimit >= 1) {
44
- runtime.maxRequest.expected = loongbaoAppOptions.enableMaxRequestLimit;
42
+ export async function createMilkioApp(MilkioAppOptions: MilkioAppOptions = {}) {
43
+ if (MilkioAppOptions?.enableMaxRequestLimit && MilkioAppOptions.enableMaxRequestLimit >= 1) {
44
+ runtime.maxRequest.expected = MilkioAppOptions.enableMaxRequestLimit;
45
45
  runtime.maxRequest.enable = true;
46
46
  }
47
47
 
48
- if (loongbaoAppOptions.enableMaxRunningTimeoutLimit && loongbaoAppOptions.enableMaxRunningTimeoutLimit >= 1) {
48
+ if (MilkioAppOptions.enableMaxRunningTimeoutLimit && MilkioAppOptions.enableMaxRunningTimeoutLimit >= 1) {
49
49
  setTimeout(() => {
50
- console.log('āŒ Loongbao reached the limit of "maxRunningTimeout" in the options and automatically exited.');
50
+ console.log('āŒ milkio reached the limit of "maxRunningTimeout" in the options and automatically exited.');
51
51
  exit(0);
52
- }, loongbaoAppOptions.enableMaxRunningTimeoutLimit * 60 * 1000);
52
+ }, MilkioAppOptions.enableMaxRunningTimeoutLimit * 60 * 1000);
53
53
  runtime.maxRunningTimeout.enable = true;
54
54
  }
55
55
 
56
- const loongbaoApp = {
56
+ const MilkioApp = {
57
57
  execute: _execute,
58
58
  executeToJson: _executeToJson,
59
59
  _executeCore,
60
60
  _executeCoreToJson
61
61
  };
62
62
 
63
- if (loongbaoAppOptions.bootstraps) {
64
- await Promise.all(loongbaoAppOptions.bootstraps());
63
+ if (MilkioAppOptions.bootstraps) {
64
+ await Promise.all(MilkioAppOptions.bootstraps());
65
65
  }
66
66
 
67
- if (loongbaoAppOptions.middlewares) {
67
+ if (MilkioAppOptions.middlewares) {
68
68
  MiddlewareEvent.define("bootstrap", (a, b) => a.index - b.index);
69
69
  MiddlewareEvent.define("beforeExecute", (a, b) => a.index - b.index);
70
70
  MiddlewareEvent.define("afterExecute", (a, b) => b.index - a.index);
71
71
  MiddlewareEvent.define("afterHTTPRequest", (a, b) => a.index - b.index);
72
72
  MiddlewareEvent.define("beforeHTTPResponse", (a, b) => b.index - a.index);
73
73
 
74
- const middlewares = loongbaoAppOptions.middlewares();
74
+ const middlewares = MilkioAppOptions.middlewares();
75
75
 
76
76
  for (let index = 0; index < middlewares.length; index++) {
77
77
  const middlewareOptions = middlewares[index];
@@ -87,12 +87,12 @@ export async function createLoongbaoApp(loongbaoAppOptions: LoongbaoAppOptions =
87
87
  }
88
88
  MiddlewareEvent._sort();
89
89
 
90
- await MiddlewareEvent.handle("bootstrap", [loongbaoApp]);
90
+ await MiddlewareEvent.handle("bootstrap", [MilkioApp]);
91
91
  }
92
92
 
93
- console.log(`🧊 Loongbao is running on : ${cwd()}`);
93
+ console.log(`🧊 Milkio is running on : ${cwd()}`);
94
94
 
95
- return loongbaoApp;
95
+ return MilkioApp;
96
96
  }
97
97
 
98
98
  async function _execute<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, headersInit: Record<string, string> | Headers = {}, options?: ExecuteOptions): Promise<ExecuteResult<Result>> {
@@ -126,7 +126,7 @@ async function _execute<Path extends keyof (typeof schema)["apiMethodsTypeSchema
126
126
  }
127
127
 
128
128
  /**
129
- * executeCore is a low-level API that is useful only when you want to execute the loongbao API without using execute or httpServer.
129
+ * executeCore is a low-level API that is useful only when you want to execute the Milkio Api without using execute or httpServer.
130
130
  * It only does the most basic thing internally, which is calling the API. The external handling of functions such as making executeId, logging, middleware, etc., are all handled externally.
131
131
  * Both execute and httpServer essentially call executeCore.
132
132
  */
@@ -137,7 +137,7 @@ async function _executeCore<Path extends keyof (typeof schema)["apiMethodsTypeSc
137
137
 
138
138
  if (runtime.maxRequest.enable) {
139
139
  if (runtime.maxRequest.counter >= runtime.maxRequest.expected) {
140
- console.log("āŒ Loongbao reached the limit of 'maxRequest' in the options and automatically exited.");
140
+ console.log("āŒ milkio reached the limit of 'maxRequest' in the options and automatically exited.");
141
141
  exit(0);
142
142
  }
143
143
  runtime.maxRequest.counter++;
@@ -148,8 +148,8 @@ async function _executeCore<Path extends keyof (typeof schema)["apiMethodsTypeSc
148
148
  executeId,
149
149
  success: false,
150
150
  fail: {
151
- code: "not-found",
152
- message: failCode["not-found"](),
151
+ code: "NOT_FOUND",
152
+ message: failCode["NOT_FOUND"](),
153
153
  data: undefined
154
154
  }
155
155
  } satisfies ExecuteResult<Result>;
@@ -185,6 +185,7 @@ async function _executeCore<Path extends keyof (typeof schema)["apiMethodsTypeSc
185
185
 
186
186
  // check type
187
187
  // @ts-ignore
188
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
188
189
  _validate(await (await schema.apiValidator.validate[path]()).params(params));
189
190
 
190
191
  // execute api
@@ -256,7 +257,7 @@ export type ExecuteOptions = {
256
257
  * These are usually only fully implemented when called by an HTTP server
257
258
  * During testing or when calling between microservices, some or all of the values may be undefined
258
259
  */
259
- detail?: FrameworkContext["detail"];
260
+ detail?: MilkioContext["detail"];
260
261
  };
261
262
 
262
263
  export type ExecuteCoreOptions = Mixin<
@@ -5,7 +5,7 @@ export function _validate(validator: IValidation.IFailure | IValidation.ISuccess
5
5
  if (validator.success) return;
6
6
  const error = validator.errors[0];
7
7
 
8
- throw reject("general-type-safe-error", {
8
+ throw reject("PARAMS_TYPE_ERROR", {
9
9
  path: error.path,
10
10
  expected: error.expected,
11
11
  value: error.value
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.1",
5
+ "version": "0.0.3",
6
6
  "peerDependencies": {
7
7
  "typescript": "^5.4.2"
8
8
  },
@@ -6,7 +6,7 @@ import { join } from "node:path";
6
6
  import { copyFile, mkdir } from "node:fs/promises";
7
7
 
8
8
  export async function buildDTO() {
9
- console.log("🧊 Loongbao DTO Building..");
9
+ console.log("🧊 milkio DTO Building..");
10
10
 
11
11
  removeDir(join(cwd(), "packages", "dto", "dist"));
12
12
  removeDir(join(cwd(), "packages", "dto", "generate"));
@@ -36,7 +36,7 @@ export async function buildDTO() {
36
36
 
37
37
  const root = join(cwd(), "packages", "dto");
38
38
 
39
- console.log("🧊 Loongbao DTO Build Finished");
39
+ console.log("🧊 milkio DTO Build Finished");
40
40
  console.log("\x1B[2m");
41
41
  console.log("Now, your latest code (including changes to your interface) is built to the latest version and waiting for your release!");
42
42
  console.log("");
@@ -53,7 +53,7 @@ export async function generateAppPartial(path?: string) {
53
53
  importPath = importPath + "src/apps";
54
54
  const template = `
55
55
  import typia from "typia";
56
- import { _validate, type ExecuteResultSuccess } from "loongbao";
56
+ import { _validate, type ExecuteResultSuccess } from "milkio";
57
57
  import { type TSONEncode } from "@southern-aurora/tson";
58
58
  import type * as <%= utils.camel(path.slice(0, -3).replaceAll('/', '$')) %> from '${importPath}/<%= path.slice(0, -3) %>';
59
59
 
@@ -21,7 +21,7 @@ export async function generateApp() {
21
21
  } catch (error) {} // Maybe the file does not exist
22
22
 
23
23
  if (!existsSync(join("generate", "README.md"))) {
24
- await writeFile(join("generate", "README.md"), "āš ļø All files in this directory are generated by Loongbao. Please do not modify the content, otherwise your modifications will be overwritten in the next generation.");
24
+ await writeFile(join("generate", "README.md"), "āš ļø All files in this directory are generated by milkio. Please do not modify the content, otherwise your modifications will be overwritten in the next generation.");
25
25
  }
26
26
 
27
27
  // Write a basic framework to ensure that there are no errors when reading later
@@ -81,7 +81,7 @@ export async function generateApp() {
81
81
  importPath = importPath + "src/apps";
82
82
  const template = `
83
83
  import typia from "typia";
84
- import { _validate, type ExecuteResultSuccess } from "loongbao";
84
+ import { _validate, type ExecuteResultSuccess } from "milkio";
85
85
  import { type TSONEncode } from "@southern-aurora/tson";
86
86
  import type * as <%= utils.camel(path.slice(0, -3).replaceAll('/', '$')) %> from '${importPath}/<%= path.slice(0, -3) %>';
87
87
 
@@ -14,10 +14,10 @@ export async function generate() {
14
14
  await generateDatabase();
15
15
  }
16
16
 
17
- console.log("Loongbao Database Generating..");
17
+ console.log("milkio Database Generating..");
18
18
 
19
19
  await generate();
20
20
 
21
- console.log("\nāœ… Loongbao Database Generated!\n");
21
+ console.log("\nāœ… milkio Database Generated!\n");
22
22
 
23
23
  exit(0);
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { argv, exit } from "node:process";
4
4
  import { generateApp } from "./generate/generate-app";
5
- console.log("Loongbao Quick Generating..");
5
+ console.log("milkio Quick Generating..");
6
6
 
7
7
  export async function generatePartial(path?: string) {
8
8
  await generateApp();
@@ -10,6 +10,6 @@ export async function generatePartial(path?: string) {
10
10
 
11
11
  await generatePartial(...(argv.slice(3) as any));
12
12
 
13
- console.log("\nāœ… Loongbao Generated!");
13
+ console.log("\nāœ… milkio Generated!");
14
14
 
15
15
  exit(0);
@@ -14,10 +14,10 @@ export async function generate() {
14
14
  await generateApp();
15
15
  }
16
16
 
17
- console.log("Loongbao Generating..");
17
+ console.log("milkio Generating..");
18
18
 
19
19
  await generate();
20
20
 
21
- console.log("\nāœ… Loongbao Generated!");
21
+ console.log("\nāœ… milkio Generated!");
22
22
 
23
23
  exit(0);
package/templates/api.ts CHANGED
@@ -5,7 +5,7 @@ await createTemplate(async (tools) => {
5
5
  return {
6
6
  path: join(tools.directory, `${tools.hyphen(tools.name)}.ts`),
7
7
  content: `
8
- import { defineApi, defineApiTest } from "loongbao";
8
+ import { defineApi, defineApiTest } from "milkio";
9
9
 
10
10
  /**
11
11
  * ${tools.hyphen(tools.name)}
package/types.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  /* eslint-disable @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any */
2
2
 
3
- import { type createLoongbaoApp } from ".";
3
+ import { type createMilkioApp } from ".";
4
4
  import type { failCode } from "../../src/fail-code";
5
5
 
6
- export type LoongbaoApp = Awaited<ReturnType<typeof createLoongbaoApp>>;
6
+ export type MilkioApp = Awaited<ReturnType<typeof createMilkioApp>>;
7
7
 
8
8
  export type ExecuteId = string | "global";
9
9
 
@@ -19,7 +19,7 @@ export type Fail<FailCode extends keyof FailEnumerates> = {
19
19
  data: Parameters<FailEnumerates[FailCode]>[0];
20
20
  };
21
21
 
22
- export type LoongbaoMeta = {
22
+ export type MilkioMeta = {
23
23
  //
24
24
  };
25
25
 
@@ -9,16 +9,16 @@ export function hanldeCatchError(error: any, executeId: ExecuteId): ExecuteResul
9
9
  if (error.stack) logger.error("\nError Stack: ", error.stack);
10
10
  else logger.error("\nError Stack: ", error);
11
11
 
12
- if (error.name !== "LoongbaoReject") {
13
- // If it is not LoongbaoReject, it is considered an internal server error that should not be exposed
14
- logger.error(`FailCode: internal-server-error`);
12
+ if (error.name !== "milkioReject") {
13
+ // If it is not milkioReject, it is considered an internal server error that should not be exposed
14
+ logger.error(`FailCode: INTERNAL_SERVER_ERROR`);
15
15
 
16
16
  return {
17
17
  executeId,
18
18
  success: false,
19
19
  fail: {
20
- code: "internal-server-error",
21
- message: failCode["internal-server-error"](),
20
+ code: "INTERNAL_SERVER_ERROR",
21
+ message: failCode["INTERNAL_SERVER_ERROR"](),
22
22
  data: undefined
23
23
  }
24
24
  };