|
| 1 | +# Contributing to Quest Service |
| 2 | + |
| 3 | +Thanks for your interest in contributing! This guide is intentionally short — it covers the **three things** that will get your PR merged fastest. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## 1. Local setup (one command) |
| 8 | + |
| 9 | +```bash |
| 10 | +# Prereqs: Node 20+, npm 10+, Docker (for Postgres/Redis/RabbitMQ) |
| 11 | +nvm use # picks up the version pinned in .nvmrc |
| 12 | +npm install |
| 13 | +npm run setup # creates .env from .env.example and brings up docker |
| 14 | +``` |
| 15 | + |
| 16 | +> If you don't use Docker, edit `.env` to point at a local Postgres/Redis/RabbitMQ. |
| 17 | +
|
| 18 | +Verify the install with a quick smoke test: |
| 19 | + |
| 20 | +```bash |
| 21 | +npm run typecheck # zero errors expected |
| 22 | +npm run lint # zero errors expected |
| 23 | +npm test # unit tests pass |
| 24 | +``` |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +## 2. Before opening a PR — run this checklist |
| 29 | + |
| 30 | +Run the same checks CI runs: |
| 31 | + |
| 32 | +```bash |
| 33 | +npm run lint |
| 34 | +npm run format:check |
| 35 | +npm run typecheck |
| 36 | +npm test |
| 37 | +``` |
| 38 | + |
| 39 | +All four must pass. If `format:check` fails, run `npm run format` to auto-fix. |
| 40 | + |
| 41 | +### Style at a glance |
| 42 | + |
| 43 | +- **TypeScript**: 2-space indent, single quotes, trailing commas, semicolons (see `.editorconfig` + `.prettierrc`). |
| 44 | +- **NestJS**: one module per folder under `src/`. Each module exports a `*.module.ts` plus a controller, service, and DTOs. |
| 45 | +- **Naming**: `kebab-case` for files & folders, `PascalCase` for classes, `camelCase` for variables/functions. |
| 46 | +- **Imports**: use the explicit relative path (e.g. `../users/users.module`) — avoid deep `@/` aliases unless one already exists. |
| 47 | +- **Don't**: disable ESLint rules, add `// @ts-ignore`, or weaken `tsconfig.json` to make errors go away. Fix the code. |
| 48 | + |
| 49 | +### Common bug sources to avoid |
| 50 | + |
| 51 | +| Symptom | Fix | |
| 52 | +| --- | --- | |
| 53 | +| `Type 'undefined' is not assignable` after an `await` | Add a null-check or use `?? defaultValue` | |
| 54 | +| Service method returns `Promise<undefined>` | Return a value or annotate as `Promise<void>` | |
| 55 | +| Config value is `string \| undefined` | Use `configService.get<...>('KEY', defaultValue)` and provide a default | |
| 56 | +| Circular dependency crash | Move shared code into a third module; never import services across `app.module.ts` siblings | |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +## 3. PR rules |
| 61 | + |
| 62 | +- **One concern per PR.** Don't bundle a refactor with a feature. |
| 63 | +- **Reference an issue** with `Fixes #123` in the description. |
| 64 | +- **Add or update tests** for any behavior change. New code without a test will be asked to add one. |
| 65 | +- **Fill in the PR template** (`.github/PULL_REQUEST_TEMPLATE.md`). The CI bot blocks PRs that don't. |
| 66 | +- **Keep diffs small.** Aim for <300 lines changed. Large refactors should be split. |
| 67 | + |
| 68 | +A maintainer will review within 2 business days. If you don't hear back, ping the issue. |
| 69 | + |
| 70 | +--- |
| 71 | + |
| 72 | +## Reporting bugs |
| 73 | + |
| 74 | +Use the **Bug report** issue template at `.github/ISSUE_TEMPLATE/bug_report.md`. A great bug report includes: |
| 75 | + |
| 76 | +1. What you did (steps to reproduce) |
| 77 | +2. What you expected |
| 78 | +3. What happened (logs/screenshots) |
| 79 | +4. Environment: OS, Node version, branch, commit SHA |
| 80 | + |
| 81 | +Security issues: see `SECURITY.md` (or open a private security advisory — **do not** file a public issue). |
| 82 | + |
| 83 | +--- |
| 84 | + |
| 85 | +## Project layout (the short version) |
| 86 | + |
| 87 | +``` |
| 88 | +src/ |
| 89 | + app.module.ts # root composition root — add new modules here |
| 90 | + main.ts # bootstrap, helmet, cors, validation, sentry |
| 91 | + config/ # env validation + app config |
| 92 | + common/ # filters, interceptors, pipes, decorators |
| 93 | + <feature>/ # one folder per feature module |
| 94 | + <feature>.module.ts |
| 95 | + <feature>.controller.ts |
| 96 | + <feature>.service.ts |
| 97 | + dto/ |
| 98 | + entities/ |
| 99 | + tests/ # *.spec.ts colocated with source |
| 100 | +``` |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +## Need help? |
| 105 | + |
| 106 | +Open a question in Discussions, or ask in the PR — there's no such thing as a dumb question. |
0 commit comments