Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vicradon/product-api-go
A products API written in Go with no frameworks for performing CRUD on products
https://github.com/vicradon/product-api-go
Last synced: 29 days ago
JSON representation
A products API written in Go with no frameworks for performing CRUD on products
- Host: GitHub
- URL: https://github.com/vicradon/product-api-go
- Owner: vicradon
- Created: 2024-10-21T08:16:19.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-10-23T03:56:46.000Z (3 months ago)
- Last Synced: 2024-10-23T11:11:37.413Z (3 months ago)
- Language: Go
- Size: 213 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Product Management System APIs
This is a simple CRUD Go API that allows users to manage products in a store. It is powered by an SQLite database and Go Gin framework.
## Prerequisites
You need Go 1.17 or higher to run this app
## Set up
Set this up by cloning this repo and creating an .env file. Do so with this command
```
cp .env.example .env
```### Running the app
You can run the app by either building first and running as an executable or running directly. Here are both cases:
1. Build and run
```sh
go build -o productapi
./productapi
```2. Run directly
```sh
go run main.go
```If you start the app with the defaults, it will run on port 2400 and set up a database in the root directory called `database.db`
## Running unit tests
You can run the included unit tests for the APIs using the command below:
```
go test -v ./...
```Example test output
```
=== RUN TestCreateProduct
[GIN] 2024/10/22 - 22:27:19 | 201 | 310.25µs | | POST "/products"
--- PASS: TestCreateProduct (0.00s)
```## API docs
The API is documented with swagger. You can test it out on the swagger browser interface: https://productapi.osinachi.me/swagger/index.html
![Swagger Screenshot](./docs/swagger-screenshot.png)