Backend for FreeLearn website.
$ git clone https://github.com/phcarneirobc/free-learn-backend
$ cd free-learn-backend
$ go run .
$ docker compose up -d
| Method | Endpoint | Description | Request Body |
|---|---|---|---|
| POST | /register | Register a new user | {"name": "User", "email": "user@example.com", "password": "password123"} |
| POST | /login | Authenticate a user | {"email": "user@example.com", "password": "password123"} |
| Method | Endpoint | Description | Authentication |
|---|---|---|---|
| POST | /product | Create a new product | Required |
| GET | /product/:id | Get product by ID | Not Required |
| GET | /product/images | Get product images by ID (query) | Not Required |
| PUT | /product/:id | Update product details | Required |
| DELETE | /product/:id | Delete a product | Required |
| GET | /search | Search products (query param: q) | Not Required |
| Method | Endpoint | Description | Authentication |
|---|---|---|---|
| POST | /collection | Create a new collection | Required |
| GET | /collection/:id | Get collection by ID | Not Required |
| GET | /collections | Get all collections | Not Required |
| PUT | /collection/:id/product | Add product to collection | Required |
| DELETE | /collection/:id/product/:productId | Remove product from collection | Required |
Products can be created by sending a multipart/form-data request with the following fields:
name: Product Name
description: Product Description
codeName: Internal Code Name
team: true/false
coverImage: [file upload]
heroImage: [file upload]
frontImage: [file upload]
backImage: [file upload]
leftImage: [file upload]
rightImage: [file upload]
Collections can be created in two ways:
Content-Type: application/json
{
"name": "Collection Name",
"description": "Collection Description",
"products": ["productId1", "productId2"]
}Content-Type: multipart/form-data
name: Collection Name
description: Collection Description
products: productId1
products: productId2
imageUrl: [file upload]