diff --git a/app/resources/file.ts b/app/resources/file.$key.ts similarity index 71% rename from app/resources/file.ts rename to app/resources/file.$key.ts index 11f38a8..568167d 100644 --- a/app/resources/file.ts +++ b/app/resources/file.$key.ts @@ -1,5 +1,5 @@ import { fs } from "edgekitjs"; -import type { Route } from "./+types/file"; +import type { Route } from "./+types/file.$key"; export function loader({ params }: Route.LoaderArgs) { return fs().serve(params.key); diff --git a/app/routes.ts b/app/routes.ts index 026e4b7..4952610 100644 --- a/app/routes.ts +++ b/app/routes.ts @@ -1,14 +1,17 @@ -import { index, layout, prefix, route } from "@react-router/dev/routes"; +import { + type RouteConfig, + index, + layout, + prefix, + route, +} from "@react-router/dev/routes"; +import { flatRoutes } from "@react-router/fs-routes"; + +const resources = await flatRoutes({ rootDirectory: "./resources" }); export default [ // Resources - route("files/:key", "./resources/file.ts"), - - // API Routes - ...prefix("api", []), - - // Webhook Routes - ...prefix("webhooks", []), + ...resources, // Views route("profile", "./views/profile.tsx"), @@ -32,4 +35,4 @@ export default [ // Catch-all Route route("*", "./views/catch-all.tsx"), -]; +] satisfies RouteConfig;