Code Style
Code Style
Section titled “Code Style”TypeScript
Section titled “TypeScript”strict: trueeverywhere —tsc --noEmitmust report 0 errors.- No
anywithout justification — preferunknown+ type guards. - No
@ts-ignore— use@ts-expect-errorwith a reason. - Use
consistent-type-imports. - Write compact code: collapse duplicate branches, avoid needless nesting, share abstractions instead of copy-pasting.
- Match the existing style of the file/module you are editing — look at neighboring code before introducing new patterns.
Property header (mandatory)
Section titled “Property header (mandatory)”Every source file must begin with the property header:
// ==============================================================================// Property of Ralf Carsjens - All Rights Reserved.// Proprietary and Confidential.// Unauthorized copying of this file, via any medium, is strictly prohibited.// Standard: ISO 27001 Compliance | Security-First | Modular API Architecture// ==============================================================================Exceptions: standard JSON files (package.json, tsconfig.json),
generated files (dist/, .next/, node_modules/), lockfiles.
Language
Section titled “Language”- Code, identifiers, and code comments: English.
- User-facing UI strings: via
next-intlmessages (German default). - Explanations and documentation for the owner: German; developer-facing technical documentation (this site): English.
Error handling
Section titled “Error handling”- Handle errors at meaningful boundaries — not every line needs a
try/catch. Follow the error-handling style of the surrounding code. - Throw specific error classes; the global exception filter maps them to
TT-xxxcodes — see Error Codes.
Input validation & security basics
Section titled “Input validation & security basics”- Every API endpoint validates input (DTOs +
class-validator). - No string interpolation in SQL — parameterized queries / Prisma only.
- File operations on user input require path sanitization.
- No
eval()or dynamic code execution. NodangerouslySetInnerHTMLexcept sanitized/static content. - No PII in logs — no emails, names, addresses in
logger.*output or test output.
Testing conventions
Section titled “Testing conventions”- A
setup()function per spec file encapsulates wiring (no sharedbeforeEachstate). - Assert specific error classes:
rejects.toThrow(SpecificError). - Verify tenant isolation in every service test.
- No
anyin tests except where strictly needed for mocks. - No PII in fixtures — synthetic UUIDs,
example.comaddresses.