- Test:
pnpm test(runs all tests) orNODE_ENV=test node --test --test-reporter spec path/to/specific.test.js(single test) - Test with coverage:
pnpm run test:cov - Lint:
npx eslint .(uses @antfu/eslint-config) - Dev:
pnpm dev(starts with nodemon)
- ES Modules: Use
import/exportsyntax, file extension.js - Imports: Node.js modules with
node:prefix (import fs from 'node:fs/promises') - Naming: camelCase for variables/functions, kebab-case for files
- Async: Prefer
async/awaitover promises, usetry/catchfor error handling - Comments: JSDoc style for functions, inline for complex logic
- Plugins: Use
fastify-pluginwrapper withfp()and explicitnameoption - Logging: Use
fastify.logmethods (info, warn, error, debug) - Config: Import from
./config.js, destructure options as needed
- Return structured error objects with
code(),send()for HTTP responses - Use
reply.code(statusCode).send({ error: 'message' })pattern - Catch and log errors appropriately, don't expose internal details
- Use Node.js built-in test runner (
node --test) - Test files in
test/directory with.test.jssuffix - Set
NODE_ENV=testfor test runs