Movie and Series API Project With Golang
Table of Contents
- Golang
- Docker
- Clone the repo
git clone https://github.com/muhammedikinci/scaleapi cd ./scaleapi
- Run docker compose file (with data)
docker compose -p "scaleflix_with_data" -f .\docker-compose.crawler.yml up
-
API and Crawler can be restarted many times until database is ready to accept the connection
restart: on-failure
-
Crawler project will terminate automatically after writing all movies and series that get from other APIs to the database
-
Crawler will add admin user to database, credentials: muhammed:1234
-
If you want to start the project without Crawler, you can use the base docker-compose file in the project
docker compose -p "scaleflix_without_data" -f .\docker-compose.yml up
This action needs the installation of PostgreSQL manually.
-
Clone the repo
git clone https://github.com/muhammedikinci/scaleapi cd ./scaleapi
-
Install Go dependencies
go mod download
-
Start PostgreSQL Service and Create
scaleflix
database -
Start API without build
go run ./cmd/server/.
-
Start crawler without build
go run ./cmd/crawler/.
curl --request POST \
--url http://localhost:8080/register \
--header 'Content-Type: application/json' \
--data '{
"username":"muhammed",
"password":"1234"
}'
curl --request POST \
--url http://localhost:8080/# \
--header 'Content-Type: application/json' \
--data '{
"username":"muhammed",
"password":"1234"
}'
curl --request GET \
--url http://localhost:8080/movies \
--header 'Authorization: Bearer {{TOKEN}}' \
--header 'Content-Type: application/json'
- GET /movies/:id
- GET /movies/filter?title={{title}}&genre={{genre}}
curl --request POST \
--url http://localhost:8080/movies \
--header 'Authorization: Bearer {{TOKEN}}' \
--header 'Content-Type: application/json' \
--data '{
"title": "Edge of Tomorrow",
"image": "https://m.media-amazon.com/images/M/MV5BMTc5OTk4MTM3M15BMl5BanBnXkFtZTgwODcxNjg3MDE@._V1_SX300.jpg",
"description": "A soldier fighting aliens gets to relive the same day over and over again, the day restarting every time he dies.",
"rating": 7.9,
"release_date": "06 Jun 2014",
"director": "Doug Liman",
"writer": "Christopher McQuarrie, Jez Butterworth, John-Henry Butterworth",
"stars": "Tom Cruise, Emily Blunt, Bill Paxton",
"duration": "113 min",
"imdb_id": "tt1631867",
"year": 2014,
"genre": "Action, Adventure, Sci-Fi"
}'
curl --request GET \
--url http://localhost:8080/series \
--header 'Authorization: Bearer {{TOKEN}}' \
--header 'Content-Type: application/json'
- GET /series/:id
- GET /series/:id/seasons
- GET /series/:id/seasons/:season_id
- GET /series/filter?title={{title}}&genre={{genre}}
curl --request POST \
--url http://localhost:8080/series \
--header 'Authorization: Bearer {{TOKEN}}' \
--header 'Content-Type: application/json' \
--data '{
"title": "Under the Dome",
"image": "https://static.tvmaze.com/uploads/images/original_untouched/81/202627.jpg",
"description": "<p><b>Under the Dome</b> is the story of a small town that is suddenly and inexplicably sealed off from the rest of the world by an enormous transparent dome. The town'\''s inhabitants must deal with surviving the post-apocalyptic conditions while searching for answers about the dome, where it came from and if and when it will go away.</p>",
"rating": 6.5,
"release_date": "2013-06-24",
"director": "",
"writer": "",
"stars": "",
"imdb_id": "tt1553656",
"year": 0,
"genre": "Drama,Science-Fiction,Thriller"
}'
curl --request POST \
--url http://localhost:8080/favorite_movie/{{movie_id}} \
--header 'Authorization: Bearer {{TOKEN}}'
curl --request POST \
--url http://localhost:8080/favorite_serie/{{serie_id}} \
--header 'Authorization: Bearer {{TOKEN}}'
curl --request GET \
--url http://localhost:8080/favorites \
--header 'Authorization: Bearer {{TOKEN}}'
curl --request GET \
--url http://localhost:8080/favorite/filter?title={{}}&genre={{}} \
--header 'Authorization: Bearer {{TOKEN}}'
go test ./...
Muhammed İKİNCİ - muhammedikinci@outlook.com