|
| 1 | +# Create Project |
| 2 | + |
| 3 | +## Endpoint |
| 4 | + |
| 5 | +**GET** `/projects` |
| 6 | +**POST** `/projects` |
| 7 | +**PATCH** `/projects/:id` |
| 8 | +**DELETE** `/projects/:id` |
| 9 | + |
| 10 | +## Authorization |
| 11 | + |
| 12 | +- This endpoint requires the user to be authenticated as a **Moderator** or **Admin**. |
| 13 | + |
| 14 | +## Request Body |
| 15 | + |
| 16 | +| Field | Type | Description | Required | |
| 17 | +| -------------- | ---------- | -------------------------------------------- | -------- | |
| 18 | +| `name` | `string` | The name of the project. | Yes | |
| 19 | +| `githubLink` | `string` | The GitHub link of the project. | Yes | |
| 20 | +| `demoLink` | `string` | The demo link of the project. | No | |
| 21 | +| `thumbnailUrl` | `string` | The thumbnail of the project. | No | |
| 22 | +| `description` | `string` | A brief description of the project. | Yes | |
| 23 | +| `techStacks` | `string[]` | List of technologies used in the project. | Yes | |
| 24 | +| `tagIds` | `string[]` | List of tag IDs associated with the project. | No | |
| 25 | + |
| 26 | +## Example Request |
| 27 | + |
| 28 | +```json |
| 29 | +{ |
| 30 | + "name": "Routine Backend", |
| 31 | + "githubLink": "https://github.com/BIC-DevSphere/devsphere-backend", |
| 32 | + "demoLink": "N/A", |
| 33 | + "thumbnailUrl": "N/A", |
| 34 | + "description": "hdhwidwidodooeufsoife", |
| 35 | + "techStacks": ["JavaScript", "React"], |
| 36 | + "tagIds": ["defcb3cf-6199-4cfa-8957-d340869c8129"] |
| 37 | +} |
| 38 | +``` |
| 39 | + |
| 40 | +## Responses |
| 41 | + |
| 42 | +### Success Response |
| 43 | + |
| 44 | +```json |
| 45 | +{ |
| 46 | + "success": true, |
| 47 | + "message": "Project added successfully", |
| 48 | + "code": 200, |
| 49 | + "data": { |
| 50 | + "id": "edbadd2d-f906-4143-8260-2ce2f12a53f7", |
| 51 | + "name": "Routine Backend", |
| 52 | + "githubLink": "https://github.com/BIC-DevSphere/devsphere-backend", |
| 53 | + "demoLink": null, |
| 54 | + "tech_stack": ["JavaScript", "React"], |
| 55 | + "description": "hdhwidwidodooeufsoife", |
| 56 | + "thumbnailUrl": null, |
| 57 | + "createdAt": "2025-09-21T18:14:35.091Z", |
| 58 | + "updatedAt": "2025-09-21T18:14:35.091Z" |
| 59 | + } |
| 60 | +} |
| 61 | +``` |
| 62 | + |
| 63 | +### Error Responses |
| 64 | + |
| 65 | +**Status Code:** `400 Bad Request` |
| 66 | + |
| 67 | +- On invalid or missing fields: |
| 68 | + |
| 69 | +```json |
| 70 | +{ |
| 71 | + "success": false, |
| 72 | + "error": "Invalid request body", |
| 73 | + "code": 400, |
| 74 | + "details": [ |
| 75 | + { |
| 76 | + "field": "thumbnailUrl", // Example field |
| 77 | + "message": "Invalid thumbnail URL", |
| 78 | + "code": "invalid_format" |
| 79 | + } |
| 80 | + ] |
| 81 | +} |
| 82 | +``` |
| 83 | + |
| 84 | +- Validation errors: |
| 85 | + |
| 86 | +```json |
| 87 | +{ |
| 88 | + "success": false, |
| 89 | + "error": "Invalid request body", |
| 90 | + "code": 400, |
| 91 | + "details": [ |
| 92 | + { |
| 93 | + "field": "description", |
| 94 | + "message": "Description is required", |
| 95 | + "code": "invalid_type" |
| 96 | + } |
| 97 | + ] |
| 98 | +} |
| 99 | +``` |
| 100 | + |
| 101 | +- **Status Code:** `401 Unauthorized` |
| 102 | + |
| 103 | +```json |
| 104 | +{ |
| 105 | + "success": false, |
| 106 | + "error": "Unauthorized", |
| 107 | + "code": 401 |
| 108 | +} |
| 109 | +``` |
0 commit comments