yn-be-developer-typescript
Backend TypeScript – Best Practices & Skills
This skill provides guidance for working on TypeScript backend projects that follow this pattern: structure under src/, ESM, Express, PostgreSQL/MongoDB, and tests with Mocha + tsx. Align with refactor.md, test.md, doc.md, and create-project.md in commands/ when refactoring, testing, documenting, or creating new projects.
When to Use
- Writing new controllers, models, or utilities in TypeScript
- Creating or updating tests (
.test.ts, Mocha + tsx/cjs) - Implementing features in a codebase that uses
src/,env.pgConnection,env.pgModels - Reviewing or refactoring TypeScript backend code
- Generating OpenAPI docs or new project scaffolds
Core Technologies
Runtime & Language
- Node.js: ESM (
"type": "module"), run with tsx (or compileddist/with node) - TypeScript: Strict mode,
.tsonly under src/ (and config/ if needed) - Imports: Use .js extension in import paths for ESM resolution (e.g.
from "./app.js"); tsx/Node resolve to.tswhen needed. No.mjs. - No dynamic imports in handlers: Do not use
await import(...)inside controller/model method bodies for normal dependencies. Resolve imports at module scope (or in a dedicated adapter module) to keep types and behavior explicit.
More from marco-meini/cursor
test-from-target
Generates or updates Mocha-style test suites (.test.ts) from a target class or method. Use when writing tests from controller/model/lib code, when the user asks to test a class or method, or when adding test coverage for a specific target. Assumes TypeScript, ESM, Mocha with tsx/cjs, source under src/, tests under test/.
4api-http-test
Run realistic HTTP API tests against real endpoints with project-scoped TOML profiles and auth credentials. Use when the user wants to simulate real API calls, validate auth flows, debug status codes/payloads, or initialize API test config with `/api-http-test install`.
3openapi-doc-from-controller
Creates or updates one OpenAPI YAML fragment from a single controller method. Use when documenting API endpoints, adding OpenAPI path items from Express routes, or when the user asks to document an endpoint or update docs from controller code.
2