mirror of
https://github.com/soconnor0919/hristudio.git
synced 2026-03-23 19:27:51 -04:00
- Install better-auth and @better-auth/drizzle-adapter - Create src/lib/auth.ts with Better Auth configuration using bcrypt - Update database schema: change auth table IDs from uuid to text - Update route handler from /api/auth/[...nextauth] to /api/auth/[...all] - Update tRPC context and middleware for Better Auth session handling - Update client components to use Better Auth APIs (signIn, signOut) - Update seed script with text-based IDs and correct account schema - Fix type errors in wizard components (robotId, optional chaining) - Fix API paths: api.robots.initialize -> api.robots.plugins.initialize - Update auth router to use text IDs for Better Auth compatibility Note: Auth tables were reset - users will need to re-register.
60 lines
2.4 KiB
JavaScript
60 lines
2.4 KiB
JavaScript
"use client";
|
|
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.api = void 0;
|
|
exports.TRPCReactProvider = TRPCReactProvider;
|
|
var react_query_1 = require("@tanstack/react-query");
|
|
var client_1 = require("@trpc/client");
|
|
var react_query_2 = require("@trpc/react-query");
|
|
var react_1 = require("react");
|
|
var superjson_1 = require("superjson");
|
|
var query_client_1 = require("./query-client");
|
|
var clientQueryClientSingleton = undefined;
|
|
var getQueryClient = function () {
|
|
if (typeof window === "undefined") {
|
|
// Server: always make a new query client
|
|
return (0, query_client_1.createQueryClient)();
|
|
}
|
|
// Browser: use singleton pattern to keep the same query client
|
|
clientQueryClientSingleton !== null && clientQueryClientSingleton !== void 0 ? clientQueryClientSingleton : (clientQueryClientSingleton = (0, query_client_1.createQueryClient)());
|
|
return clientQueryClientSingleton;
|
|
};
|
|
exports.api = (0, react_query_2.createTRPCReact)();
|
|
function TRPCReactProvider(props) {
|
|
var queryClient = getQueryClient();
|
|
var trpcClient = (0, react_1.useState)(function () {
|
|
return exports.api.createClient({
|
|
links: [
|
|
(0, client_1.loggerLink)({
|
|
enabled: function (op) {
|
|
return process.env.NODE_ENV === "development" ||
|
|
(op.direction === "down" && op.result instanceof Error);
|
|
},
|
|
}),
|
|
(0, client_1.httpBatchStreamLink)({
|
|
transformer: superjson_1.default,
|
|
url: getBaseUrl() + "/api/trpc",
|
|
headers: function () {
|
|
var headers = new Headers();
|
|
headers.set("x-trpc-source", "nextjs-react");
|
|
return headers;
|
|
},
|
|
}),
|
|
],
|
|
});
|
|
})[0];
|
|
return (<react_query_1.QueryClientProvider client={queryClient}>
|
|
<exports.api.Provider client={trpcClient} queryClient={queryClient}>
|
|
{props.children}
|
|
</exports.api.Provider>
|
|
</react_query_1.QueryClientProvider>);
|
|
}
|
|
function getBaseUrl() {
|
|
var _a;
|
|
if (typeof window !== "undefined")
|
|
return window.location.origin;
|
|
if (process.env.VERCEL_URL)
|
|
return "https://".concat(process.env.VERCEL_URL);
|
|
return "http://localhost:".concat((_a = process.env.PORT) !== null && _a !== void 0 ? _a : 3000);
|
|
}
|