Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/falcucci/f1-world-championship-api
A comprehensive API for Formula 1 World Championship data. It allows developers to quickly access data from the world's premier motor racing competition.
https://github.com/falcucci/f1-world-championship-api
Last synced: about 2 months ago
JSON representation
A comprehensive API for Formula 1 World Championship data. It allows developers to quickly access data from the world's premier motor racing competition.
- Host: GitHub
- URL: https://github.com/falcucci/f1-world-championship-api
- Owner: falcucci
- Created: 2022-11-01T20:49:45.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-08T08:48:50.000Z (over 1 year ago)
- Last Synced: 2024-07-03T12:11:05.881Z (3 months ago)
- Language: JavaScript
- Homepage: https://f1-world-championship-api.vercel.app
- Size: 784 KB
- Stars: 10
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
F1 World Championship Service
A project to analyze drivers winners.
___
[![Run in Postman](https://run.pstmn.io/button.svg)](https://www.getpostman.com/collections/5ae5b5688e9cbee57e46)## Application Architectural Overview
____Running the service requires some dependencies.
1. Docker and Docker Compose installed. [Install instructions.](https://docs.docker.com/get-docker/)
3. Hasura CLI installed. [Instructions here.](https://hasura.io/docs/latest/graphql/core/hasura-cli/install-hasura-cli.html)## Running the service
- Run `docker-compose up -d --build`
- Make sure all migrations are applied by running `npm run migrate`
- Make sure to fulfill the database using the seeds by running `npm run seeds`
- To start exploring, start hasura console with `hasura console`if you wanna make sure the migrations has been applied to the correct schema, run:
```sh
docker exec f1-world-championship-api_app_1 sh -c npm run migrate"
```and also the seeds to make sure
```sh
docker exec f1-world-championship-api_app_1 sh -c npm run seeds"
```dont forget to track the schemas and create the actions
```sh
hasura metadata apply
```In case you need to load env vars use the `.env` file as the sample
| name | description |
| ---- | ----------- |
| `HASURA_PROJECT_ENDPOINT` | GraphQL engine endpoint |
| `NEXTJS_SERVER_URL` | Next server |
| `ACTIONS_BASE_URL` | Actions endpoint |Or, run the development server by yourself to check better logs:
```bash
npm run dev
# or
yarn dev
```Go to http://localhost:3000 to access the serveless functions
Go to http://localhost:8080 for Hasura console (admin secret = "")
Serveless functions are running at https://f1-world-championship-api.vercel.app/api/health
check it out the functions.
```bash
curl --location --request POST 'https://f1-world-championship-api.vercel.app/api/actions/drivers' \
--header 'x-hasura-admin-secret: X6M0Xj35Y1QqL6M66CBOj852xwEaUYqE6i2R246WQdZVQxptuO3sf7f6tv4ZObjb' \
--header 'Content-Type: application/json' \
--data-raw '{
"input": {
"from": "2021-12-16",
"to": "2023-12-16",
"limit": 10
}
}'
```Graphql engine is running at https://quiet-buzzard-46.hasura.app
try it out the actions:
```graphql
query {
getDrivers(
from: "2021-12-16",
to: "2023-12-16",
limit: 10
) {
id
forename
surname
standings_aggregate {
aggregate {
sum {
wins
}
}
}
result {
milliseconds
fastest_lap_speed
race {
year
name
datetime
}
}
}
}
```
# Test Coverageyou can check if everything is fine running the assertions
```bash
npm run test
```
generate coverage
```bash
npm run coverage
```here you have a simple test coverage report.
### The visual sample
As an example, the [bar chart below](https://falcucci.grafana.net/goto/VOqcJsDVz?orgId=1) shows 10 racers who have the most wins by time already consumed by our `GetDrivers` Hasura action.
## DISCLAIMER
The high latency of the servers of the GraphQL engine and the vercel serveless functions is due the zone and cold start reasons. It should runs faster if we boost the server and change the regions. Also I made a tiny performance improvement to make sure it was the server latency instead of a low query issue at our engine. Try it out locally to see the difference.
## Deploy It Yourself 🎉
[![Deploy to Vercel](https://vercel.com/button)](https://vercel.com/import/project?template=https://github.com/falcucci/f1-world-championship-api)
#### The Node Wayâ„¢
> "When applications are done well, they are just the really application-specific, brackish residue that can't be so easily abstracted away. All the nice, reusable components sublimate away onto github and npm where everybody can collaborate to advance the commons."
![node.js is shiny](https://feross.net/x/node2.gif)