Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scblur869/pg-widget-api
api written for postgres PQX library
https://github.com/scblur869/pg-widget-api
api-rest gin-gonic golang microservces postgresql pqx
Last synced: 19 days ago
JSON representation
api written for postgres PQX library
- Host: GitHub
- URL: https://github.com/scblur869/pg-widget-api
- Owner: scblur869
- License: mit
- Created: 2024-07-15T21:20:08.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-07-18T01:12:12.000Z (5 months ago)
- Last Synced: 2024-11-16T15:38:30.070Z (about 1 month ago)
- Topics: api-rest, gin-gonic, golang, microservces, postgresql, pqx
- Language: Go
- Homepage:
- Size: 180 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PG-Widget-API
## Purpose
To provide a simple api / http microservice that supports a few common postgres data handling functions.
This api is written in GO for its simplicity and speed of use. It leverages a single database handler to support reciever functions.### Files & Libs
#### libs
- -- http api framework for GO
- -- postgres library written in GO#### files
- **services** folder contains receiver and utility functions to support endpoint functions
- **structs** contains structs for the widget model
- **images** supports this README
- *.env* - local environment file for testing
- *compose.yml* - a simple docker-compose file to spin up postgres database container and creates the widgetDB and table
- *init.sql* - file that creates the widgetdb/widget table structure used by compose
- *Dockerfile* - docker file for building the pg-api container
- *key.txt* - key file created on every start up. this file is stored in the container should be used if you want to secure an endpoint accessabilty
- *sample-data.sh* - a set of curl statements to load up some sample data```bash
sh sample-data.sh
```### Building and Deploying
#### Api
![building the api](images/console.png)
#### Postgres
(old docker-compsoe v1)
```docker
docker-compose up -d
```(new docker compose v2)
![spinning up the postgres container](images/compose.png)
#### Testing the api
#### add new
```console
curl --location 'localhost:4000/api/v1/addNew' \
--header 'Content-Type: application/json' \
--data '{
"name": "wid005",
"category": "square",
"color" : "purple"
}'
```#### list widgets
```console
curl --location 'localhost:4000/api/v1/getAll'
```enjoy!