|
1 | 1 | # AGENTS.md — Quick Guide for Coding Agents |
| 2 | + |
2 | 3 | Scope: entire repo. Always branch first (feature/... or fix/...), never commit to master/main. |
3 | 4 | Build/run: `npm ci`; dev: `npm run dev`; prod: `npm start`. |
4 | 5 | Health check: `npm run ping` or `curl http://localhost:3000/ping`. |
5 | | -Tests: none configured; use curl/manual checks. If Jest is added: `npx jest path/to.test.js -t "name"` for single tests. |
6 | | -Lint/format: ESLint v9+ is configured (see eslint.config.js). Use 2‑space indent, single quotes, semicolons, trailing newline. Run `npx eslint . --ext .js` before committing. |
| 6 | +Tests: Jest configured; use `npx jest path/to.test.js -t "name"` for single tests. |
| 7 | +Lint/format: ESLint v9+ is configured (see eslint.config.js). Use 2-space indent, single quotes, semicolons, trailing newline. Run `npx eslint . --ext .js` before committing. |
7 | 8 | Modules: CommonJS only (`require`/`module.exports`). Do not introduce ESM. |
8 | | -Imports: group built‑in, deps, local; use relative paths (`./`, `../`). Avoid deep coupling. |
| 9 | +Imports: group built-in, deps, local; use relative paths (`./`, `../`). Avoid deep coupling. |
9 | 10 | Types: plain JS; add JSDoc for complex functions. Do not add TS files unless requested. |
10 | 11 | Naming: camelCase vars/functions; PascalCase classes; UPPER_SNAKE for constants/env. |
11 | 12 | Errors: validate inputs; respond JSON `{ ok:false, error }` with correct HTTP codes; avoid uncaught throws in handlers. |
12 | | -Logging: use `logger.js` helpers (`httpLogger`, `wireSocketLogging`, `appLogger`). Never log secrets. |
13 | | -MongoDB: reuse a single client (no per‑request connects). Keep auth state in `mongoAuthState.js`. |
14 | | -Routes: define in `routes.js` as `[{ method, path, handler }]`; use `req.app.locals.whatsapp_socket`. |
15 | | -Socket lifecycle: in `index.js`; don’t change without need; keep HTTP and socket separate. |
| 13 | +Logging: use `src/logger.js` helpers (`httpLogger`, `wireSocketLogging`, `appLogger`). Never log secrets. |
| 14 | +MongoDB: reuse a single client (no per-request connects). Keep auth state in `src/mongoAuthState.js`. |
| 15 | +Routes: define in `src/routes.js` as `[{ method, path, handler }]`; use `req.app.locals.whatsapp_socket`. |
| 16 | +Socket lifecycle: in `src/index.js`; don't change without need; keep HTTP and socket separate. |
| 17 | +Middleware: auth in `src/middleware/authMiddleware.js`; webhooks in `src/middleware/webhookSecurityMiddleware.js`. |
| 18 | +Validators: schemas in `src/validators/validationSchemas.js`; apply with `validateRequest` middleware. |
16 | 19 | Env vars: `HOST`, `PORT`, `MONGO_URL`, `DB_NAME`; keep README and `.env.example` in sync. |
17 | 20 | API shape: return `{ ok: boolean, ... }`; keep endpoints small and testable. |
18 | 21 | Docs: update `docs/API_Reference.md` and `README.md` when adding/modifying endpoints. |
|
0 commit comments