You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and hooks (`useUsersCommandControllerCreate`) — NEVER hand-write fetch/axios.
161
+
- In Server Components / Server Actions, pass `await getServerRequestConfig()`
162
+
(from `@myorg/api-client/server`) as the last arg so cookies + locale are sent.
163
+
- Wrap every Server Action body in `safeAction(...)` — it returns the typed
164
+
`{ success, data, message, error }` envelope and never throws on network errors.
165
+
Errors carry `error.correlationId` (matches the backend `x-correlation-id` header).
166
+
- Place in `_actions/` folders (excluded from routing); `revalidatePath()` after a
167
+
successful mutation.
168
+
169
+
### Testing
170
+
171
+
-**Vitest** for unit/component tests (`*.spec.ts` backend, `*.test.tsx` web),
172
+
**Playwright** for E2E (`apps/web/e2e/`). `pnpm test` runs them via turbo.
173
+
- Backend: test Actions in isolation with a mocked repository — see
174
+
`create-user.action.spec.ts` (the golden blueprint). No DB needed.
175
+
- Web: drive components like a user (type + submit) and assert behaviour — see
176
+
`universal-form.test.tsx`.
148
177
149
178
### Routing
150
179
@@ -173,7 +202,7 @@ app/[locale]/(main)/
173
202
11.`@I18n()` for messages
174
203
12. Soft deletes, UUID keys, indexes on queried columns
175
204
13.`QueryHelper.paginate()` for pagination
176
-
14. Register entities in `database.module.ts` (both arrays)
205
+
14. Register a new entity in its module's `TypeOrmModule.forFeature([...])` — `autoLoadEntities` handles the connection (no more dual-array registration)
177
206
15. Import types/enums from `@myorg/api-client` on frontend
0 commit comments