https://github.com/subliker/user-bookings-service
Simple rest-api service to manage users and bookings
https://github.com/subliker/user-bookings-service
docker golang postgresql rest-api swagger
Last synced: 2 months ago
JSON representation
Simple rest-api service to manage users and bookings
- Host: GitHub
- URL: https://github.com/subliker/user-bookings-service
- Owner: subliker
- Created: 2023-09-24T21:22:33.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-25T16:10:57.000Z (over 1 year ago)
- Last Synced: 2025-03-25T17:25:05.539Z (over 1 year ago)
- Topics: docker, golang, postgresql, rest-api, swagger
- Language: Go
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# user-bookings-service
> RESTful API based on Go, PostgreSQL and Docker
### Docs (Sweagger):
```
https://localhost:8000/docs/index.html
```
### Requirements:
#### With Docker:

You can install Docker there
#### Without Docker:
 
You can install Golang there
You can install PostgreSQL there
### Installing:
1. Clone repository
2. In main directory:
With Docker:
for Windows users:
```bash
docker-compose build
docker-compose up -d postgresdb
docker-compose up -d app
```
for Linux users:
```bash
sudo docker compose build
sudo docker compose up -d postgresdb
sudo docker compose up -d app
```
Without Docker:
Set PostgreSQL in pgAdmin (see in env file (.env))
and
```
go build
//for windows
backendproj.exe
//for linux
./backendproj
```
### Entities:
- **User (example)**:
```
{
"id": 906,
"username": "Andrew",
"password": "$2a$14$kv/sGmTWIlNYocbZqd88GuRsrOtKrs9bBFMM7N7HRNZ.qPxF.b.GG", //bcrypt hash
"created_at": "2023-09-24T17:13:42Z",
"updated_at": "2023-09-27T11:10:23Z"
}
```
- **Booking (example)**:
```
{
"id": 1021,
"user_id": 906,
"end_time": "2023-10-01T14:30:00Z",
"start_time": "2023-10-01T12:00:00Z",
"comment": "I may be a little late"
}
```
### Requests
- /user/{id} [get]
Get User by id
- /user [post]
Create User from postForm: username, password
- /user/{user_id} [delete]
Delete User and its bookings by user_id
- /user/{id} [put]
Update User data (optional: username, password) by id (set new timestamp in update_at)
- /booking [get]
Get all bookings ordered by id
- /booking/{id} [get]
Get Booking by id (optional: set limit, page(required limit), offset(required limit) in params)
- /booking [post]
Create User from postForm: user_id, start_time, end_time, comment(optional)
- /booking/{id} [delete]
Delete Booking by id
- /booking/{id} [put]
Update Booking data (optional: start_time, end_time, comments) by id