The Foccacia REST API provides endpoints to manage teams, leagues, users, and groups. It is built using Node.js and Express, and it includes middleware for request counting and logging request data.
- Node.js
- Express
- JSON
- countReq: Logs the request count.
- showRequestData: Logs the request data.
- extractToken: Extracts the token from the request for group-related endpoints.
- GET /api/teams: Retrieve teams by name.
- Query Parameters:
name: The name of the team to search for.
- Query Parameters:
- GET /api/leagues: Retrieve leagues by team.
- Query Parameters:
team: The name of the team to search for leagues.
- Query Parameters:
- POST /api/users: Create a user
For all the following requests it is required to provide a Bearer authentication token. In order to get one you must first create a user with the POST /api/users/ endpoint.
- GET /api/groups: Retrieve all groups.
- POST /api/groups: Create a new group.
- Request Body:
name: The name of the group.description: The description of the group.
- Request Body:
- PUT /api/groups: Update an existing group.
- Request Queries:
groupId: The ID of the group to update.
- Request Body:
name: The new name of the group.description: The new description of the group.
- Request Queries:
- DELETE /api/groups: Delete a group.
- Request Queries:
groupId: The ID of the group to delete.
- Request Queries:
- GET /api/groups:groupId: Get the details and items of a group
- POST /api/groups:groupId: Add a team to a group
- Request Body:
teamId: The id of the teamleagueId: Id of the league for the teamseason: Year of the season of the league for the team
- Request Body:
- DELETE /api/groups:groupId: Delete a team from a group
- Request Queries:
teamId: The id of the teamleagueId: Id of the league for the teamseason: Year of the season of the league for the team
- Request Queries:
- Ensure you have Node.js installed.
- Clone the repository.
- Create a configuration file (e.g.,
config.json) with the following content:{ "apiKey": "your-api-key" } - Run the server using the following command:
Replace
node src/foccacia-server.mjs <config-file>
<config-file>with the path to your configuration file.