scaffold Vike app with Bati

This commit is contained in:
Bati
2025-06-26 21:42:05 -04:00
commit 9916e95de0
38 changed files with 1023 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
import { createTRPCProxyClient, httpBatchLink } from "@trpc/client";
import type { AppRouter } from "./server.js";
export const trpc = createTRPCProxyClient<AppRouter>({
links: [
httpBatchLink({
url: "/api/trpc",
}),
],
});
+32
View File
@@ -0,0 +1,32 @@
import { initTRPC } from "@trpc/server";
/**
* Initialization of tRPC backend
* Should be done only once per backend!
*/
const t = initTRPC.context<object>().create();
/**
* Export reusable router and procedure helpers
* that can be used throughout the router
*/
export const router = t.router;
export const publicProcedure = t.procedure;
export const appRouter = router({
demo: publicProcedure.query(async () => {
return { demo: true };
}),
onNewTodo: publicProcedure
.input((value): string => {
if (typeof value === "string") {
return value;
}
throw new Error("Input is not a string");
})
.mutation(async (opts) => {
console.log("Received new todo", { text: opts.input });
}),
});
export type AppRouter = typeof appRouter;