- This app uses SQLite3. You don't need to start it.
- Run
make build
to compile the project directly on your OS (tested on MAC M1), binary will be added to build directory, it was tested with go 1.19+.
- Run
make run
it was tested with go 1.19+.
- Run
make lint
to run linter. - Run
make test
to execute unit tests. - Run
make integration-test
to execute integration tests, you need Venom installed.
- This app uses:
- Go 1.19
- [Gin] to handle requests, responses, validations (validator V10).
- [SQLite3] to store data.
- [Migrate] to manage database migrations.
- [sqlMock & Moq] to mock dependencies in unit-tests.
- golangci-lint to lint code.
- Venom to run integration tests (You have to install it, script will download it only for Mac M1/M2).
- Valid SubReddits are stored in a txt file that is loaded at startup.
Method: POST
http://localhost:8082/v1/post
{
"title": "titulo",
"subreddit": "/r/nvidia",
"link": "https://www.twi2tch.tv/elmariana",
"content": "content is mututally exclusive with link, choose wisely",
"score": 1232132,
"nsfw": true,
"promoted": false
}
{
"id": "35ce6d85-2260-484d-b656-24f90408efe9"
}
Method: POST
http://localhost:8082/v1/post/score
{
"id":"2bf5b210-b4f4-47b3-bc7e-bd5034bf129d",
"score":45
}
{
"error": null
}
Method: GET
http://localhost:8082/v1/feed?page=1&limit=10
{
"data": [
{
"id": "88539220-1d68-42de-aa5c-150115ddcecd",
"title": "titulo",
"author": "t2_Ej6sNFr4",
"subreddit": "/r/nvidia",
"link": "https://www.twi2tch.tv/elmariana",
"score": 1232132,
"promoted": false,
"nsfw": true
},
{
"id": "35ce6d85-2260-484d-b656-24f90408efe9",
"title": "titulo",
"author": "t2_rcXbzrcA",
"subreddit": "/r/nvidia",
"link": "https://www.twi2tch.tv/elmariana",
"score": 1232132,
"promoted": false,
"nsfw": true
}
],
"pagination": {
"pageCount": 2,
"next": "/v1/feed?page=2",
"page": 1,
"limit": 2,
"total": 62
}
}
Author: Carlos Flores