POST /signup
: Register a new user.POST /signin
: Login with existing credentials.POST /refresh-token
: Refresh JWT token.
POST /create-ad
: Create a new ad.GET /all-ads
: Get all adsGET /ads-by-page
: Get ads on the page (written param in the query)
- localhost:8080/all-ads?date_order=desc
- localhost:8080/all-ads?max_price=1000&price_order=asc
- localhost:8080/all-ads?max_price=1000&price_order=asc&min_price=300
- localhost:8080/ads-by-page?price_order=desc&page=2
- localhost:8080/ads-by-page?date_order=asc&page=2
To run the application, execute the following command in your terminal:
go run ./cmd
To register use the following json pattern
{
"email": "[email protected]",
"password": "useMeForLoginAlso!"
}
In order to add an ad you should be authorized, and if so, use the following json pattern Max image size 1MB
{
"title": "Продается дача",
"text": "Дача в 100 км от города. 6 соток, дом 80 м2.",
"image_url": "https://www.example.com/dacha.jpg",
"price": 1500000.0
}
Make sure to set the necessary environment variables in a .env
file before running the application.
- Gin: HTTP web framework.
- MongoDB Go Driver: Official MongoDB driver for Go.
- JWT Go: Library for JSON Web Tokens.
The application requires the following environment variables to be set:
MONGO_URI
: MongoDB connection URI.PORT
: Port number for the server.JWT_SECRET
: Secret key for JWT token generation.GIN_MODE
: Gin mode (debug
orrelease
).
Ensure these environment variables are correctly set in a .env
file before running the application.