Simple, lightweight authentication system built with Go and PostgreSQL.
- Go 1.19+
- Docker and Docker Compose
- Clone and setup
git clone https://github.com/PeterM45/go-postgres-api
cd go-postgres-api
- Create
.env
file
DB_USER=admin
DB_PASS=password
DB_NAME=myapp
DB_HOST=localhost
DB_PORT=5433
PORT=8080
JWT_SECRET=your-secret-key
- Run
# Start PostgreSQL
docker compose up -d
# Run API
go run cmd/main.go
POST /api/users
- Create userPOST /api/auth/login
- Login
GET /api/users
- List usersGET /api/users/{id}
- Get userPUT /api/users/{id}
- Update userDELETE /api/users/{id}
- Delete user
# Create user
curl -X POST http://localhost:8080/api/users \
-H "Content-Type: application/json" \
-d '{"username": "test", "email": "[email protected]", "password": "password123"}'
# Login
curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]", "password": "password123"}'