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
+1
View File
@@ -0,0 +1 @@
# Copy this file to .env and add local environment values.
+8
View File
@@ -0,0 +1,8 @@
module.exports = {
root: true,
env: { es2022: true, node: true },
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
ignorePatterns: ["node_modules/", "dist/", "coverage/"],
};
+3
View File
@@ -5,3 +5,6 @@ dist/
coverage/
test-results/
playwright-report/
*.tsbuildinfo
.eslintcache
pnpm-debug.log*
+5
View File
@@ -0,0 +1,5 @@
node_modules
dist
coverage
docs/
+19
View File
@@ -0,0 +1,19 @@
{
"name": "drift-bottle",
"version": "0.0.0",
"private": true,
"packageManager": "pnpm@9.15.0",
"scripts": {
"test": "vitest run",
"typecheck": "tsc --noEmit -p tsconfig.base.json",
"lint": "eslint . --ext .ts --max-warnings 0 && prettier --check ."
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^8.18.0",
"@typescript-eslint/parser": "^8.18.0",
"eslint": "^8.57.1",
"prettier": "^3.4.2",
"typescript": "^5.6.3",
"vitest": "^2.1.8"
}
}
+10
View File
@@ -0,0 +1,10 @@
{
"name": "@drift/contracts",
"version": "0.0.0",
"private": true,
"type": "module",
"exports": "./src/index.ts",
"scripts": {
"test": "vitest run src/index.test.ts"
}
}
+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,
});
+2506
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -0,0 +1,2 @@
packages:
- packages/*
+15
View File
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"types": ["vitest/globals"]
},
"include": ["packages/**/*.ts"]
}