- docs: https://docs.google.com/document/d/1pCdrbqCXFOat7dLoNG91BZaSON4g-3R_2e0dbLvyQ8E/edit?usp=sharing
- how to handle posting images with coolify (url to the img?, etc.)
- if url, update postModel
- if url, update createPost service
- if url, update README docs on Post endpoints
- simple setup, project structure, prettier(done)/eslint(maybe)
- create
.env
file for important env_vars likeMONGO_URI
- be able to connect to mongodb (via container rn)
- dockerize for easy dev env and prod builds
- create schemas
- create comment schema
- services/handlers
- conrollers/routes
- endpoint:
/organizations
-> CRUD - endpoint:
/users
-> CRUD - endpoint:
/posts
-> CRUD - endpoint:
/comments
-> CRUD
- endpoint:
- auth and validation
- integrate LSCS Central Auth service for auth
- only verify JWT generated by the auth service (don't handle refresh tokens directly) - using public key (asymmetric key) or shared secret (symmetric key)
- ensure protected routes -> ex. users can only view their own org posts
- ...
- add DOCUMENTATION for the
endpoints
(for the frontend to consume)- docs:
postsRouter
- docs:
usersRouter
- docs:
orgsRouter
- docs:
commentsRouter
- docs:
- start via
docker
:
docker compose up -d
- test connection via
curl
-> should return "HEALTHY"
curl http://localhost:3500/
- stop when done
docker compose down
- prod:
npm run start
- NOTE: All routes has GET, POST, PUT, DELETE endpoints
- gets information on ALL posts
- gets the information about a post given an id
- example
response
:{ "_id": "64c1e8e9e4b08f001a4cdb22", "title": "LSCS Blog \#7", "content": "Main content goes here... example content", "comments": [ { "_id": "64c1e8f2e4b08f001a4cdb23", "content": "Great insights! AI is indeed transforming the tech landscape.", "created_on": "2024-10-28T15:25:30.000Z", "author": { "_id": "64c1e870e4b08f001a4cdb20", "username": "jane.doe", "email": "jane.doe@example.com" }, "org_id": { "_id": "64c1e8c5e4b08f001a4cdb21", "name": "Tech Innovators Inc.", "slug": "tech-innovators" }, "post_id": "64c1e8e9e4b08f001a4cdb22", "createdAt": "2024-10-28T15:25:30.000Z", "updatedAt": "2024-10-28T15:26:00.000Z" }, { "_id": "64c1e8fae4b08f001a4cdb24", "content": "Thanks for sharing! Looking forward to more articles on this topic.", "created_on": "2024-10-28T15:30:00.000Z", "author": { "_id": "64c1e871e4b08f001a4cdb25", "username": "john.smith", "email": "john.smith@example.com" }, "org_id": { "_id": "64c1e8c5e4b08f001a4cdb21", "name": "Tech Innovators Inc.", "slug": "tech-innovators" }, "post_id": "64c1e8e9e4b08f001a4cdb22", "createdAt": "2024-10-28T15:30:00.000Z", "updatedAt": "2024-10-28T15:31:00.000Z" } ], "featured_img": { "data": "<base64_encoded_image_data>", "imgType": "image/png" }, "created_on": "2024-10-28T15:20:30.000Z", "author": [ { "_id": "64c1e870e4b08f001a4cdb20", "username": "jane.doe", "email": "jane.doe@example.com" } ], "category": "Technology", "org_id": { "_id": "64c1e8c5e4b08f001a4cdb21", "name": "Tech Innovators Inc.", "slug": "tech-innovators" }, "createdAt": "2024-10-28T15:20:30.000Z", "updatedAt": "2024-10-28T15:45:10.000Z" }
- creates a new post (checks if org_id is valid)
- needs JWT token in the request headers
- example
request
:
curl -X POST http://localhost:3500/posts \
-H "Authorization: Bearer <JWT>" \
-H "Content-Type: application/json"
-d '{
"title": "New Post Title",
"content": "This is the content of the post.",
"comments": [],
"featured_img": {
"data": "<base64_encoded_image_data>",
"imgType": "image/jpeg"
},
"category": "News"
}'
- gets information on ALL users
- gets information on ALL organization
- gets information on ALL comments
- gets the information about a user given an id
- example
response
:{ "_id": "64c1e870e4b08f001a4cdb20", "org_id": { "_id": "64c1e8c5e4b08f001a4cdb21", "name": "Tech Innovators Inc.", "slug": "tech-innovators", "admin_id": "64c1e872e4b08f001a4cdb30" }, "username": "jane.doe", "email": "jane.doe@example.com", "password": "hashed_password", // Note: In practice, do not expose password details "createdAt": "2024-10-01T10:15:30.000Z", "updatedAt": "2024-10-28T15:00:00.000Z" }
- gets the information about an organization given an id
- example
response
:{ "_id": "64c1e8c5e4b08f001a4cdb21", "admin_id": { "_id": "64c1e872e4b08f001a4cdb30", "username": "admin.john", "email": "admin.john@example.com" }, "name": "Tech Innovators Inc.", "slug": "tech-innovators", "createdAt": "2024-09-15T09:00:00.000Z", "updatedAt": "2024-10-28T14:00:00.000Z", "members": [ { "_id": "64c1e870e4b08f001a4cdb20", "username": "jane.doe", "email": "jane.doe@example.com" }, { "_id": "64c1e871e4b08f001a4cdb25", "username": "john.smith", "email": "john.smith@example.com" } ] }
- gets the information about a comment given an id
- example
response
:{ "_id": "64c1e8f2e4b08f001a4cdb23", "content": "Great insights! AI is indeed transforming the tech landscape.", "created_on": "2024-10-28T15:25:30.000Z", "author": { "_id": "64c1e870e4b08f001a4cdb20", "username": "jane.doe", "email": "jane.doe@example.com" }, "org_id": { "_id": "64c1e8c5e4b08f001a4cdb21", "name": "Tech Innovators Inc.", "slug": "tech-innovators" }, "post_id": "64c1e8e9e4b08f001a4cdb22", "createdAt": "2024-10-28T15:25:30.000Z", "updatedAt": "2024-10-28T15:26:00.000Z" },