mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 16:38:19 +01:00
18 lines
557 B
TypeScript
18 lines
557 B
TypeScript
import { join } from "node:path";
|
|
import { FileSystemRouter } from "bun";
|
|
// Returns the route filesystem path when given a URL
|
|
export const routeMatcher = new FileSystemRouter({
|
|
style: "nextjs",
|
|
dir: `${process.cwd()}/api`,
|
|
fileExtensions: [".ts", ".js"],
|
|
});
|
|
|
|
export const routes = Object.fromEntries(
|
|
Object.entries(routeMatcher.routes)
|
|
.filter(([route]) => !route.endsWith(".test"))
|
|
.map(([route, path]) => [
|
|
route,
|
|
path.replace(join(process.cwd()), "."),
|
|
]),
|
|
) as Record<string, string>;
|