chore: rename to arcanesync-backend; update agents.md; disable vitest in eslint
This commit is contained in:
parent
ec5269a579
commit
8eff6d17b8
3 changed files with 52 additions and 20 deletions
64
AGENTS.md
64
AGENTS.md
|
|
@ -2,59 +2,87 @@
|
||||||
|
|
||||||
## Project Overview
|
## Project Overview
|
||||||
|
|
||||||
TypeScript ESM boilerplate. Runtime-only via `tsx`, no build step.
|
`arcanesync` — cloud sync backend for the arcanegram telegram client fork. Authenticates every request via Telegram Mini App `initData` (HMAC-SHA256) and persists per-user sync state in postgres.
|
||||||
|
|
||||||
## Stack
|
## Stack
|
||||||
|
|
||||||
- **Runtime**: Node 24+, tsx
|
- **Runtime**: Node 24+, tsx (no build step)
|
||||||
- **Package manager**: pnpm
|
- **Package manager**: pnpm
|
||||||
|
- **HTTP**: Hono on `@hono/node-server`
|
||||||
|
- **DB**: PostgreSQL via `pg` + drizzle-orm; migrations via drizzle-kit
|
||||||
- **Linting**: @antfu/eslint-config v8 (eslint.config.mjs)
|
- **Linting**: @antfu/eslint-config v8 (eslint.config.mjs)
|
||||||
- **Env**: env-var + native `loadEnvFile`
|
- **Env**: env-var + native `loadEnvFile`
|
||||||
- **Container**: Docker, node:24-alpine
|
- **Container**: Docker, node:24-alpine; docker-compose for postgres
|
||||||
|
|
||||||
## Structure
|
## Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
src/
|
src/
|
||||||
├── index.ts # entrypoint
|
├── index.ts # entrypoint — wires hono app, starts server
|
||||||
|
├── db/
|
||||||
|
│ ├── db.ts # pg pool + drizzle instance
|
||||||
|
│ ├── schema.ts # drizzle schema
|
||||||
|
│ ├── migrate.ts # migration runner (pnpm db:migrate)
|
||||||
|
│ └── migrations/ # generated sql
|
||||||
|
├── lib/
|
||||||
|
│ ├── initdata.ts # telegram initData hmac validator
|
||||||
|
│ └── initdata.test.ts
|
||||||
|
├── middleware/
|
||||||
|
│ └── auth.ts # `Authorization: tma <initData>` guard
|
||||||
|
├── routes/
|
||||||
|
│ ├── health.ts # GET /health
|
||||||
|
│ ├── miniapp.ts # GET /miniapp (botfather stub)
|
||||||
|
│ └── sync.ts # GET/PUT /sync
|
||||||
└── shared/
|
└── shared/
|
||||||
└── config.ts # env config
|
└── config.ts # env config
|
||||||
```
|
```
|
||||||
|
|
||||||
## Preferred Folder Structure
|
## Endpoints
|
||||||
|
|
||||||
```
|
- `GET /health` — liveness
|
||||||
src/
|
- `GET /miniapp` — mini app stub registered with botfather
|
||||||
├── index.ts # entrypoint
|
- `GET /sync` — auth required. returns `{version, data}`
|
||||||
├── shared/ # cross-cutting concerns (config, types, utilities)
|
- `PUT /sync` — auth required. body `{baseVersion, patch}`. 200 on accept, 409 on version conflict (returns current `{version, data}`)
|
||||||
└── lib/ # third-party wrappers, adapters
|
|
||||||
```
|
|
||||||
|
|
||||||
Expand based on project type as needed. Keep `src/index.ts` as the single entrypoint.
|
Auth header: `Authorization: tma <initData>`. Validation enforces hmac correctness and `auth_date` freshness.
|
||||||
|
|
||||||
## Conventions
|
## Conventions
|
||||||
|
|
||||||
- ESM only (`"type": "module"`)
|
- ESM only (`"type": "module"`)
|
||||||
- Path alias `@/*` maps to `src/*` — imports must end with `.js` extension (nodenext resolution)
|
- Path alias `@/*` → `src/*` — imports must end with `.js` (nodenext resolution)
|
||||||
- No build step — tsx runs TS directly in dev and prod
|
- No build step — tsx runs TS directly in dev and prod
|
||||||
- `cross-env` for cross-platform env vars in npm scripts
|
- `cross-env` for cross-platform env vars in npm scripts
|
||||||
- No useless comments
|
- No useless comments
|
||||||
- Split code into multiple files rather than monoliths
|
- Split code into multiple files rather than monoliths
|
||||||
|
- Lowercase strings (errors, keys, log messages) where reasonable
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
- `pnpm dev` — watch mode
|
- `pnpm dev` — watch mode
|
||||||
- `pnpm start` — production run
|
- `pnpm start` — production run
|
||||||
- `pnpm lint` — check
|
- `pnpm lint` / `pnpm lint:fix`
|
||||||
- `pnpm lint:fix` — auto-fix
|
- `pnpm test` — node:test runner via tsx
|
||||||
|
- `pnpm db:generate` — drizzle-kit generate
|
||||||
|
- `pnpm db:migrate` — apply migrations
|
||||||
|
- `pnpm db:studio` — drizzle studio
|
||||||
|
|
||||||
|
## Env
|
||||||
|
|
||||||
|
| var | default | meaning |
|
||||||
|
|---|---|---|
|
||||||
|
| `PORT` | `3000` | http port |
|
||||||
|
| `DATABASE_URL` | required | postgres dsn |
|
||||||
|
| `BOT_TOKEN` | required | telegram bot token (mini-app-enabled) |
|
||||||
|
| `AUTH_DATE_MAX_AGE_SECONDS` | `86400` | initData freshness window |
|
||||||
|
| `MAX_PAYLOAD_BYTES` | `65536` | per-PUT payload cap |
|
||||||
|
|
||||||
## Lint Rules
|
## Lint Rules
|
||||||
|
|
||||||
- `no-console: off` — console.log is allowed
|
- `no-console: off`
|
||||||
- `antfu/no-top-level-await: off`
|
- `antfu/no-top-level-await: off`
|
||||||
- Stylistic: 2-space indent, single quotes
|
- Stylistic: 2-space indent, single quotes
|
||||||
- JSON key ordering enforced (auto-fixed)
|
- JSON key ordering enforced (auto-fixed)
|
||||||
|
|
||||||
## Docker
|
## Docker
|
||||||
|
|
||||||
Single-stage, no build. Copies source, installs prod deps, runs via `pnpm start`.
|
Single-stage `node:24-alpine`, no build. Copies source, installs prod deps, runs `pnpm db:migrate` then `pnpm start`. `docker-compose.yml` provides postgres for local dev.
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,13 @@ export default antfu({
|
||||||
quotes: 'single',
|
quotes: 'single',
|
||||||
},
|
},
|
||||||
typescript: true,
|
typescript: true,
|
||||||
|
// project uses node --test, not vitest
|
||||||
|
vitest: false,
|
||||||
ignores: ['.omc', 'src/db/migrations'],
|
ignores: ['.omc', 'src/db/migrations'],
|
||||||
rules: {
|
rules: {
|
||||||
'no-console': 'off',
|
'no-console': 'off',
|
||||||
'antfu/no-top-level-await': 'off',
|
'antfu/no-top-level-await': 'off',
|
||||||
|
// project uses node --test, not vitest
|
||||||
|
'test/no-import-node-test': 'off',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "boilerplate",
|
"name": "arcanesync-backend",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"packageManager": "pnpm@10.13.1",
|
"packageManager": "pnpm@10.13.1",
|
||||||
"description": "typescript esm boilerplate",
|
"description": "cloud sync backend for the arcanegram telegram client fork",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=24.0.0"
|
"node": ">=24.0.0"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue