Skip to content

Commit 92914b9

Browse files
authored
better-auth in cli (#64)
2 parents a79339f + 54a4a7b commit 92914b9

File tree

153 files changed

+4719
-1466
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+4719
-1466
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package-lock.json
88
yarn.lock
99

1010
# TESTING
11-
/coverage
11+
coverage/
1212
*.lcov
1313
.nyc_output
1414

apps/docs/next.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { createMDX } from "fumadocs-mdx/next";
22
import { type NextConfig } from "next";
3-
import { validateRegistry } from "@/registry/lib/validator";
3+
import { validateRegistry } from "@proofkit/registry";
44

55
const withMDX = createMDX();
6-
validateRegistry();
6+
// validateRegistry();
77

88
const config: NextConfig = {
99
reactStrictMode: true,
1010
serverExternalPackages: ["typescript", "twoslash", "shiki"],
11-
transpilePackages: ["@proofkit/fmdapi"],
11+
transpilePackages: ["@proofkit/fmdapi", "@proofkit/registry"],
1212
async redirects() {
1313
return [
1414
{

apps/docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"test": "vitest run"
1111
},
1212
"dependencies": {
13+
"@proofkit/registry": "workspace:*",
1314
"@proofkit/typegen": "workspace:*",
1415
"@proofkit/webviewer": "workspace:*",
1516
"@radix-ui/react-separator": "^1.1.7",

apps/docs/src/app/r/[[...name]]/registry.ts

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { Hono } from "hono";
22

3-
import { getRegistryIndex, getStaticComponent } from "@/registry/lib/utils";
3+
import {
4+
getComponentMeta,
5+
getRegistryIndex,
6+
getStaticComponent,
7+
} from "@proofkit/registry";
8+
import { createMiddleware } from "hono/factory";
9+
import type { TemplateMetadata } from "@proofkit/registry";
410

511
const app = new Hono().basePath("/r");
612

@@ -16,18 +22,57 @@ app.get("/", async (c) => {
1622
}
1723
});
1824

19-
// Handle registry requests at base path "/r"
20-
app.get("/:path", async (c) => {
21-
const path = c.req.param("path");
25+
const componentMeta = (basePath: string) =>
26+
createMiddleware<{
27+
Variables: { meta: TemplateMetadata; path: string };
28+
}>(async (c, next) => {
29+
console.log("c.req.path", c.req.path);
30+
console.log("basePath", basePath);
31+
const path = c.req.path.replace(basePath, "").replace(/\.json$/, "");
32+
console.log("path", path);
33+
c.set("path", path);
2234

23-
// Support both with and without .json suffix; path may contain slashes
24-
const pathWithoutJson = path.replace(/\.json$/, "");
25-
try {
26-
const data = await getStaticComponent(pathWithoutJson);
27-
return c.json(data);
28-
} catch (error) {
29-
console.error(error);
30-
return c.json({ error: "Component not found." }, { status: 404 });
35+
try {
36+
const meta = await getComponentMeta(path);
37+
c.set("meta", meta);
38+
await next();
39+
} catch (error) {
40+
console.error(error);
41+
return c.json({ error: "Component not found." }, { status: 404 });
42+
}
43+
});
44+
45+
// Handle meta requests first (more specific route)
46+
app.get("/meta/*", componentMeta("/r/meta"), async (c) => {
47+
const meta = c.get("meta");
48+
return c.json(meta, 200);
49+
});
50+
51+
// Handle registry requests at base path "/r" (less specific route)
52+
app.get("/*", componentMeta("/r"), async (c) => {
53+
const path = c.get("path");
54+
const requestUrl = new URL(c.req.url);
55+
56+
const meta = c.get("meta");
57+
if (meta.type === "static") {
58+
try {
59+
const data = await getStaticComponent(path);
60+
61+
return c.json({
62+
...data,
63+
registryDependencies: data.registryDependencies?.map((x) =>
64+
x.replace("{proofkit}", requestUrl.origin),
65+
),
66+
});
67+
} catch (error) {
68+
console.error(error);
69+
return c.json({ error: "Component not found." }, { status: 404 });
70+
}
71+
} else {
72+
return c.json(
73+
{ error: "Dynamic components are not supported yet." },
74+
{ status: 501 },
75+
);
3176
}
3277
});
3378

apps/docs/src/registry/lib/types.ts

Lines changed: 0 additions & 71 deletions
This file was deleted.

apps/docs/src/registry/lib/utils.ts

Lines changed: 0 additions & 121 deletions
This file was deleted.

0 commit comments

Comments
 (0)