chore: 初始化 TypeScript monorepo

This commit is contained in:
root
2026-09-14 10:34:07 +08:00
parent 39798c2f7c
commit 332bf2fb46
11 changed files with 2601 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
import { describe, expect, it } from "vitest";
import { ErrorCode, ok } from "./index";
describe("contracts", () => {
it("creates the uniform response envelope", () => {
expect(ok({ id: "1" }, "req-1")).toEqual({
code: ErrorCode.OK,
message: "success",
data: { id: "1" },
requestId: "req-1",
});
});
});
+19
View File
@@ -0,0 +1,19 @@
export enum ErrorCode {
OK = "OK",
AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED",
AUTH_REFRESH_REUSED = "AUTH_REFRESH_REUSED",
BOTTLE_DAILY_LIMIT = "BOTTLE_DAILY_LIMIT",
BOTTLE_POOL_EMPTY = "BOTTLE_POOL_EMPTY",
BOTTLE_LEASE_EXPIRED = "BOTTLE_LEASE_EXPIRED",
CONTENT_REJECTED = "CONTENT_REJECTED",
USER_BLOCKED = "USER_BLOCKED",
CONVERSATION_FORBIDDEN = "CONVERSATION_FORBIDDEN",
MESSAGE_DUPLICATE = "MESSAGE_DUPLICATE",
}
export const ok = <T>(data: T, requestId: string) => ({
code: ErrorCode.OK,
message: "success",
data,
requestId,
});