Skip to main content

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:
projects
array

Example Request

cURL
curl https://andreruperto.dev/api/projects
JavaScript
const response = await fetch('https://andreruperto.dev/api/projects');
const projects = await response.json();
console.log(projects);

Example Response

Success (200)
[
  {
    "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 (500)
{
  "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

title
string
required
Project title
description
string
required
Project description
image
string
URL or path to project image
technologies
array
Array of technology names
githubUrl
string
GitHub repository URL
liveUrl
string
Live demo URL
order
integer
Display order (default: 0)

Example Request

cURL
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
  }'
JavaScript
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

Success (200)
{
  "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

id
integer
required
Project ID to update

Request Body

Same as Create Project - all fields are optional, only provided fields will be updated.

Example Request

cURL
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"
  }'
JavaScript
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

Success (200)
{
  "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

id
integer
required
Project ID to delete

Example Request

cURL
curl -X DELETE https://andreruperto.dev/api/projects/3 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
JavaScript
const response = await fetch('https://andreruperto.dev/api/projects/3', {
  method: 'DELETE',
  headers: {
    'Authorization': `Bearer ${token}`
  }
});

const result = await response.json();

Example Response

Success (200)
{
  "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.

Build docs developers (and LLMs) love