@tekyzinc/gsd-t 2.45.11 → 2.50.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +26 -5
  3. package/bin/debug-ledger.js +193 -0
  4. package/bin/gsd-t.js +259 -1
  5. package/commands/gsd-t-complete-milestone.md +2 -1
  6. package/commands/gsd-t-debug.md +48 -2
  7. package/commands/gsd-t-doc-ripple.md +148 -0
  8. package/commands/gsd-t-execute.md +102 -5
  9. package/commands/gsd-t-help.md +25 -2
  10. package/commands/gsd-t-integrate.md +41 -1
  11. package/commands/gsd-t-qa.md +26 -5
  12. package/commands/gsd-t-quick.md +39 -1
  13. package/commands/gsd-t-test-sync.md +26 -1
  14. package/commands/gsd-t-verify.md +8 -2
  15. package/commands/gsd-t-wave.md +57 -0
  16. package/docs/GSD-T-README.md +84 -1
  17. package/docs/architecture.md +9 -1
  18. package/docs/framework-comparison-scorecard.md +160 -0
  19. package/docs/requirements.md +33 -0
  20. package/examples/rules/desktop.ini +2 -0
  21. package/package.json +2 -2
  22. package/templates/CLAUDE-global.md +82 -4
  23. package/templates/stacks/_security.md +243 -0
  24. package/templates/stacks/desktop.ini +2 -0
  25. package/templates/stacks/docker.md +202 -0
  26. package/templates/stacks/firebase.md +166 -0
  27. package/templates/stacks/flutter.md +205 -0
  28. package/templates/stacks/github-actions.md +201 -0
  29. package/templates/stacks/graphql.md +216 -0
  30. package/templates/stacks/neo4j.md +218 -0
  31. package/templates/stacks/nextjs.md +184 -0
  32. package/templates/stacks/node-api.md +196 -0
  33. package/templates/stacks/playwright.md +528 -0
  34. package/templates/stacks/postgresql.md +225 -0
  35. package/templates/stacks/python.md +243 -0
  36. package/templates/stacks/react-native.md +216 -0
  37. package/templates/stacks/react.md +293 -0
  38. package/templates/stacks/redux.md +193 -0
  39. package/templates/stacks/rest-api.md +202 -0
  40. package/templates/stacks/supabase.md +188 -0
  41. package/templates/stacks/tailwind.md +169 -0
  42. package/templates/stacks/typescript.md +176 -0
  43. package/templates/stacks/vite.md +176 -0
  44. package/templates/stacks/vue.md +189 -0
  45. package/templates/stacks/zustand.md +203 -0
@@ -0,0 +1,196 @@
1
+ # Node.js API Standards
2
+
3
+ These rules are MANDATORY. Violations fail the task. No exceptions.
4
+
5
+ ---
6
+
7
+ ## 1. Service Layer Pattern
8
+
9
+ HTTP knowledge belongs in services only. Controllers are thin delegators.
10
+
11
+ ```
12
+ MANDATORY:
13
+ ├── Controllers: validate input, call service, return response — nothing else
14
+ ├── Services: all business logic, data access, external HTTP calls
15
+ └── Never import axios/fetch in controllers, hooks, or UI components
16
+ ```
17
+
18
+ **BAD:** `router.get('/users/:id', async (req, res) => { const r = await axios.get(...); res.json(r.data); })`
19
+
20
+ **GOOD:**
21
+ ```js
22
+ // controller — delegates only
23
+ router.get('/users/:id', async (req, res, next) => {
24
+ try { res.json({ data: await userService.getById(req.params.id) }); }
25
+ catch (err) { next(err); }
26
+ });
27
+ ```
28
+
29
+ ---
30
+
31
+ ## 2. Request Validation
32
+
33
+ Every endpoint must validate input. Reject unexpected fields.
34
+
35
+ ```
36
+ MANDATORY:
37
+ ├── Validate bodies, path params, and query strings with Zod or Joi schemas
38
+ ├── Use .strict() (Zod) or .unknown(false) (Joi) — reject extra fields
39
+ └── Return 400 with structured error before business logic runs
40
+ ```
41
+
42
+ **BAD:** `await orderService.create(req.body)` — raw unvalidated input
43
+
44
+ **GOOD:**
45
+ ```js
46
+ const schema = z.object({ productId: z.string().uuid(), quantity: z.number().int().min(1) }).strict();
47
+ router.post('/orders', validate(schema), async (req, res, next) => { ... });
48
+ ```
49
+
50
+ ---
51
+
52
+ ## 3. Response Formatting
53
+
54
+ All endpoints return a consistent shape.
55
+
56
+ ```
57
+ Success: { data: T, meta?: { page, total } }
58
+ Error: { error: { code: string, message: string } }
59
+ Never return raw objects, arrays, or strings at the top level.
60
+ ```
61
+
62
+ ---
63
+
64
+ ## 4. Error Handling
65
+
66
+ ```
67
+ MANDATORY:
68
+ ├── Register a global error handler middleware as the last app.use()
69
+ ├── All route handlers call next(err) on caught errors — never swallow
70
+ ├── No empty catch blocks — log at minimum, then re-throw or next(err)
71
+ ├── Log full error server-side; return sanitized response to client
72
+ └── Never include stack traces in production responses
73
+ ```
74
+
75
+ **Global error handler:**
76
+ ```js
77
+ app.use((err, req, res, next) => {
78
+ logger.error({ err, path: req.path });
79
+ const status = err.statusCode ?? 500;
80
+ const message = process.env.NODE_ENV === 'production' && status === 500
81
+ ? 'Internal server error' : err.message;
82
+ res.status(status).json({ error: { code: err.code ?? 'ERR_INTERNAL', message } });
83
+ });
84
+ ```
85
+
86
+ ---
87
+
88
+ ## 5. Middleware Order
89
+
90
+ Register in this exact order:
91
+
92
+ ```
93
+ 1. Security headers (helmet)
94
+ 2. CORS — see _security.md
95
+ 3. Body parser (express.json with size limit)
96
+ 4. Request/correlation ID
97
+ 5. Auth middleware — see _security.md
98
+ 6. Rate limiting — see _security.md
99
+ 7. Route-level validation
100
+ 8. Route handlers
101
+ 9. 404 handler
102
+ 10. Global error handler (last)
103
+ ```
104
+
105
+ ---
106
+
107
+ ## 6. Environment Config
108
+
109
+ ```
110
+ MANDATORY:
111
+ ├── All config from environment variables — no hardcoded values
112
+ ├── Never commit .env files with real values
113
+ ├── Client-side vars: VITE_ or NEXT_PUBLIC_ prefix only
114
+ ├── Never expose server secrets (DB_PASSWORD, API_KEY) to client bundles
115
+ └── Validate required env vars on startup — fail fast if missing
116
+ ```
117
+
118
+ **BAD:** `new Pool({ password: 'hardcoded123' })`
119
+
120
+ **GOOD:**
121
+ ```js
122
+ ['DATABASE_URL', 'JWT_SECRET'].forEach(k => {
123
+ if (!process.env[k]) throw new Error(`Missing env: ${k}`);
124
+ });
125
+ ```
126
+
127
+ ---
128
+
129
+ ## 7. Structured Logging
130
+
131
+ ```
132
+ MANDATORY:
133
+ ├── Use structured JSON logging (pino or winston with json transport)
134
+ ├── Never log PII — redact email, name, phone, tokens before logging
135
+ ├── Include request ID on every log line for traceability
136
+ └── No console.log in production paths
137
+ ```
138
+
139
+ **BAD:** `console.log('User:', user)` — leaks PII
140
+
141
+ **GOOD:** `logger.info({ userId: user.id, action: 'login' }, 'User authenticated')`
142
+
143
+ ---
144
+
145
+ ## 8. Health Check Endpoint
146
+
147
+ ```js
148
+ app.get('/health', (req, res) =>
149
+ res.json({ status: 'ok', uptime: process.uptime() }));
150
+ // /health/ready — also checks DB/dependency reachability
151
+ ```
152
+
153
+ ---
154
+
155
+ ## 9. Graceful Shutdown
156
+
157
+ ```
158
+ MANDATORY:
159
+ ├── Handle SIGTERM and SIGINT
160
+ ├── Stop accepting new connections immediately
161
+ ├── Drain in-flight requests (10s timeout)
162
+ └── Close DB pools before exiting
163
+ ```
164
+
165
+ ```js
166
+ const shutdown = async () => {
167
+ server.close(async () => { await db.end(); process.exit(0); });
168
+ setTimeout(() => process.exit(1), 10_000).unref();
169
+ };
170
+ process.on('SIGTERM', shutdown);
171
+ process.on('SIGINT', shutdown);
172
+ ```
173
+
174
+ ---
175
+
176
+ ## 10. Security Cross-References
177
+
178
+ These topics are covered in `_security.md` — do not duplicate here:
179
+ SQL injection, auth token storage, CORS, Content Security Policy, rate limiting, input sanitization.
180
+
181
+ ---
182
+
183
+ ## Verification Checklist
184
+
185
+ - [ ] Route handlers delegate all logic to services — no business logic in controllers
186
+ - [ ] Every endpoint has a Zod/Joi schema with strict mode (no extra fields allowed)
187
+ - [ ] All responses use `{ data }` or `{ error: { code, message } }` shape
188
+ - [ ] Global error handler registered last — no route handles errors via `res.json` directly
189
+ - [ ] No stack traces in production responses
190
+ - [ ] No silent catch blocks — all errors are logged or re-thrown
191
+ - [ ] All config from env vars — no hardcoded secrets or connection strings
192
+ - [ ] Structured JSON logging in use — no `console.log` in production paths
193
+ - [ ] No PII in log output
194
+ - [ ] `/health` endpoint returns 200 with status payload
195
+ - [ ] SIGTERM/SIGINT handlers registered with connection draining
196
+ - [ ] Security concerns (SQL injection, CORS, tokens) deferred to `_security.md`