chore: 初始化 TypeScript monorepo
This commit is contained in:
@@ -0,0 +1 @@
|
||||
# Copy this file to .env and add local environment values.
|
||||
@@ -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/"],
|
||||
};
|
||||
@@ -5,3 +5,6 @@ dist/
|
||||
coverage/
|
||||
test-results/
|
||||
playwright-report/
|
||||
*.tsbuildinfo
|
||||
.eslintcache
|
||||
pnpm-debug.log*
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
node_modules
|
||||
dist
|
||||
coverage
|
||||
|
||||
docs/
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -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",
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -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,
|
||||
});
|
||||
Generated
+2506
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
packages:
|
||||
- packages/*
|
||||
@@ -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"]
|
||||
}
|
||||
Reference in New Issue
Block a user