index-now
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data β all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v106View latest version
This val automates IndexNow submission by:
- Crawling sitemap URLs.
- Tracking submission history in project-scoped SQLite.
- Submitting only changed URLs in batches (up to 10,000 URLs per POST).
indexnow.http.ts: primary HTTP entrypoint./serves the dashboard UI./runperforms IndexNow submission runs (JSON response)./monitorserves monitor JSON (or dashboard via?view=dashboardif needed).
indexnow.cron.ts: scheduled trigger that calls the HTTP handler at/run.indexnow.monitor.http.ts: monitor implementation module used byindexnow.http.ts.
The recommended setup is a cron trigger every hour for sitemap polling, plus /run for immediate/manual control.
INDEXNOW_RUN_TOKEN(required): auth token required for/run(manual and cron).INDEXNOW_FORCE_TOKEN(optional but recommended): separate auth token required when usingforce=1.INDEXNOW_ENDPOINT(optional): defaults tohttps://api.indexnow.org/indexnow.INDEXNOW_MAX_URLS_PER_RUN(optional): defaults to5000.
Site configs live in config/sites/*.json with one site per file.
At least one file must exist or the val will throw on startup.
Example: config/sites/hanayou.studio.json
{ "host": "www.hanayou.studio", "sitemapUrl": "https://www.hanayou.studio/sitemap.xml", "keyLocation": "https://www.hanayou.studio/2dc12b205bfe46d19a75077e3991f7ce.txt", "key": "optional-explicit-key", "includePrefixes": ["/journal/", "/guides/"], "excludePrefixes": ["/tag/", "/author/"] }
- Dashboard:
/ - Run endpoint:
/run /runisPOSTonly and requires auth:Authorization: Bearer <INDEXNOW_RUN_TOKEN>orx-indexnow-token: <INDEXNOW_RUN_TOKEN>
- Dry run:
POST /run?dryRun=1 - Force resubmit currently eligible URLs:
POST /run?force=1- also requires
x-indexnow-force-token: <INDEXNOW_FORCE_TOKEN>
- also requires
- Target a single configured site:
POST /run?site=www.hanayou.studio - Response includes stage-specific URL arrays:
siteRuns[].filteredUrlsfor URLs that passed filters.siteRuns[].changedUrlsfor URLs detected as changed.siteRuns[].queuedUrlsfor changed URLs after run-cap limiting.siteRuns[].submittedCountcounts only HTTP200responses.- HTTP
202responses are tracked as pending insiteRuns[].pendingCount.
Example:
curl -X POST "https://<your-val>.web.val.run/run?dryRun=1&site=www.hanayou.studio" \ -H "x-indexnow-token: <INDEXNOW_RUN_TOKEN>"
Force example:
curl -X POST "https://<your-val>.web.val.run/run?force=1&site=www.hanayou.studio" \ -H "x-indexnow-token: <INDEXNOW_RUN_TOKEN>" \ -H "x-indexnow-force-token: <INDEXNOW_FORCE_TOKEN>"
- Path:
/monitoronindexnow.http.ts(JSON default) - Purpose: IndexNow health snapshot from config + SQLite state
- Query params:
site(optional): limit report to one configured host.runs(optional): recent run history per site (default 50, max 500).view(optional):dashboardfor HTML UI, otherwise JSON.
Response highlights:
totals.everSubmitted200Urls: URLs that have ever had a confirmed HTTP200submission.totals.upToDateUrls: URLs whose latest sitemaplastmodis already covered by the last successful submission.totals.needsSubmissionUrls: URLs never successfully submitted, or changed since last successful submission.totals.retryPendingUrls: URLs that need submission and whose latest attempt was a non-200/202failure.sites[].latestRun: latest run summary per site.sites[].recentRuns: recent run history per site.
Dashboard example:
https://<your-val>.web.val.run/?site=www.hanayou.studio&runs=50
SQLite tables:
indexnow_url_state_v1: per-URL state (seen/submitted timestamps, lastmod, status).indexnow_run_log_v1: per-run summaries for observability and debugging.
This val uses https://esm.town/v/std/sqlite/main.ts so data is scoped to this val project.