Prerequisites Before running the server, make sure you have the following dependencies installed:
- Node.js (v14 or later)
- NPM (Node Package Manager)
- MongoDB (with the connection URL provided in the environment variable MONGODB_URL)
- Cloudinary Account (with API credentials stored in environment variables ClOULDINARY_CLOUD_NAME, ClOULDINARY_API_KEY, and ClOULDINARY_API_SECRET)
- OpenAI API Key (stored in the environment variable OPENAI_API_KEY)
MONGODB_URL=your-mongodb-connection-url ClOULDINARY_CLOUD_NAME=your-cloudinary-cloud-name ClOULDINARY_API_KEY=your-cloudinary-api-key ClOULDINARY_API_SECRET=your-cloudinary-api-secret OPENAI_API_KEY=your-openai-api-key
run :
npm start
Your server will be available at http://localhost:8080
- 1. /api/v1/post (Post Routes)
- GET /api/v1/post
Request Type: GET
- Response:
- Status Code: 200 OK
- Content-Type: application/json
-
Error Responses:
- Status Code: 500 Internal Server Error
- Content-Type: application/json
- Request Type: POST
- Request Body:
- Content-Type: application/json
{ "name": "Post Name", "prompt": "DALL-E Prompt", "photo": "Base64-encoded image data" }
- Status Code: 201 Created
- Content-Type: application/json
{ "success": true, "data": { "name": "Post Name", "prompt": "DALL-E Prompt", "photo": "URL to the uploaded image" } }