mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-15 06:35:20 -07:00
Keep prod health checks and route fallbacks from failing on stale API entries
Add a Bun health script that exercises top-level, dynamic, and representative video routes against one or more hosts so prod regressions are visible from a single command. Device pages now fall back to the bundled device list when the external API misses a slug, and orphaned tv slugs redirect to /benchmarks instead of returning a 500. Video fallback logic reuses the existing YouTube-to-listing builder so route reconstruction stays aligned with the current build logic. Constraint: The external API host can lag behind the frontend build and omit per-slug JSON files that public routes still expect Rejected: Import the generated video list directly | static/video-list.json is too large for a safe SSR fallback Rejected: Leave missing tv routes as 500s | a stale public URL should degrade to a useful redirect instead of breaking the request Confidence: medium Scope-risk: moderate Reversibility: clean Directive: Keep route fallbacks tied to build-time artifacts from the same repo so frontend and fallback data stay in sync Tested: bun scripts/health http://127.0.0.1:4322; vitest ./test/prebuild/config-node.test.js ./test/prebuild/site-listings.test.js; pnpm run netlify-build Not-tested: live production deploy before push
This commit is contained in:
parent
820e495d2d
commit
6cfbfbf530
7 changed files with 224 additions and 7 deletions
29
test/prebuild/site-listings.test.js
Normal file
29
test/prebuild/site-listings.test.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import {
|
||||
getDeviceListingBySlug,
|
||||
getVideoListingBySlug
|
||||
} from '~/helpers/site-listings.js'
|
||||
|
||||
describe( 'site listing fallbacks', () => {
|
||||
it( 'loads known devices from the bundled device list', () => {
|
||||
expect( getDeviceListingBySlug( 'm1-imac' ) ).toMatchObject({
|
||||
name: 'M1 iMac',
|
||||
endpoint: '/device/m1-imac'
|
||||
})
|
||||
})
|
||||
|
||||
it( 'rebuilds known tv listings from the bundled YouTube source', async () => {
|
||||
await expect(
|
||||
getVideoListingBySlug( 'install-instagram-app-on-m1-macbook-air-apple-silicon-tutorial-i-vfbmworal6i' )
|
||||
).resolves.toMatchObject({
|
||||
endpoint: '/tv/install-instagram-app-on-m1-macbook-air-apple-silicon-tutorial-i-vfbmworal6i'
|
||||
})
|
||||
})
|
||||
|
||||
it( 'returns null for missing tv slugs', async () => {
|
||||
await expect(
|
||||
getVideoListingBySlug( 'apple-silicon-gaming-is-here' )
|
||||
).resolves.toBeNull()
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue