Skip to content

Commit

Permalink
Rename file.ts to file.$key.ts and update route configuration to use …
Browse files Browse the repository at this point in the history
…flatRoutes for improved resource handling
  • Loading branch information
sergiodxa committed Jan 9, 2025
1 parent 1f826f7 commit 5c9d79d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/resources/file.ts → app/resources/file.$key.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
21 changes: 12 additions & 9 deletions app/routes.ts
Original file line number Diff line number Diff line change
@@ -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"),
Expand All @@ -32,4 +35,4 @@ export default [

// Catch-all Route
route("*", "./views/catch-all.tsx"),
];
] satisfies RouteConfig;

0 comments on commit 5c9d79d

Please sign in to comment.