MCPcopy Index your code
hub / github.com/epicweb-dev/react-suspense / loader

Function loader

exercises/04.image/02.problem.error/api.server.ts:6–35  ·  view source on GitHub ↗
({
	request,
	params,
}: {
	request: Request
	params: Record<string, string>
})

Source from the content-addressed store, hash-verified

4export type ShipSearch = Awaited<ReturnType<typeof searchShips>>
5
6export async function loader({
7 request,
8 params,
9}: {
10 request: Request
11 params: Record<string, string>
12}) {
13 const path = params['*']
14 switch (path) {
15 case 'search-ships': {
16 const result = await searchShips(request)
17 return new Response(JSON.stringify(result), {
18 headers: {
19 'content-type': 'application/json',
20 },
21 })
22 }
23 case 'get-ship': {
24 const result = await getShip(request)
25 return new Response(JSON.stringify(result), {
26 headers: {
27 'content-type': 'application/json',
28 },
29 })
30 }
31 default: {
32 return new Response('Not found', { status: 404 })
33 }
34 }
35}

Callers

nothing calls this directly

Calls 2

searchShipsFunction · 0.90
getShipFunction · 0.90

Tested by

no test coverage detected