react-server675fbba4
react-serverfilesexamplestyped-routerresourcesmappings.ts
examples/typed-router/resources/mappings.tsts676 B0e3b375d
/**
 * Server-side resource-to-route mappings.
 *
 * Each `.from()` call maps route params/search to a resource key.
 * These are consumed by the router (router.tsx) when binding
 * resources to routes.
 */
import { userById } from "./user";
import { currentUser } from "./current-user";
import { postBySlug } from "./post";
import { todos } from "./todos/server";

export const userByIdMapping = userById.from(({ params }) => ({
  id: params.id,
}));

export const postBySlugMapping = postBySlug.from(({ params }) => ({
  slug: params.slug,
}));

export const todosServerMapping = todos.from(({ search }) => ({
  filter: search.filter ?? "all",
}));

export { currentUser };