Separate Cloudflare Worker API for PayToonl map locations. The main website can later consume this from https://map.payto.onl/api/v1/locations and integrate it into /map.
- Separate API Worker for PayToonl location map.
- Website can consume it from
https://map.payto.onl/api/v1/locations. - Uses Cloudflare D1 for location storage.
- No admin UI yet. Locations are inserted manually for now.
npm install
npx wrangler d1 create paytoonl-map-dbCopy the returned database_id into wrangler.jsonc.
npx wrangler d1 migrations apply paytoonl-map-db --local
npx wrangler d1 execute paytoonl-map-db --local --file=./db/seed.sql
npx wrangler devDeploy:
npx wrangler deployApply migrations remotely:
npx wrangler d1 migrations apply paytoonl-map-db --remoteInsert seed remotely:
npx wrangler d1 execute paytoonl-map-db --remote --file=./db/seed.sqlManual insert examples:
npx wrangler d1 execute paytoonl-map-db --remote --command="
INSERT INTO locations (
id,
name,
lat,
lng,
address,
city,
country,
category,
payment_methods,
source_url,
source_text,
verified_at
) VALUES (
'bratislava-coffee-01',
'Bratislava Coffee',
48.1486,
17.1077,
'Example 1, Bratislava',
'Bratislava',
'Slovakia',
'Cafe',
'[\"Alipay\",\"Alipay+\"]',
'https://example.com/alipay',
'Official payment page confirms Alipay support.',
'2026-05-26'
);"npx wrangler d1 execute paytoonl-map-db --remote --command="
UPDATE locations
SET is_active = 0
WHERE id = 'bratislava-coffee-01';"- Cloudflare route should point
map.payto.onl/*to this Worker. - This project uses the
routesfield inwrangler.jsonc. - Depending on account setup, you can also use a custom domain instead of a wildcard route.
- If switching to a custom domain later, update the Wrangler config and ensure the DNS record for
map.payto.onlis proxied through Cloudflare.
const res = await fetch("https://map.payto.onl/api/v1/locations");
const geojson = await res.json(); map.addSource("locations", {
type: "geojson",
data: "https://map.payto.onl/api/v1/locations"
});https://map.payto.onl/api/v1/locations?city=Bratislava&payment=Alipay/map-dataon main site can fetch Worker API.- Useful if hiding API origin or adding caching.
- Main site can fetch GeoJSON during build and bundle it.
- Good for speed, bad for frequent updates.
- Possible later if Worker also serves full map HTML.
- Not implemented now.
SQL INSERT example:
INSERT INTO locations (
id,
name,
lat,
lng,
address,
city,
country,
category,
payment_methods,
source_url,
source_text,
verified_at
) VALUES (
'example-brno-shop',
'Example Brno Shop',
49.1951,
16.6068,
'Brno, Czech Republic',
'Brno',
'Czech Republic',
'Retail',
'["Alipay","Alipay+"]',
'https://example.com/payment-methods',
'Official store page lists supported payment methods.',
'2026-05-26'
);payment_methodsshould be stored as a JSON string.source_urlandsource_textare required as evidence.
- Only add shops with official source pages.
- Keep
source_url. - Keep
verified_atdate. - Mark inactive instead of deleting if uncertain.
curl examples:
curl https://map.payto.onl/
curl https://map.payto.onl/health
curl "https://map.payto.onl/api/v1/locations?city=Bratislava"
curl https://map.payto.onl/api/v1/locations.csvGeoJSON response example:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [17.1077, 48.1486]
},
"properties": {
"id": "example-bratislava-shop",
"name": "Example Bratislava Shop",
"address": "Bratislava, Slovakia",
"city": "Bratislava",
"country": "Slovakia",
"category": "Retail",
"payment_methods": ["Alipay", "Alipay+"],
"source_url": "https://example.com/payment-methods",
"source_text": "Website states that Alipay is accepted.",
"verified_at": "2026-05-26"
}
}
]
}CSV export example:
"id","name","lat","lng","address","city","country","category","payment_methods","source_url","source_text","verified_at"
"example-bratislava-shop","Example Bratislava Shop","48.1486","17.1077","Bratislava, Slovakia","Bratislava","Slovakia","Retail","[""Alipay"",""Alipay+""]","https://example.com/payment-methods","Website states that Alipay is accepted.","2026-05-26"- The current Worker allows all origins with
Access-Control-Allow-Origin: *. - This is convenient for early integration and local testing.
- If you want to restrict origins later, update the Hono
corsmiddleware in src/index.ts.
GET /returns basic JSON service info.GET /healthreturns{ "ok": true }.GET /api/v1/locationsreturns a GeoJSONFeatureCollection.GET /api/v1/locations.jsonis an alias of/api/v1/locations.GET /api/v1/locations.csvreturns CSV for debugging and export.
Supported filters:
citycountrycategorypayment