An open API service indexing awesome lists of open source software.

https://github.com/arjun-g/stepzen-tmdb


https://github.com/arjun-g/stepzen-tmdb

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

# stepzen-tmdb

Demo - https://stepzen-tmdb.pages.dev/
## Requirements

- StepZen Account (https://stepzen.com/) - for GraphQL
- TMDB Developer API Key (http://developers.themoviedb.org/) - for Movie/TV data
- MongoDB Data API Key (https://www.mongodb.com/atlas/database) - To store data
- Cloudflare Page (https://pages.cloudflare.com/) - To host the static files and proxy the StepZen api

## Get Started

### Starting StepZen

The StepZen schema and config are present in `stepzen` folder. You can use `stepzen start` to deploy and watch the graphql apis. Before that create a `config.yaml` file in the `stepzen` folder with the below content.

```
configurationset:
- configuration:
name: curl_import_config
authorization: Bearer
- configuration:
name: mongo_data_config
apiKey:
```

### Starting Web App

The Web App react code if present in `app` folder. You can use `npm start` to run it locally. Before running create a `.env.development` file in `app` folder with the below content.

```
REACT_APP_API_URL=
REACT_APP_STEPZEN_KEY=
```

## Additional Details

### Cloudflare Proxying

To hide the StepZen Api Key Cloudflare Page is used to proxy the endpoint so that the api key can be added in backend.

```
export async function onRequestPost({ request, env }) {
const url = new URL(request.url);
const newRequest = new Request(
"https://lakebluff.stepzen.net/api/tmdb/__graphql",
request
);
newRequest.headers.set("Authorization", `Apikey ${env.STEPZEN_API_KEY}`);
let response = await fetch(newRequest);
response = new Response(response.body, response);
response.headers.set("Access-Control-Allow-Origin", "*");
response.headers.set("Access-Control-Allow-Methods", "GET,HEAD,POST,OPTIONS");
response.headers.set("Access-Control-Max-Age", "86400");
response.headers.set("Access-Control-Allow-Headers", request.headers.get(
"Access-Control-Request-Headers"
));
return response;
}
```

## TODO
Complete the GraphQL implementation for TMDB with StepZen

## Known Issues
Due to some issues with TMDB api the GraphQL endpoint fails at random with "Bad Request". Need to figure out hte cause for this.