Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

payto-map

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.

Project purpose

  • 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.

Setup commands

npm install
npx wrangler d1 create paytoonl-map-db

Copy 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 dev

Deploy:

npx wrangler deploy

Production D1 commands

Apply migrations remotely:

npx wrangler d1 migrations apply paytoonl-map-db --remote

Insert seed remotely:

npx wrangler d1 execute paytoonl-map-db --remote --file=./db/seed.sql

Manual 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';"

DNS / route setup

  • Cloudflare route should point map.payto.onl/* to this Worker.
  • This project uses the routes field in wrangler.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.onl is proxied through Cloudflare.

Integration possibilities

A. Direct frontend fetch from PayToonl /map

const res = await fetch("https://map.payto.onl/api/v1/locations");
const geojson = await res.json();

B. MapLibre GeoJSON source

	map.addSource("locations", {
		type: "geojson",
		data: "https://map.payto.onl/api/v1/locations"
	});

C. Filtered API

https://map.payto.onl/api/v1/locations?city=Bratislava&payment=Alipay

D. Server-side proxy from main website

  • /map-data on main site can fetch Worker API.
  • Useful if hiding API origin or adding caching.

E. Static build-time import

  • Main site can fetch GeoJSON during build and bundle it.
  • Good for speed, bad for frequent updates.

F. iframe/standalone option

  • Possible later if Worker also serves full map HTML.
  • Not implemented now.

Manual location insert examples

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_methods should be stored as a JSON string.
  • source_url and source_text are required as evidence.

Data quality rules

  • Only add shops with official source pages.
  • Keep source_url.
  • Keep verified_at date.
  • Mark inactive instead of deleting if uncertain.

API examples

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.csv

GeoJSON 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"

CORS

  • 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 cors middleware in src/index.ts.

Endpoints

  • GET / returns basic JSON service info.
  • GET /health returns { "ok": true }.
  • GET /api/v1/locations returns a GeoJSON FeatureCollection.
  • GET /api/v1/locations.json is an alias of /api/v1/locations.
  • GET /api/v1/locations.csv returns CSV for debugging and export.

Supported filters:

  • city
  • country
  • category
  • payment

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages