Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Danielsl4/TFG_DAM_2526_Consulta2/llms.txt

Use this file to discover all available pages before exploring further.

Fields represent the physical venues where matches are played. Each match can be assigned a field. Write operations require a valid JWT with the admin role; the listing endpoint is public.

Field object

id
number
required
Unique identifier for the field.
name
string
required
Display name of the field (e.g. "Pabellón Municipal Norte").
location
string
Address or description of the venue’s location.
is_active
boolean
required
Whether the field is currently active. Inactive fields have been soft-deleted and do not appear in the public listing.

GET /fields

Returns all active fields (is_active = true) ordered alphabetically by name. No authentication required.
cURL
curl --request GET \
  --url 'http://localhost:3000/fields'
Response
[
  {
    "id": 1,
    "name": "Pabellón Municipal Norte",
    "location": "Calle Mayor 12, Valencia",
    "is_active": true
  }
]

POST /fields

Creates a new field. Requires admin role.
name
string
required
Name of the field.
location
string
Address or description of the venue’s location.
cURL
curl --request POST \
  --url 'http://localhost:3000/fields' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{"name": "Pabellón Municipal Norte", "location": "Calle Mayor 12, Valencia"}'
Response — 201 Created
{
  "id": 5,
  "name": "Pabellón Municipal Norte",
  "location": "Calle Mayor 12, Valencia",
  "is_active": true
}

PUT /fields/:id

Updates the name and/or location of a field. Requires admin role.
id
number
required
ID of the field to update.
name
string
required
Updated name for the field.
location
string
Updated location description.
cURL
curl --request PUT \
  --url 'http://localhost:3000/fields/5' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{"name": "Pabellón Sur", "location": "Avenida del Deporte 8, Valencia"}'

DELETE /fields/:id

Soft-deletes a field by setting is_active = false. The record is retained in the database and can be restored. Requires admin role.
id
number
required
ID of the field to deactivate.
cURL
curl --request DELETE \
  --url 'http://localhost:3000/fields/5' \
  --header 'Authorization: Bearer <token>'

GET /fields/admin/trash

Returns all inactive fields (is_active = false). Requires admin role.

POST /fields/:id/restore

Restores a soft-deleted field by setting is_active = true. Requires admin role.
id
number
required
ID of the field to restore.

DELETE /fields/:id/permanent

Permanently removes a field record from the database. The field must already be inactive (soft-deleted) before it can be permanently deleted. Returns 400 if the field is still active or has matches associated with it. Requires admin role.
id
number
required
ID of the field to permanently delete.

Fields are referenced by matches via field_id. Calling DELETE /fields/:id performs a soft delete (is_active = false) to preserve match history. Use DELETE /fields/:id/permanent only after the field has been moved to the trash and confirmed to have no associated matches.

Build docs developers (and LLMs) love