This API provides a RESTful interface for managing pomodoro sessions using Google Firestore
- Get all Pomodoros: Retrieve a list of all pomodoro sessions.
- Get a Pomodoro by ID: Fetch a specific pomodoro session by its unique identifier.
- Create a Pomodoro: Start a new pomodoro session.
- Update a Pomodoro: Modify an existing pomodoro session (currently only allows for generic updates to the entire Pomodoro object).
- Delete a Pomodoro: Remove a pomodoro session.
- Go 1.17 or later
- Google Cloud project with Firestore enabled
- Service account key with permissions to access Firestore
- Clone this repository.
- Set up your Google Cloud project and enable Firestore.
- Create a service account key and download the JSON file.
- Place the service account key JSON file in the project directory (adjust the path as needed).
- Configure the
FirestoreClient
in yourmain.go
file to connect to your Firestore instance.
- Open a terminal in the project directory.
- Run
go run main.go
.
Base URL: http://localhost:8080
(assuming the server runs on port 8080)
Get All Pomodoros:
-
Method: GET
-
Path:
/pomodoros
-
Response: JSON array of
Pomodoro
objects (see Models section) -
Status Code:
- 200: Success
- 500: Internal Server Error (database error)
Get Pomodoro by ID:
-
Method: GET
-
Path:
/pomodoros/:id
-
Parameter:
id
: Unique identifier of the pomodoro session (string)
-
Response: JSON object representing a single
Pomodoro
(see Models section) -
Status Code:
- 200: Success
- 404: Not Found (pomodoro with specified ID not found)
- 500: Internal Server Error (database error)
Create Pomodoro:
-
Method: POST
-
Path:
/pomodoros/create
-
Request Body: JSON object representing a new
Pomodoro
(see Models section) -
Response: JSON object representing the created
Pomodoro
-
Status Code:
- 201: Created
- 400: Bad Request (invalid request body)
- 500: Internal Server Error (database error)
Update Pomodoro:
-
Method: PUT
-
Path:
/pomodoros/:id
-
Parameter:
id
: Unique identifier of the pomodoro session (string)
-
Request Body: JSON object representing the updated
Pomodoro
(see Models section) -
Response: JSON object representing the updated
Pomodoro
-
Status Code:
- 200: OK (pomodoro updated successfully)
- 400: Bad Request (invalid request body)
- 404: Not Found (pomodoro with specified ID not found)
- 500: Internal Server Error (database error)
Delete Pomodoro:
-
Method: DELETE
-
Path:
/pomodoros/:id
-
Parameter:
id
: Unique identifier of the pomodoro session (string)
-
Response: No content
-
Status Code:
- 204: No Content (pomodoro deleted successfully)
- 404: Not Found (pomodoro with specified ID not found)
- 500: Internal Server Error (database error)
The API uses the following model for Pomodoro
objects:
type Pomodoro struct {
ID string `json:"id"`
StartTime time.Time `json:"startTime"`
Completed bool `json:"completed"`
}