Hasura graphql engine for whatsinthebox.tv
The front-end project contains a few routes that are specially built to be used with this hasura.
/api/admin/channels/update
- create / update in the DB the list of available channels/api/admin/queue/create
- for each channel, create an entry in the queue to process a given day. It accepts anoffset
payload to specify the day we want to schedule (e.g.:{ payload: { offset: 1 } }
fetches the programming for following day)/api/admin/queue/next
- find the next incomplete channel in the queue and processes it (find the IMDB id for each movie and fetches movie details from OMDB)/api/admin/schedule/<schedule_id>
- processes again a given schedule. Helpful when we make changes and need to update an old entry.
This project has two cron jobs:
- Every midnight, each channel gets queued to get the day's programming. (api/admin/queue/create)
- Every 2 minutes, we check for incomplete items in queue and process them. (api/admin/queue/next)
You can also trigger manually these endpoints using Postman (or any other similar tool) and sending an authorization
header with the code defined in the .env
files of both projects (API_CODE
and API_ADMIN_CODE
). All admin endpoints are POST
and, if a payload is required, use the following format:
{
"payload": {
YOUR_PAYLOAD
}
}
- Make sure you have docker and docker-compose.
- Clone the front-end project, fill its environment variables, install dependencies (
npm i
) and run the project (npm run dev
)
Copy the example .env file and fill with whatever necessary: cp .env.example .env
.
Make sure your APP_ADMIN_CODE
matches API_CODE
in the front-end repo
docker-compose up
Hasura is now running at http://localhost:8080/
Refer to Docker's documentation for more.
To start fetching some movies you need to trigger /api/admin/channels/update
. Refer to the API routes above.
Refer to hasura's CLI docs for detailed instructions.
Update the .env
file to point to whichever instance you want to update.
Run hasura metadata apply
to apply local metadata changes to the deployed instance.
hasura migrate squash --name "<feature-name>" --from <start-migration-version> --database-name <database-name>
# note down the version
# mark the squashed migration as applied on this server
hasura migrate apply --version "<squash-migration-version>" --skip-execution --database-name <database-name>
from this guide