This api is a security-focused system that combines role-based authentication, streamlined CRUD operations (Create, Read, Update, Delete), and efficient user management. It empowers administrators to control access based on user roles while providing a seamless experience for data manipulation and user interactions.
├───cmd
├───docker
└───pkg
├───auth
├───db
├───entities
├───errors
└───server
To run this project, you will need to add the following environment variables to your .env file
PORT
, DB_URI
, DB_NAME
, JWT_SECRET
Clone the project
git clone https://github.com/Merloss/go-api.git
Go to the project directory
cd go-api
Run services
docker-compose -f /docker/docker-compose.yml up -d
Install dependencies
go mod tidy
Start the server
go run .\cmd\main.go
POST /api/auth/register
Field name | Type | Description |
---|---|---|
username |
string |
Required. Your username |
password |
string |
Required. Your password |
POST /api/auth/login
Field name | Type | Description |
---|---|---|
username |
string |
Required. Your username |
password |
string |
Required. Your password |
GET /api/posts
POST /api/posts
Field name | Type | Description |
---|---|---|
title |
string |
Required. Post title |
description |
string |
Required. Post description |
POST /api/posts/:id
Field name | Type | Description |
---|---|---|
title |
string |
Required. Post title |
description |
string |
Required. Post description |
status |
string |
Admin only Post status |
DELETE /api/posts/:id
Parameter | Type | Description |
---|---|---|
id |
string |
Required. Post ID |
GET /api/posts/pending
POST /api/users/:id/edit
Field name | Type | Description |
---|---|---|
username |
string |
User username |
roles |
string[] |
User roles |
To run tests, run the following command
go test ./...