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

add geolocation weather example #15

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

michelleN
Copy link
Member

  • requires api token for weather site
  • can provide an ip addr to test with

SPIN_VARIABLE_TEST_IP_ADDR= SPIN_VARIABLE_WAQI_API_TOKEN= spin up

@michelleN michelleN force-pushed the weatherapp branch 2 times, most recently from 7d5a4c5 to a2a679b Compare February 20, 2025 20:19
@michelleN michelleN marked this pull request as ready for review February 20, 2025 20:19
+ requires api token for weather site
+ can provide an ip addr to test with

SPIN_VARIABLE_TEST_IP_ADDR=<some ip> SPIN_VARIABLE_WAQI_API_TOKEN=<some token> spin up

Signed-off-by: Michelle Dhanani <michelle@fermyon.com>
@@ -0,0 +1,31 @@
const getClientAddressFromRequest = (req: Request): string | null => {
Copy link
Member Author

Choose a reason for hiding this comment

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

@ThorstenHans I borrowed this from one of your js samples. It'd be great to figure out how to consolidate this logic to be used across multiple sample apps

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, what are you thinking about? Sharing this across multiple apps/examples would either lead to a local or published npm package.

IMO, being repetitive here is okay, for the sake of each sample being holistic.

Or had you something different in mind @michelleN

Copy link
Member Author

Choose a reason for hiding this comment

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

yea, npm package was along the lines of what I was thinking but good point on being repetitive for the sake of being holistic. I think we should keep it as is.

@michelleN michelleN linked an issue Feb 20, 2025 that may be closed by this pull request
@michelleN michelleN force-pushed the weatherapp branch 2 times, most recently from 6e0899c to 1114c8e Compare February 20, 2025 21:54
addEventListener('fetch', async (event: FetchEvent) => {
let token = Variables.get("waqi_api_token");
if (!token) {
event.respondWith(new Response("Internal Server Error", {status: 500}));
Copy link
Contributor

Choose a reason for hiding this comment

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

It would also possibly make sense to leave a console.log here as to why the request failed to make it easier to debug. My apologies for not leaving it with the previous review.

Copy link
Member Author

Choose a reason for hiding this comment

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

updated 👍

Co-authored-by: Karthik Ganeshram <karthik.ganeshram@fermyon.com>
Signed-off-by: Michelle Dhanani <michelle@fermyon.com>
@michelleN michelleN marked this pull request as draft February 20, 2025 22:42
Signed-off-by: Michelle Dhanani <michelle@fermyon.com>
@michelleN michelleN marked this pull request as ready for review February 21, 2025 18:09
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.

add geolocation example
3 participants