This is a simple RESTful API built with Golang, Echo framework, and CouchDB for managing holidays. It allows you to add, retrieve, update, and delete holiday records.
- Add a new holiday
- Get all holidays
- Get a specific holiday by ISO date
- Update an existing holiday
- Delete a specific holiday
- Delete all holidays
Ensure you have the following installed:
- Go (1.18+ recommended)
- CouchDB (running locally or remotely)
- Postman or
cURLfor testing API
-
Clone the repository:
git clone https://github.com/N-Jangra/cc.git cd cc -
Configure the Database:
- Update
.envwith your CouchDB credentials:DB_HOST=localhost DB_PORT=5984 DB_USER=USERNAME DB_PASSWORD=PASSWORD DB_NAME=DATABASE_NAME apikey=<your-apikey>
- Update
-
Install dependencies:
go mod tidy
-
Run the API server:
go run main.go
The server should start at
http://localhost:8080
- Endpoint:
POST /n - Query Parameters:
Parameter Type Description Name string Holiday name iso_date string Holiday ISO date (YYYY-MM-DD) international bool Whether it's an international holiday - cURL Example:
curl -X POST "http://localhost:8080/n?Name=New%20Year&iso_date=2025-01-01&international=true"
- Endpoint:
GET /ga - cURL Example:
curl -X GET "http://localhost:8080/ga"
- Endpoint:
GET /g/:iso_date - Example:
GET /g/2025-01-01 - cURL Example:
curl -X GET "http://localhost:8080/g/2025-01-01"
- Endpoint:
PUT /u/:id - cURL Example:
curl -X PUT "http://localhost:8080/u/01" -H "Content-Type: application/json" -d '{ "name": "Updated Holiday", "iso_date": "2025-01-01", "international": false }'
- Endpoint:
DELETE /d/:iso_date - cURL Example:
curl -X DELETE "http://localhost:8080/d/2025-01-01"
- Endpoint:
DELETE /da - cURL Example:
curl -X DELETE "http://localhost:8080/da"
You can test the API using Postman or the provided cURL commands.
This project is open-source and free to use under the MIT License.
For any questions or suggestions, feel free to reach out:
Author: Nitin
Email: itznitinjangra@gmail.com
GitHub: N-Jangra