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

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: 4 months 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

### Summary

1. [Description](#description-)
2. [Prerequisites](#prerequisites-)
3. [Makefile](#makefile-)
4. [Starting the Project](#starting-the-project-)
5. [Stopping the Project](#stopping-the-project-)
6. [Features](#features-)
1. [Profile Module](#profile-module-http)
2. [User Module](#user-module-http)
3. [Authentication Module](#authentication-module-http)
4. [Product Module](#product-module-http)
7. [Code Status](#code-status-)
8. [Contributors](#contributors-)
9. [License](#license-)

1. #### Description [↑](#summary)

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

2. #### Prerequisites [↑](#summary)
* Docker
* Docker Compose
* Golang 1.23+ (Optional)

3. #### Makefile [↑](#summary)

Makefile commands:

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

Commands:

init Create environment file
build Build the application from source code
run Run application from source code
compose-build-services Create and start services containers
compose-build-built Create and start containers from built
compose-build-source Create and start containers from source code
compose-down Stop and remove containers and networks
compose-remove Stop and remove containers, networks and volumes
compose-exec Access container bash
compose-log Show container logger
compose-top Display containers processes
compose-stats Display containers stats
go-test Run test and generate coverage report
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
```

4. #### Starting the Project [↑](#summary)
* Download and extract the latest build [release](https://github.com/raulaguila/go-api/releases)
* Open the terminal in the release folder
* Run `make compose-build-built`

5. #### Stopping the Project [↑](#summary)
* Open the terminal in the release folder
* Run `make compose-remove`

6. #### Features [↑](#summary)

* Get default user email and password on environment file `configs/.env`
* Test API endpoints using [http files](../api) or accessing [swagger page](http://127.0.0.1:9000/swagger)

1. ###### Profile Module ([HTTP](../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` |

2. ###### User Module ([HTTP](../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/pass` | `PUT` | `Set user's password` |
| `/user/pass` | `DELETE` | `Reset user's password` |

3. ###### Authentication Module ([HTTP](../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
```

4. ###### Product Module ([HTTP](../api/product.http))

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

7. #### Code Status [↑](#summary)
* Development

8. #### Contributors [↑](#summary)


raulaguila

9. #### License [↑](#summary)

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