refactor(api): refactor API module with route definitions and response utilities

Restructure the core API module to improve clarity, consistency, and
maintainability:

- Introduce `defineApiRoutes()` helper for declarative route definitions
  with built-in config validation at startup
- Add `apiSuccess()` / `apiError()` response utilities; enforce their
  use across all handlers (core and modules)
- Move auth enforcement to route definitions (`auth: 'public' | 'user' |
  'admin'`), removing manual auth checks from handlers
- Extract core routes into `core-routes.js`; router now has no knowledge
  of specific features
- Rename `nx-route.js` to `route-handler.js` and update package.json
  export accordingly
- Update ARCHITECTURE.md to reflect new API conventions and point to
  `src/core/api/README.md` for details
This commit is contained in:
2026-04-13 15:13:03 -04:00
parent 89741d4460
commit 4ddf834990
25 changed files with 1261 additions and 1185 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ export default defineConfig([
'src/features/admin/pages.js',
'src/features/admin/components/index.js',
'src/core/api/index.js',
'src/core/api/nx-route.js',
'src/core/api/route-handler.js',
'src/core/database/index.js',
'src/cli/database.js',
'src/core/email/index.js',