2.6 KiB
2.6 KiB
Strapi Integration - Complete ✅
What Was Added
Backend Updates
- Fixed SQLite enum issue: Changed Article.status from enum type to text type (SQLite doesn't support enum)
- Fixed entity initialization order: Moved Author and Category definitions before Article to avoid circular reference errors
- Fixed SQLite array issue: Changed tags from simple-array to text type (SQLite doesn't support arrays)
- Added Strapi integration:
strapi.service.ts- Service for syncing content from Strapistrapi.controller.ts- Webhook endpoint controllerstrapi.module.ts- Module containing Strapi functionality
- Installed dependencies:
@nestjs/axiosfor HTTP requests to Strapi API - Updated CORS: Added Strapi URL to allowed origins
- Updated environment variables: Added STRAPI_URL and STRAPI_API_TOKEN
Database Schema
- Authors table with id, name, slug, bio, avatar, isActive, timestamps
- Categories table with id, name, slug, description, parentId, order, timestamps
- Articles table with id, title, content, excerpt, slug, featuredImage, tags (text), status (text), views, strapiId, authorId, categoryId, timestamps
Configuration
- Updated
backend/src/app.module.tsto include StrapiModule - Updated
backend/.env.examplewith Strapi configuration - Created
STRAPI_INTEGRATION.mdwith detailed setup instructions - Updated
SETUP_COMPLETE.mdwith Strapi integration info
Next Steps
- Start all services:
# Terminal 1 - Backend
cd backend
npm run start:dev
# Terminal 2 - Frontend
cd frontend
npm run dev
# Terminal 3 - Strapi
cd cms/cms
npm run develop
-
Configure Strapi (see STRAPI_INTEGRATION.md):
- Create content types: Article, Author, Category, Tag
- Create API token
- Configure webhook pointing to backend
- Add API token to backend
.env
-
Test the integration:
- Create an article in Strapi
- Publish it
- Check backend:
curl http://localhost:3000/api/v1/articles - Verify it appears in frontend
Webhook Flow
- Content created/updated in Strapi → 2. Strapi sends webhook to backend → 3. Backend fetches content from Strapi API → 4. Backend syncs to SQLite database → 5. Frontend queries backend API
API Endpoints Added
POST /api/v1/webhooks/strapi/article- Handle Strapi webhooksPOST /api/v1/webhooks/strapi/sync/all- Manual full sync trigger
Fixed Issues
✅ SQLite enum type not supported - changed to text ✅ Circular entity reference - reordered definitions ✅ Frontend routeTree not exported - added export ✅ All TypeScript errors resolved ✅ All linting errors resolved
All services are ready to run!