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

Get geolocation about a given IP address #138

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
28779ba
Get geolocation about a given IP address
cegerhardson Jun 2, 2023
23df1d1
Add necessary bits to run test locally, and move to new location.
cegerhardson Jun 6, 2023
fc08d73
Add Github Actions to deploy Fastly's Compute@Edge: getGeolocationFor…
cegerhardson Jun 6, 2023
0b966f4
Place deploy-geoip.yaml in the correct location to be triggered
cegerhardson Jun 6, 2023
7224f68
Prepare for testing, and delete old file paths.
cegerhardson Jun 6, 2023
e70054b
Add project_directory value
cegerhardson Jun 6, 2023
97c4ec6
Move project_diretory value
cegerhardson Jun 6, 2023
f7246fc
Trying to fix path bug.
cegerhardson Jun 7, 2023
5a3506c
Trying again
cegerhardson Jun 7, 2023
37271a3
Just trying
cegerhardson Jun 7, 2023
4473889
Fingers-crossed
cegerhardson Jun 7, 2023
5a97097
Testing for auth
cegerhardson Jun 7, 2023
77ca319
Maybe?
cegerhardson Jun 7, 2023
6f4f8be
Update fastly-compute/geoip/fastly.toml
cegerhardson Jun 8, 2023
84bd996
Update fastly-compute/geoip/fastly.toml
cegerhardson Jun 8, 2023
3cd7cf2
Add Github Actions to deploy Fastly's Compute@Edge: getGeolocationFor…
cegerhardson Jun 6, 2023
1dc6920
Include region in geolocation return values.
cegerhardson Jun 8, 2023
5ec7b1b
Merge branch 'ComputeAtEdge_Test' of https://github.com/python/pypi-i…
cegerhardson Jun 9, 2023
9616015
Add Service ID
cegerhardson Jun 13, 2023
2a83ae9
Add authentication configuration via Fastly's ConfigStore.
cegerhardson Jun 15, 2023
9c5177e
Add necessary file for configuation
cegerhardson Jun 15, 2023
629c057
Update fastly-compute/geoip/.secret.json
ewdurbin Jun 15, 2023
665dd7d
Update README
cegerhardson Jun 27, 2023
44347b6
Update service description
cegerhardson Jun 27, 2023
d9f1270
Reconfigure authentication and prettify
cegerhardson Jun 27, 2023
f284d67
Update
cegerhardson Jun 28, 2023
262f214
Update references
cegerhardson Jun 29, 2023
9d67bc5
change config store name
cegerhardson Jun 30, 2023
bbafc46
get rid of try/catch
cegerhardson Jun 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions compute-at-edge-test/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/// <reference types="@fastly/js-compute" />
ewdurbin marked this conversation as resolved.
Show resolved Hide resolved

import { getGeolocationForIpAddress } from "fastly:geolocation"
async function app(event) {
try {
let ip = new URL(event.request.url).searchParams.get('ip') || event.client.address
let geo = getGeolocationForIpAddress(ip);
let respBody = JSON.stringify({
geo: {
city: geo.city,
continent: geo.continent,
country_code: geo.country_code,
country_code3: geo.country_code3,
country_name: geo.country_name,
region: null,
},
})

return new Response( respBody, {
headers: {
"Content-Type": "application/json",
},
});
} catch (error) {
console.error(error);
return new Response("Internal Server Error", {
status: 500
});
}
}

addEventListener("fetch", (event) => event.respondWith(app(event)));