API Endpoint Migration Map: Strapi → NestJS
Migration Status Overview
Purpose: Complete mapping of frontend API calls that need NestJS implementation
Priority: CRITICAL - Dev agent must implement missing endpoints before frontend integration
Context: Frontend currently uses Strapi API contracts, must migrate to NestJS
Frontend API Usage Analysis
Authentication & User Management (CRITICAL - MISSING)
| Frontend Service | Current Strapi Endpoint | Required NestJS Endpoint | Implementation Status | Priority |
|---|---|---|---|---|
User.find() | GET /users | GET /api/users | ❌ MISSING | CRITICAL |
User.getRoles() | GET /users/me | GET /api/users/me | ❌ MISSING | CRITICAL |
Auth.login() | POST /auth/local | POST /api/auth/login | ❌ MISSING | CRITICAL |
Impact: Authentication completely broken without these endpoints
Core Business Entities
| Frontend Service | Current Strapi Endpoint | Required NestJS Endpoint | Implementation Status | Priority |
|---|---|---|---|---|
Client.find() | GET /clients | GET /api/clients | ✅ EXISTS | ✅ Complete |
Client.findById() | GET /clients/{id} | GET /api/clients/{id} | ✅ EXISTS | ✅ Complete |
Client.create() | POST /clients | POST /api/clients | ✅ EXISTS | ✅ Complete |
Client.update() | PUT /clients/{id} | PUT /api/clients/{id} | ✅ EXISTS | ✅ Complete |
Client.delete() | DELETE /clients/{id} | DELETE /api/clients/{id} | ✅ EXISTS | ✅ Complete |
Sites Management
| Frontend Service | Current Strapi Endpoint | Required NestJS Endpoint | Implementation Status | Priority |
|---|---|---|---|---|
Site.find() | GET /sites | GET /api/sites | ❓ VERIFY | HIGH |
Site.create() | POST /sites | POST /api/sites | ❓ VERIFY | HIGH |
Site.update() | PUT /sites/{id} | PUT /api/sites/{id} | ❓ VERIFY | HIGH |
Site.delete() | DELETE /sites/{id} | DELETE /api/sites/{id} | ❓ VERIFY | HIGH |
Site.findById() | GET /sites/{id} | GET /api/sites/{id} | ❓ VERIFY | HIGH |
Cadastres Management
| Frontend Service | Current Strapi Endpoint | Required NestJS Endpoint | Implementation Status | Priority |
|---|---|---|---|---|
Cadastre.find() | GET /cadastres | GET /api/cadastres | ✅ EXISTS | ✅ Complete |
Cadastre.findById() | GET /cadastres/{id} | GET /api/cadastres/{id} | ✅ EXISTS | ✅ Complete |
Cadastre.delete() | DELETE /cadastres/{id} | DELETE /api/cadastres/{id} | ✅ EXISTS | ✅ Complete |
Reclamations (Tax Claims)
| Frontend Service | Current Strapi Endpoint | Required NestJS Endpoint | Implementation Status | Priority |
|---|---|---|---|---|
Reclamation.find() | GET /reclamations | GET /api/reclamations | ❓ VERIFY | HIGH |
Reclamation.findById() | GET /reclamations/{id} | GET /api/reclamations/{id} | ❓ VERIFY | HIGH |
Reclamation.delete() | DELETE /reclamations/{id} | DELETE /api/reclamations/{id} | ❓ VERIFY | HIGH |
Partners (Apporteur Affairs)
| Frontend Service | Current Strapi Endpoint | Required NestJS Endpoint | Implementation Status | Priority |
|---|---|---|---|---|
Partner.find() | GET /apporteur-affaires | GET /api/partners | ❓ VERIFY | MEDIUM |
Partner.findById() | GET /apporteur-affaires/{id} | GET /api/partners/{id} | ❓ VERIFY | MEDIUM |
Partner.delete() | DELETE /apporteur-affaires/{id} | DELETE /api/partners/{id} | ❓ VERIFY | MEDIUM |
Invoices (Factures)
| Frontend Service | Current Strapi Endpoint | Required NestJS Endpoint | Implementation Status | Priority |
|---|---|---|---|---|
Facture.find() | GET /factures | GET /api/invoices | ❓ VERIFY | MEDIUM |
Facture.findById() | GET /factures/{id} | GET /api/invoices/{id} | ❓ VERIFY | MEDIUM |
Facture.delete() | DELETE /factures/{id} | DELETE /api/invoices/{id} | ❓ VERIFY | MEDIUM |
Partner Invoices
| Frontend Service | Current Strapi Endpoint | Required NestJS Endpoint | Implementation Status | Priority |
|---|---|---|---|---|
PartnerInvoice.find() | GET /partner-invoices | GET /api/partner-invoices | ❓ VERIFY | MEDIUM |
PartnerInvoice.findById() | GET /partner-invoices/{id} | GET /api/partner-invoices/{id} | ❓ VERIFY | MEDIUM |
PartnerInvoice.update() | PUT /partner-invoices/{id} | PUT /api/partner-invoices/{id} | ❓ VERIFY | MEDIUM |
PartnerInvoice.delete() | DELETE /partner-invoices/{id} | DELETE /api/partner-invoices/{id} | ❓ VERIFY | MEDIUM |
Critical Implementation Gaps
1. User Management Module (BLOCKING)
Status: ❌ COMPLETELY MISSING
Impact: Frontend authentication broken
Required Implementation:
// Required: apps/api/src/users/users.controller.ts
@Controller('users')
export class UsersController {
@Get('me')
@UseGuards(JwtAuthGuard)
async getCurrentUser(@Request() req) {
// Return user profile with roles from Auth0
}
@Get()
@UseGuards(JwtAuthGuard)
async findAll(@Query() query) {
// List users with filtering/pagination
}
}
2. Authentication Module (BLOCKING)
Status: ❌ COMPLETELY MISSING
Impact: No login functionality
Required Implementation:
// Required: apps/api/src/auth/auth.controller.ts
@Controller('auth')
export class AuthController {
@Post('login')
async login(@Body() loginDto) {
// Auth0 token validation
}
@Get('profile')
@UseGuards(JwtAuthGuard)
async getProfile(@Request() req) {
// Extract profile from JWT
}
}
3. JWT Authentication Guard (CRITICAL)
Status: ❌ MISSING
Impact: No API security
Required Implementation:
// Required: apps/api/src/auth/guards/jwt-auth.guard.ts
@Injectable()
export class JwtAuthGuard implements CanActivate {
async canActivate(context: ExecutionContext): Promise<boolean> {
const request = context.switchToHttp().getRequest();
const token = this.extractTokenFromHeader(request);
if (!token) {
throw new UnauthorizedException();
}
try {
// Validate Auth0 JWT
const payload = await this.validateAuth0Token(token);
request.user = payload;
} catch {
throw new UnauthorizedException();
}
return true;
}
}
Existing NestJS Controllers Found
✅ Implemented:
/apps/api/src/client/client.controller.ts- Client management/apps/api/src/cadastre/cadastre.controller.ts- Cadastre management/apps/api/src/app.controller.ts- Health check
❓ Need Verification:
- Sites controller
- Reclamations controller
- Partners controller
- Invoices controller
Dev Agent Action Items
Immediate (CRITICAL - Day 1)
- Verify existing controllers - Check if sites, reclamations, partners, invoices are implemented
- Implement User Management Module - Users controller with
/meendpoint - Implement Auth Module - JWT validation guard and auth controller
- Configure Swagger - Generate OpenAPI spec for frontend type generation
Day 2-3 (HIGH)
- Implement missing controllers based on verification results
- Add authentication guards to all existing controllers
- Test all endpoints with Postman/automated tests
Day 4-5 (INTEGRATION)
- Generate OpenAPI types for frontend consumption
- Update frontend API client to use NestJS endpoints
- Integration testing frontend ↔ NestJS API
Response Data Structure Migration
Strapi Response Format (OLD)
{
"data": {
"id": 1,
"attributes": {
"nom": "Client Name",
"created_at": "2023-01-01"
}
},
"meta": {
"pagination": {...}
}
}
NestJS Response Format (NEW)
{
"id": 1,
"nom": "Client Name",
"created_at": "2023-01-01"
}
⚠️ Breaking Change: Frontend services will need response handling updates after API migration.
Verification Commands for Dev Agent
# Check existing NestJS controllers
find apps/api/src -name "*.controller.ts" -exec basename {} \;
# Verify endpoint availability
curl http://localhost:3001/api/clients
curl http://localhost:3001/api/users/me
curl http://localhost:3001/api-json # Swagger OpenAPI spec
# Test authentication
curl -H "Authorization: Bearer <token>" http://localhost:3001/api/users/me
Next Artifact Needed: auth0-integration-guide.md for JWT validation implementation