Skip to main content

Endpoint

POST /api/teams/delete
Despite being a POST request, this endpoint performs a delete operation. It’s configured this way in the Nitro.js handler.
Deletes a Formula 1 team from the database. This endpoint requires admin authentication via JWT token.

Authentication

This endpoint requires an admin JWT token. The token must:
  • Be valid and not expired
  • Contain a userType field with value "admin"
  • Be signed with the application’s secret key

Request

teamId
string
required
The unique identifier of the team to delete
token
string
required
JWT authentication token with admin privileges

Response

Success (200)

Returns an object containing the status and the deleted team data.
status
number
HTTP status code (200 for success)
body
string
JSON stringified deleted team object containing:

Error responses

400 - Bad Request
Returned when no token is provided in the request body
{
  "status": 400,
  "body": "{\"error\":\"Bad Request\"}"
}
401 - Unauthorized
Returned when:
  • JWT verification fails
  • Token has expired
{
  "status": 401,
  "body": "{\"error\":\"Unauthorized\"}"
}
or
{
  "status": 401,
  "body": "{\"error\":\"Token has expired\"}"
}
403 - Forbidden
Returned when the authenticated user does not have admin privileges
{
  "status": 403,
  "body": "{\"error\":\"Forbidden\"}"
}

Example

curl -X POST https://your-domain.com/api/teams/delete \
  -H "Content-Type: application/json" \
  -d '{
    "teamId": "haas",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
  }'

Response

{
  "status": 200,
  "body": "{\"teamId\":\"haas\",\"name\":\"Haas F1 Team\",\"nationality\":\"American\",\"url\":\"https://www.haasf1team.com\",\"teamLogo\":\"https://example.com/logos/haas.png\"}"
}

Implementation notes

The deletion is performed using Prisma’s delete method as shown in /home/daytona/workspace/source/server/api/teams/delete.ts:42-46:
const deletedTeam = await db.teams.delete({
    where: {
        teamId: teamId,
    },
});
The response includes the deleted team object, allowing you to confirm which team was removed from the database.

Important considerations

  • Deleting a team may affect related drivers if there are foreign key constraints in the database
  • The endpoint returns the deleted team object for confirmation purposes
  • This operation is irreversible and should be used with caution

Build docs developers (and LLMs) love