Skip to content

Commit 3bc10da

Browse files
authored
Merge pull request #44 from adgator101/develop
Introduced Project Functionality with github API implementation
2 parents bbf0111 + 0014581 commit 3bc10da

17 files changed

Lines changed: 1028 additions & 8 deletions

.env.example

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
DATABASE_URL=
22
CORS_ORIGIN=
33
BETTER_AUTH_SECRET=
4-
BETTER_AUTH_URL=
4+
BETTER_AUTH_URL=
5+
NODE_ENV=
6+
JWT_ACCESS_SECRET=
7+
JWT_REFRESH_SECRET=
8+
GITHUB_TOKEN=

docs/Project/CREATEPROJECT.MD

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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+
```

docs/Project/LISTPROJECT.MD

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# List Projects
2+
3+
## Endpoint
4+
5+
**GET** `/projects`
6+
7+
## Authorization
8+
9+
- This endpoint is public and does not require authentication.
10+
11+
## Example Response
12+
13+
```json
14+
{
15+
"success": true,
16+
"message": "Fetched Sucessfully",
17+
"code": 200,
18+
"data": {
19+
"success": true,
20+
"data": [
21+
{
22+
"id": "1",
23+
"name": "Devsphere",
24+
"githubLink": "https://github.com/BIC-DevSphere/devsphere-backend",
25+
"demoLink": null,
26+
"tech_stack": ["JavaScript", "React"],
27+
"tags": [
28+
{
29+
"id": "1",
30+
"name": "Web"
31+
}
32+
],
33+
"contributors": [
34+
{
35+
"id": "1",
36+
"name": "Test",
37+
"avatarUrl": "https://avatars.githubusercontent.com/contributor-1",
38+
"githubUsername": "samTime101"
39+
}
40+
],
41+
"description": "hdhwidwidodooeufsoife",
42+
"createdAt": "2025-09-21T18:14:35.091Z",
43+
"updatedAt": "2025-09-21T18:16:11.461Z"
44+
}
45+
]
46+
}
47+
}
48+
```

docs/Project/UPDATEPROJECT.MD

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Update Project
2+
3+
# Endpoint
4+
5+
- **PATCH** `/projects/:id`
6+
7+
# Authorization
8+
9+
- This endpoint requires the user to be authenticated as a **Moderator** or **Admin**.
10+
11+
# Request Body
12+
13+
| Field | Type | Description | Required |
14+
| -------------- | ---------- | -------------------------------------------- | -------- |
15+
| `name` | `string` | The name of the project. | No |
16+
| `githubLink` | `string` | The GitHub link of the project. | No |
17+
| `demoLink` | `string` | The demo link of the project. | No |
18+
| `thumbnailUrl` | `string` | The thumbnail of the project. | No |
19+
| `description` | `string` | A brief description of the project. | No |
20+
| `techStacks` | `string[]` | List of technologies used in the project. | Yes |
21+
| `tagIds` | `string[]` | List of tag IDs associated with the project. | No |
22+
23+
# Example Request Body
24+
25+
```json
26+
{
27+
"name": "Devsphere",
28+
"tagIds": ["2"],
29+
"techStacks": ["JavaScript", "React"]
30+
}
31+
```
32+
33+
# Example Response
34+
35+
```json
36+
{
37+
"success": true,
38+
"message": "Project updated successfully",
39+
"code": 200,
40+
"data": {
41+
"id": "edbadd2d-f906-4143-8260-2ce2f12a53f7",
42+
"name": "Devsphere",
43+
"githubLink": "https://github.com/BIC-DevSphere/devsphere-backend",
44+
"demoLink": null,
45+
"tech_stack": ["JavaScript", "React"],
46+
"description": "hdhwidwidodooeufsoife",
47+
"thumbnailUrl": null,
48+
"createdAt": "2025-09-21T18:14:35.091Z",
49+
"updatedAt": "2025-09-21T18:16:11.461Z"
50+
}
51+
}
52+
```
53+
54+
# Note
55+
- The PATCH request accepts the same fields as the POST request, but all fields are optional.
56+
- To remove a tag from a project, send all tags except the one to be removed.
57+
E.g. If you have the following tags
58+
59+
```json
60+
["tag1", "tag2", "tag3"]
61+
```
62+
63+
To remove `tag2`, send in `tagIds` field
64+
65+
```json
66+
["tag1", "tag3"]
67+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ErrorResponse, SuccessResponse } from "@/dtos";
2+
import { contributorServices } from "@/services/contributor.service";
3+
import { HTTP } from "@/utils/constants";
4+
import type { Request, Response } from "express";
5+
6+
class ContributorController {
7+
async getContributors(req: Request, res: Response) {
8+
try {
9+
const contributors = await contributorServices.getAllContributors();
10+
11+
if (!contributors.success || !contributors.data) {
12+
return res
13+
.status(HTTP.BAD_REQUEST)
14+
.json(ErrorResponse(HTTP.BAD_REQUEST, contributors.error));
15+
}
16+
return res
17+
.status(HTTP.OK)
18+
.json(SuccessResponse(HTTP.OK, "Contributors fetched successfully", contributors.data));
19+
} catch (error) {}
20+
}
21+
}
22+
23+
export const contributorController = new ContributorController();

0 commit comments

Comments
 (0)