Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/devenes/todos-api
This API is a simple todo list. It is a RESTful API that allows you to create, read, update and delete todos.
https://github.com/devenes/todos-api
api docker dockerfile go golang multi-stage restful-api
Last synced: about 1 month ago
JSON representation
This API is a simple todo list. It is a RESTful API that allows you to create, read, update and delete todos.
- Host: GitHub
- URL: https://github.com/devenes/todos-api
- Owner: devenes
- License: apache-2.0
- Created: 2022-06-07T15:54:42.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-09T14:01:06.000Z (about 2 years ago)
- Last Synced: 2024-05-02T02:31:53.777Z (8 months ago)
- Topics: api, docker, dockerfile, go, golang, multi-stage, restful-api
- Language: Go
- Homepage:
- Size: 229 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Todo List API
About |
Features |
Technologies |
Requirements |
Starting |
Containerization |
License |
Author## :dart: About
This API is a simple todo list. It is a RESTful API that allows you to create, read, update and delete todos.
## :sparkles: Features
| Parameter | Type | Description |
| :-------- | :------- | ---------------------------- |
| `id` | `string` | The id of the todo object |
| `title` | `string` | The title of the todo object |:heavy_check_mark: List todos\
:heavy_check_mark: Get todo status\
:heavy_check_mark: Create a new todo object\
:heavy_check_mark: Delete a todo object## :rocket: Technologies
The following tools were used in this project:
- [Go](https://golang.org/): The language used in this project
- [Docker](https://www.docker.com/): The containerization tool used in this project
- [GitHub](https://www.github.com/): The source control tool used in this project
- [GitHub Actions](https://github.com/actions/): The continuous integration tool used in this project## :white_check_mark: Requirements
Before starting :checkered_flag:, you need to have [Git](https://git-scm.com), [Docker](https://www.docker.com/), and [Go](https://golang.org) installed.
## :checkered_flag: Starting
- Clone the project
```bash
git clone https://github.com/devenes/todos-api
```- Go to the project directory:
```bash
cd todos-api
```- Run the following command to start the server:
```bash
go run main.go
```- You can also run the server in the background:
```bash
go run main.go &
```- Build the Docker image:
```bash
docker build -t devenes/todos-api:1 ./
```- You can also run the server in a Docker container:
```bash
docker run -p 8080:8080 -d devenes/todos-api:1
```- See the output:
```bash
docker build -t devenes/todos-api:1 ./ && docker run -p 8080:8080 -d devenes/todos-api:1 && explorer "http://localhost:8080/todos"
```- List todos with the following command:
```bash
curl http://localhost:8080/todos
```- Get the first todo with the following command:
```bash
curl http://localhost:8080/todos/1
```- Create a new todo with the following command:
```bash
curl -X POST -H 'content-type: application/json' --data '{"id": "4", "title": "Buy milk"}' http://localhost:8080/todos
```- Update the first todo with the following command:
```bash
curl -X POST -H 'content-type: application/json' --data '{"id": "1", "title": "Check the mailbox"}' http://localhost:8080/todos
```- Delete the first todo with the following command:
```bash
curl -X DELETE http://localhost:8080/todos/1
```- Get the second todo with the following command:
```bash
curl http://localhost:8080/todos/2
```- Stop and remove all Docker containers and images:
```bash
docker stop $(docker ps -aq) && docker rm $(docker ps -aq) && docker rmi $(docker images -q)
```## 🐳 Multi-Stage Containerization
You can reduce the size of the Docker image from 301MB to 12MB by using multi-stage containerization. Check the [Dockerfile](Dockerfile) to see how it works and look at the latest image created with alpine.
![Docker image](images.png)
## :memo: License
This project is under license from Apache 2.0. For more details, see the [LICENSE](LICENSE) file.
Made with :heart: by devenes