Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/raulaguila/go-api

User-friendly API template solution designed as a foundation for more complex APIs.
https://github.com/raulaguila/go-api

docker golang postgresql

Last synced: 28 days ago
JSON representation

User-friendly API template solution designed as a foundation for more complex APIs.

Awesome Lists containing this project

README

        

Go API Template



release

size
stars

license


report


test


build

## Prerequisites

- Docker

## Getting Started

- Help with make command

```sh
Usage:
make [COMMAND]
make help

Commands:

init Create environment file
compose-build-services Run 'docker compose --profile services up -d --build' to create and start containers
compose-build-source Run 'docker compose --profile services --profile source up -d --build' to create and start containers from source code
compose-build-binary Run 'docker compose --profile services --profile binary up -d --build' to create and start containers from binary
compose-down Run 'docker compose --profile all down' to stop and remove containers and networks
compose-remove Run 'docker compose --profile all down -v --remove-orphans' to stop and remove containers, networks and volumes
compose-exec Run 'docker compose exec -it backend_binary bash' to access container bash
compose-log Run 'docker compose logs -f backend_binary' to show container logger
compose-top Run 'docker compose top' to display containers processes
compose-stats Run 'docker compose stats' to display containers stats
go-run Run application from source code
go-test Run tests and generate coverage report
go-build Build the application from source code
go-benchmark Benchmark code performance
go-lint Run lint checks
go-audit Conduct quality checks
go-swag Update swagger files
go-format Fix code format issues
go-tidy Clean and tidy dependencies
```

- Run project

1. Download and extract the latest build [release](https://github.com/raulaguila/go-api/releases)
2. Open the terminal in the release folder
3. Run:

```sh
make compose-build-binary
```

- Remove project

```sh
make compose-remove
```

## Features

- Get default user email and password on environment file `configs/.env`
- Test API endpoints using http files or
accessing swagger page

[Profile module](../api/profile.http):

| Endpoint | HTTP Method | Description |
|:----------------|:-----------:|:------------------------:|
| `/profile` | `GET` | `Get all profiles` |
| `/profile` | `POST` | `Insert new profile` |
| `/profile` | `DELETE` | `Delete profiles by IDs` |
| `/profile/{id}` | `GET` | `Get profile by ID` |
| `/profile/{id}` | `PUT` | `Update profile by ID` |

[User module](../api/user.http):

| Endpoint | HTTP Method | Description |
|:-------------------|:-----------:|:-----------------------:|
| `/user` | `GET` | `Get all users` |
| `/user` | `POST` | `Insert user` |
| `/user` | `DELETE` | `Delete user` |
| `/user/{id}` | `GET` | `Get user by ID` |
| `/user/{id}` | `PUT` | `Update user by ID` |
| `/user/{id}/photo` | `GET` | `Get user's photo` |
| `/user/{id}/photo` | `PUT` | `Set user's photo` |
| `/user/pass` | `PUT` | `Set user's password` |
| `/user/pass` | `DELETE` | `Reset user's password` |

[Authentication module](../api/auth.http):

| Endpoint | HTTP Method | Description |
|:---------|:-----------:|:---------------------------------------:|
| `/auth` | `POST` | `User authentication` |
| `/auth` | `GET` | `User authenticated via access token` |
| `/auth` | `PUT` | `User refresh tokens via refresh token` |

- Pass token using prefix _**Bearer**_ in Authorization request header:

```bash
Authorization: Bearer
```

[Department module](../api/department.http):

| Endpoint | HTTP Method | Description |
|:-------------------|:-----------:|:-------------------------:|
| `/department` | `GET` | `Get all departments` |
| `/department` | `POST` | `Insert new department` |
| `/department` | `DELETE` | `Delete departments` |
| `/department/{id}` | `GET` | `Get department by ID` |
| `/department/{id}` | `PUT` | `Update department by ID` |

## Code status

- Development

## Contributors


raulaguila

## License

Copyright © 2023 [raulaguila](https://github.com/raulaguila).
This project is [MIT](../LICENSE) licensed.