Overview
The Projects API allows you to create, read, update, and delete portfolio projects. All write operations require authentication.
Get All Projects
GET /api/projects
Retrieve all projects, ordered by the order field in ascending order.
This endpoint is public and does not require authentication.
Response
Returns an array of project objects:
Unique project identifier
URL or path to project image
Array of technology names used in the project
GitHub repository URL (optional)
Display order (lower numbers appear first)
Example Request
curl https://andreruperto.dev/api/projects
const response = await fetch('https://andreruperto.dev/api/projects');
const projects = await response.json();
console.log(projects);
Example Response
[
{
"id": 1,
"title": "E-commerce Platform",
"description": "Full-stack e-commerce solution with React and Node.js",
"image": "/images/ecommerce.png",
"technologies": ["React", "Node.js", "PostgreSQL", "Stripe"],
"githubUrl": "https://github.com/andreruperto/ecommerce",
"liveUrl": "https://demo.ecommerce.com",
"order": 1
},
{
"id": 2,
"title": "Data Analytics Dashboard",
"description": "Real-time analytics dashboard with Python and React",
"image": "/images/analytics.png",
"technologies": ["Python", "React", "D3.js", "MongoDB"],
"githubUrl": "https://github.com/andreruperto/analytics",
"liveUrl": null,
"order": 2
}
]
{
"error": "Erro ao buscar projetos"
}
Create Project
POST /api/projects
Create a new portfolio project.
This endpoint requires authentication. Include a valid JWT token in the Authorization header.
Request Body
URL or path to project image
Array of technology names
Display order (default: 0)
Example Request
curl -X POST https://andreruperto.dev/api/projects \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{
"title": "New Project",
"description": "Amazing new project",
"technologies": ["React", "TypeScript"],
"order": 3
}'
const response = await fetch('https://andreruperto.dev/api/projects', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
title: 'New Project',
description: 'Amazing new project',
technologies: ['React', 'TypeScript'],
order: 3
})
});
const project = await response.json();
Example Response
{
"id": 3,
"title": "New Project",
"description": "Amazing new project",
"image": null,
"technologies": ["React", "TypeScript"],
"githubUrl": null,
"liveUrl": null,
"order": 3
}
Error - Unauthorized (401)
{
"error": "Token não fornecido"
}
Error - Server Error (500)
{
"error": "Erro ao criar projeto"
}
Update Project
PUT /api/projects/:id
Update an existing project.
This endpoint requires authentication. Include a valid JWT token in the Authorization header.
Path Parameters
Request Body
Same as Create Project - all fields are optional, only provided fields will be updated.
Example Request
curl -X PUT https://andreruperto.dev/api/projects/3 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{
"title": "Updated Project Title",
"liveUrl": "https://new-live-url.com"
}'
const response = await fetch('https://andreruperto.dev/api/projects/3', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
title: 'Updated Project Title',
liveUrl: 'https://new-live-url.com'
})
});
const updatedProject = await response.json();
Example Response
{
"id": 3,
"title": "Updated Project Title",
"description": "Amazing new project",
"image": null,
"technologies": ["React", "TypeScript"],
"githubUrl": null,
"liveUrl": "https://new-live-url.com",
"order": 3
}
Error - Unauthorized (401)
{
"error": "Token inválido"
}
Error - Server Error (500)
{
"error": "Erro ao atualizar projeto"
}
Delete Project
DELETE /api/projects/:id
Delete a project permanently.
This endpoint requires authentication and cannot be undone.
Path Parameters
Example Request
curl -X DELETE https://andreruperto.dev/api/projects/3 \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
const response = await fetch('https://andreruperto.dev/api/projects/3', {
method: 'DELETE',
headers: {
'Authorization': `Bearer ${token}`
}
});
const result = await response.json();
Example Response
{
"message": "Projeto deletado"
}
Error - Unauthorized (401)
{
"error": "Token não fornecido"
}
Error - Server Error (500)
{
"error": "Erro ao deletar projeto"
}
Implementation Reference
All project endpoints are implemented in backend/src/server.js:
- GET /api/projects - Line 287
- POST /api/projects - Line 299 (requires auth)
- PUT /api/projects/:id - Line 311 (requires auth)
- DELETE /api/projects/:id - Line 324 (requires auth)
The API uses Prisma ORM to interact with the database, ensuring type-safe database operations.