ak11
ak11
Explore posts from servers
BABetter Auth
Created by ak11 on 4/29/2025 in #help
Offline support for expo apps
hhey @bekacru
7 replies
BABetter Auth
Created by ak11 on 4/29/2025 in #help
Offline support for expo apps
okay
7 replies
BABetter Auth
Created by ak11 on 4/29/2025 in #help
Offline support for expo apps
Could you help please? @Ping
7 replies
BABetter Auth
Created by ak11 on 4/29/2025 in #help
Offline support for expo apps
this is my current protecteRoute set's up that wraps the entry of my app
import React, { useEffect } from 'react';
import { router, useSegments } from 'expo-router';
import { authClient } from '@/authClient';

interface ProtectedRouteProps {
children: React.ReactNode;
}

export const ProtectedRoute: React.FC<ProtectedRouteProps> = ({ children }) => {
const { data: session, isPending: isSessionPending } =
authClient.useSession();
const { data: activeOrg, isPending: isOrgPending } =
authClient.useActiveOrganization();

const segments = useSegments();

useEffect(() => {
if (!session && !isSessionPending) {
router.push('/sign-in');
}
if (
!session &&
!isSessionPending &&
!activeOrg &&
!isOrgPending &&
segments[0] !== '(org-list)'
) {
router.push('/recent-businesses');
}
}, [session, isSessionPending, activeOrg, isOrgPending]);

if (!session) return null;

return children;
};
import React, { useEffect } from 'react';
import { router, useSegments } from 'expo-router';
import { authClient } from '@/authClient';

interface ProtectedRouteProps {
children: React.ReactNode;
}

export const ProtectedRoute: React.FC<ProtectedRouteProps> = ({ children }) => {
const { data: session, isPending: isSessionPending } =
authClient.useSession();
const { data: activeOrg, isPending: isOrgPending } =
authClient.useActiveOrganization();

const segments = useSegments();

useEffect(() => {
if (!session && !isSessionPending) {
router.push('/sign-in');
}
if (
!session &&
!isSessionPending &&
!activeOrg &&
!isOrgPending &&
segments[0] !== '(org-list)'
) {
router.push('/recent-businesses');
}
}, [session, isSessionPending, activeOrg, isOrgPending]);

if (!session) return null;

return children;
};
7 replies
BABetter Auth
Created by ak11 on 4/14/2025 in #bug-reports
BetterAuth+Prisma given Too many Connections error
Thank you for your assistance
36 replies
BABetter Auth
Created by ak11 on 4/14/2025 in #bug-reports
BetterAuth+Prisma given Too many Connections error
i would update you further if i still get "too many connections error"
36 replies
BABetter Auth
Created by ak11 on 4/14/2025 in #bug-reports
BetterAuth+Prisma given Too many Connections error
silly me
36 replies
BABetter Auth
Created by ak11 on 4/14/2025 in #bug-reports
BetterAuth+Prisma given Too many Connections error
that error has gone
36 replies
BABetter Auth
Created by ak11 on 4/14/2025 in #bug-reports
BetterAuth+Prisma given Too many Connections error
sorry. my bad. i was putting
import {db} from '@/prisma/db';
import {db} from '@/prisma/db';
and not
import db from '@/prisma/db';
import db from '@/prisma/db';
36 replies
BABetter Auth
Created by ak11 on 4/14/2025 in #bug-reports
BetterAuth+Prisma given Too many Connections error
error
2025-04-14T05:29:47.329Z ERROR [Better Auth]: INTERNAL_SERVER_ERROR TypeError: Cannot read properties of undefined (reading 'session')
at Object.findOne (/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-auth/dist/adapters/prisma-adapter/index.cjs:163:14)
at Object.findSession (/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-auth/dist/shared/better-auth.BGUZBbM4.cjs:345:37)
at /Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-auth/dist/shared/better-auth.BDYXUcLv.cjs:389:57
at internalHandler (/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-call/dist/index.cjs:606:22)
at api.<computed> (/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-auth/dist/api/index.cjs:484:22)
at processRequest (/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-call/dist/index.cjs:4894:24)
at handler (/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-call/dist/index.cjs:4914:19)
at handler (/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/@expo/server/src/index.ts:197:17)
at /Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/@expo/server/src/vendor/http.ts:30:24
2025-04-14T05:29:47.360Z ERROR [Better Auth]: INTERNAL_SERVER_ERROR TypeError: Cannot read properties of undefined (reading 'session')
at Object.findOne (/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-auth/dist/adapters/prisma-adapter/index.cjs:163:14)

2025-04-14T05:29:47.329Z ERROR [Better Auth]: INTERNAL_SERVER_ERROR TypeError: Cannot read properties of undefined (reading 'session')
at Object.findOne (/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-auth/dist/adapters/prisma-adapter/index.cjs:163:14)
at Object.findSession (/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-auth/dist/shared/better-auth.BGUZBbM4.cjs:345:37)
at /Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-auth/dist/shared/better-auth.BDYXUcLv.cjs:389:57
at internalHandler (/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-call/dist/index.cjs:606:22)
at api.<computed> (/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-auth/dist/api/index.cjs:484:22)
at processRequest (/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-call/dist/index.cjs:4894:24)
at handler (/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-call/dist/index.cjs:4914:19)
at handler (/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/@expo/server/src/index.ts:197:17)
at /Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/@expo/server/src/vendor/http.ts:30:24
2025-04-14T05:29:47.360Z ERROR [Better Auth]: INTERNAL_SERVER_ERROR TypeError: Cannot read properties of undefined (reading 'session')
at Object.findOne (/Users/mac/Documents/workspace/business-copilot/business-copilot-webapp/node_modules/better-auth/dist/adapters/prisma-adapter/index.cjs:163:14)

36 replies
BABetter Auth
Created by ak11 on 4/14/2025 in #bug-reports
BetterAuth+Prisma given Too many Connections error
36 replies
BABetter Auth
Created by ak11 on 4/14/2025 in #bug-reports
BetterAuth+Prisma given Too many Connections error
ok let me send my full db.ts. as well as my auth.ts
36 replies
BABetter Auth
Created by ak11 on 4/14/2025 in #bug-reports
BetterAuth+Prisma given Too many Connections error
that's what i did. in my db.ts This is my imports
import { Prisma, PrismaClient } from '@/prisma/generated/prisma';
import { Prisma, PrismaClient } from '@/prisma/generated/prisma';
Then
declare global {
var db: PrismaClient | undefined;
}

const db = global.db || new PrismaClient();

if (process.env.NODE_ENV !== ‘production’) {
global.db = db;
}

export default db;
declare global {
var db: PrismaClient | undefined;
}

const db = global.db || new PrismaClient();

if (process.env.NODE_ENV !== ‘production’) {
global.db = db;
}

export default db;
36 replies
BABetter Auth
Created by ak11 on 4/14/2025 in #bug-reports
BetterAuth+Prisma given Too many Connections error
i did that a while back but was worried it would create multiple connections
36 replies
BABetter Auth
Created by ak11 on 4/14/2025 in #bug-reports
BetterAuth+Prisma given Too many Connections error
just Prisma and PrismaClient
36 replies
BABetter Auth
Created by ak11 on 4/14/2025 in #bug-reports
BetterAuth+Prisma given Too many Connections error
but there's no "prisma" coming from the grenerated file
36 replies
BABetter Auth
Created by ak11 on 4/14/2025 in #bug-reports
BetterAuth+Prisma given Too many Connections error
oh
36 replies
BABetter Auth
Created by ak11 on 4/14/2025 in #bug-reports
BetterAuth+Prisma given Too many Connections error
36 replies
BABetter Auth
Created by ak11 on 4/14/2025 in #bug-reports
BetterAuth+Prisma given Too many Connections error
they are stored at "./generated/prisma"
36 replies
BABetter Auth
Created by ak11 on 4/14/2025 in #bug-reports
BetterAuth+Prisma given Too many Connections error
on it
36 replies