Cursor rule
.cursor/rules/backend-server.mdcCursor rules
Quality
52/100
Scores the file, not the repository.Length
315 words
5 headings · 0 code blocksRepository
4.0k
— · pushed 2 days agoLast changed
3 days ago
First indexed 3 days ago.12345## Backend Server (apps/server)67- **Role**: Thin WebSocket + HTTP edge that:8 - Hosts a **`CoreContext` per WebSocket connection**.9 - Exposes health/metrics endpoints.10 - Delegates all business logic to `packages/core`.11- Do **not** add business rules, Telegram API calls, or heavy data processing into `apps/server`; push those into `packages/core`.1213### Bootstrap & Lifecycle1415- Preserve the bootstrap sequence from `src/app.ts`:16 1. Parse env flags (`parseEnvFlags`).17 2. Initialize logging (`initLogger` + `useLogger().useGlobalConfig()`).18 3. Build runtime config from environment (`parseEnvToConfig(process.env)`).19 4. Initialize database via `initDrizzle` using that config.20 5. Configure the HTTP/WebSocket server.21 6. Start listening via `listhen` and register graceful shutdown handlers.22- Any changes must keep this order clear and failure modes explicit.2324### HTTP & WebSocket Design2526- HTTP:27 - Keep endpoints minimal: health checks, metrics, and potentially a small set of diagnostics.28 - Reuse `h3` helpers (`createApp`, `createRouter`, `defineEventHandler`) and centralize error handling in `onError`.29 - Never leak internal error details in HTTP responses; log full details, return generic messages.30- WebSocket:31 - Route all WS traffic through a dedicated module (e.g. `ws/routes`) that knows how to instantiate and manage `CoreContext`.32 - Enforce **one `CoreContext` per connection**; no cross-connection sharing.33 - When adding new events, ensure types are synchronized with `@tg-search/server/types` and `@tg-search/core`.3435### Configuration & Environment3637- Source configuration from `config.yaml` + environment variables only; avoid hard-coding URLs, ports, or credentials.38- Keep the config schema compatible between server and browser modes where applicable (database, embedding, Telegram API).39- When adding new configuration options:40 - Document them in `.env.example`.41 - Provide safe defaults that will not break existing deployments.4243### Error Handling & Observability4445- Use central error handlers:46 - `setupErrorHandlers` for process-level errors (uncaughtException, unhandledRejection).47 - `h3`'s `onError` hook for HTTP path errors.48- Metrics:49 - Use `prom-client` and expose metrics from `/metrics` using the shared registry.50 - Only add new metrics when they support explicit SLOs (latency, error rate, throughput).5152
Also in groupultra/telegram-search
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| groupultra/telegram-search.cursor/rules/testing.mdc · 4.0k | Cursor rules | teststyletesting-strategydatabase | 55/100 | 3 days ago | |
| groupultra/telegram-search.cursor/rules/architecture.mdc · 4.0k | Cursor rules | buildtestlint-formatarch+4 | 89/100 | 3 days ago | |
| groupultra/telegram-search.cursor/rules/client.mdc · 4.0k | Cursor rules | stylearchtypesdependencies+1 | 60/100 | 3 days ago | |
| groupultra/telegram-search.cursor/rules/contributing.mdc · 4.0k | Cursor rules | styletypesgit | 56/100 | 3 days ago | |
| groupultra/telegram-search.cursor/rules/core.mdc · 4.0k | Cursor rules | stylearchdependenciesdatabase+1 | 60/100 | 3 days ago | |
| groupultra/telegram-search.cursor/rules/db.mdc · 4.0k | Cursor rules | styletypesdatabaseperformance | 59/100 | 3 days ago | |
| groupultra/telegram-search.cursor/rules/events.mdc · 4.0k | Cursor rules | style | 60/100 | 3 days ago | |
| groupultra/telegram-search.cursor/rules/frontend-web.mdc · 4.0k | Cursor rules | stylesecurityuimonorepo | 56/100 | 3 days ago | |
| groupultra/telegram-search.cursor/rules/pglite-inspector.mdc · 4.0k | Cursor rules | securityapi | 47/100 | 3 days ago | |
| groupultra/telegram-search.cursor/rules/tooling.mdc · 4.0k | Cursor rules | buildlint-formatstyledeployment+1 | 67/100 | 3 days ago | |
| groupultra/telegram-search.github/copilot-instructions.md · 4.0k | Copilot instructions | teststyleagent-behaviour | 76/100 | 3 days ago | |
| groupultra/telegram-searchAGENTS.md · 4.0k | AGENTS.md | setupbuildtestlint-format+10 | 83/100 | 3 days ago |
Diff against .cursor/rules/testing.mdc Diff against .cursor/rules/architecture.mdc Diff against .cursor/rules/client.mdc Diff against .cursor/rules/contributing.mdc Diff against .cursor/rules/core.mdc Diff against .cursor/rules/db.mdc Diff against .cursor/rules/events.mdc Diff against .cursor/rules/frontend-web.mdc Diff against .cursor/rules/pglite-inspector.mdc Diff against .cursor/rules/tooling.mdc Diff against .github/copilot-instructions.md Diff against AGENTS.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago |
