Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add coingecko api key #12

Merged
merged 4 commits into from
May 1, 2024

Conversation

alfetopito
Copy link
Contributor

Summary

Use Coingecko's api key in the proxy requests

@alfetopito alfetopito self-assigned this May 1, 2024
Copy link

vercel bot commented May 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
cow-web-services ✅ Ready (Inspect) Visit Preview May 1, 2024 0:43am

Comment on lines +13 to +15
upstream:
fastify.config.COINGECKO_PROXY_UPSTREAM ||
DEFAULT_COINGECKO_PROXY_UPSTREAM,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the env var COINGECKO_PROXY_UPSTREAM when set

replyOptions: {
rewriteRequestHeaders: (request, headers) => ({
...headers,
"x-cg-pro-api-key": fastify.config.COINGECKO_API_KEY,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add required env var COINGECKO_API_KEY to requests

@alfetopito
Copy link
Contributor Author

Merging to parent, post merge review please

@alfetopito alfetopito merged commit 6d1a163 into feat/no-server-side-cache May 1, 2024
3 checks passed
@alfetopito alfetopito deleted the feat/coingecko-api-key branch May 1, 2024 12:50
alfetopito added a commit that referenced this pull request May 1, 2024
* feat: remove server side caching

* chore: remove fastify-caching

* chore: undici config still required

* fix: type on cdn-cache-control value

* feat: add coingecko api key (#12)

* feat: add coingecko api key to proxy requests

* fix: remove `simple` prefix as it's part of coingecko's path

* chore: temporarily change to pro-api since the key is set to "pro"

* chore: add COINGECKO_PROXY_UPSTREAM as optional env var
alfetopito added a commit that referenced this pull request May 1, 2024
* feat: add coingeckoProxy

* chore: add fastify/caching dependency

* feat: add request caching

* fix: only cache successfull responses from proxy origin

* chore: improve logging

* feat: set our own cache-control header

* chore: delete set-cookie header

* chore: rename local header from cache-hit to x-proxy-cache and leave it in the reply

* Revert "chore: rename local header from cache-hit to x-proxy-cache and leave it in the reply"

This reverts commit 71ecd72.

* fix: prevent content-length header mismatch errors

* fix: do not fwd accept-encoding header, as I'm not able to deal with encoded response

* chore: attempt at caching only after response is sent

* chore: try a different way to decorate

* Revert "chore: try a different way to decorate"

This reverts commit 31672a6.

* Revert "chore: attempt at caching only after response is sent"

This reverts commit b2dd0eb.

* feat: coingecko proxy without server side caching (#11)

* feat: remove server side caching

* chore: remove fastify-caching

* chore: undici config still required

* fix: type on cdn-cache-control value

* feat: add coingecko api key (#12)

* feat: add coingecko api key to proxy requests

* fix: remove `simple` prefix as it's part of coingecko's path

* chore: temporarily change to pro-api since the key is set to "pro"

* chore: add COINGECKO_PROXY_UPSTREAM as optional env var
Copy link
Contributor

@anxolin anxolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve! thanks

anxolin added a commit that referenced this pull request May 7, 2024
* feat: coingecko proxy (#10)

* feat: add coingeckoProxy

* chore: add fastify/caching dependency

* feat: add request caching

* fix: only cache successfull responses from proxy origin

* chore: improve logging

* feat: set our own cache-control header

* chore: delete set-cookie header

* chore: rename local header from cache-hit to x-proxy-cache and leave it in the reply

* Revert "chore: rename local header from cache-hit to x-proxy-cache and leave it in the reply"

This reverts commit 71ecd72.

* fix: prevent content-length header mismatch errors

* fix: do not fwd accept-encoding header, as I'm not able to deal with encoded response

* chore: attempt at caching only after response is sent

* chore: try a different way to decorate

* Revert "chore: try a different way to decorate"

This reverts commit 31672a6.

* Revert "chore: attempt at caching only after response is sent"

This reverts commit b2dd0eb.

* feat: coingecko proxy without server side caching (#11)

* feat: remove server side caching

* chore: remove fastify-caching

* chore: undici config still required

* fix: type on cdn-cache-control value

* feat: add coingecko api key (#12)

* feat: add coingecko api key to proxy requests

* fix: remove `simple` prefix as it's part of coingecko's path

* chore: temporarily change to pro-api since the key is set to "pro"

* chore: add COINGECKO_PROXY_UPSTREAM as optional env var

* feat: organize proxy routes (#13)

* refactor: move coingeckoProxy to proxies/coingecko

* refactor: move proxy to proxies/tokens and keep proxy for awhile

* chore: add permanent redirect rather than re-exporting same path

* Revert "chore: add permanent redirect rather than re-exporting same path"

This reverts commit 246c27a.

graphql-request doesn't seem able to handle redirects natively:
https://stackoverflow.com/questions/78015439/follow-redirects-setting-for-aws-appsync#comment137542218_78015439

Thus, reverting the redirect change

* fix: build and run

---------

Co-authored-by: Anxo Rodriguez <anxolin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants