Sebastian
Sebastian
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Sebastian on 1/4/2024 in #questions
Prisma turborepo deployment not initialized error
Wow, for anybody else who can't read like me, the solution is in the error message. Find out why and learn how to fix this: https://pris.ly/d/schema-not-found-nextjs apparently it's a known issue and it's even a workaround plugin from prisma for monorepos.
13 replies
TTCTheo's Typesafe Cult
Created by Sebastian on 1/4/2024 in #questions
Prisma turborepo deployment not initialized error
yeah, that's how I defined the database package in my monorepo
13 replies
TTCTheo's Typesafe Cult
Created by Sebastian on 1/4/2024 in #questions
Prisma turborepo deployment not initialized error
They displayed this as an example for how to setup turborepo with prisma https://turbo.build/repo/docs/handbook/tools/prisma
13 replies
TTCTheo's Typesafe Cult
Created by Sebastian on 1/4/2024 in #questions
Prisma turborepo deployment not initialized error
So @prisma/client is only installed in @kleerk/database, and it has an index.ts which does
export * from "@prisma/client"
export * from "@prisma/client"
The basic example on turborepo prisma docs. Then the initialization is done in the other packages which want to use PrismaClient. At build time, it depends on a "db:generate" which generates the client and types for prisma
13 replies
TTCTheo's Typesafe Cult
Created by Sebastian on 1/4/2024 in #questions
Prisma turborepo deployment not initialized error
This is the error displayed in vercel logs. This is the initialization in the apps/web The error comes after trying to import prisma in a /pages folder in order to use it in getServerSideProps for doing a check. However, the blocker is the displayed error.
import { PrismaClient } from "@kleerk/database";

declare global {
var prisma: PrismaClient | undefined;
}

export const prisma = global.prisma || new PrismaClient();

if (process.env.NODE_ENV !== "production") global.prisma = prisma;
import { PrismaClient } from "@kleerk/database";

declare global {
var prisma: PrismaClient | undefined;
}

export const prisma = global.prisma || new PrismaClient();

if (process.env.NODE_ENV !== "production") global.prisma = prisma;
13 replies
TTCTheo's Typesafe Cult
Created by Sebastian on 1/4/2024 in #questions
Prisma turborepo deployment not initialized error
PrismaClientInitializationError: Your schema.prisma could not be found, and we detected that you are using Next.js.
Find out why and learn how to fix this: https://pris.ly/d/schema-not-found-nextjs
at new pr (/var/task/apps/web/.next/server/chunks/2300.js:112:10787)
at Na (/var/task/apps/web/.next/server/chunks/2300.js:115:1589)
at new t (/var/task/apps/web/.next/server/chunks/2300.js:128:4651)
at 19097 (/var/task/apps/web/.next/server/chunks/9097.js:1:206)
at __webpack_require__ (/var/task/apps/web/.next/server/webpack-api-runtime.js:1:146)
at 38703 (/var/task/apps/web/.next/server/pages/api/auth/[...nextauth].js:1:1496)
at __webpack_require__ (/var/task/apps/web/.next/server/webpack-api-runtime.js:1:146)
at __webpack_exec__ (/var/task/apps/web/.next/server/pages/api/auth/[...nextauth].js:1:1813)
at /var/task/apps/web/.next/server/pages/api/auth/[...nextauth].js:1:1846
at __webpack_require__.X (/var/task/apps/web/.next/server/webpack-api-runtime.js:1:1610) {
clientVersion: '5.3.1',
errorCode: undefined
}
PrismaClientInitializationError: Your schema.prisma could not be found, and we detected that you are using Next.js.
Find out why and learn how to fix this: https://pris.ly/d/schema-not-found-nextjs
at new pr (/var/task/apps/web/.next/server/chunks/2300.js:112:10787)
at Na (/var/task/apps/web/.next/server/chunks/2300.js:115:1589)
at new t (/var/task/apps/web/.next/server/chunks/2300.js:128:4651)
at 19097 (/var/task/apps/web/.next/server/chunks/9097.js:1:206)
at __webpack_require__ (/var/task/apps/web/.next/server/webpack-api-runtime.js:1:146)
at 38703 (/var/task/apps/web/.next/server/pages/api/auth/[...nextauth].js:1:1496)
at __webpack_require__ (/var/task/apps/web/.next/server/webpack-api-runtime.js:1:146)
at __webpack_exec__ (/var/task/apps/web/.next/server/pages/api/auth/[...nextauth].js:1:1813)
at /var/task/apps/web/.next/server/pages/api/auth/[...nextauth].js:1:1846
at __webpack_require__.X (/var/task/apps/web/.next/server/webpack-api-runtime.js:1:1610) {
clientVersion: '5.3.1',
errorCode: undefined
}
13 replies
TTCTheo's Typesafe Cult
Created by Sebastian on 1/4/2024 in #questions
Prisma turborepo deployment not initialized error
I have a package in /packages named database, which exports * from '@prisma/client' I have setup the package.json right, I can work with the database package locally and while developing, I checked that the client is generated after removing node_modules, bun.lockb and simulate the build process.
13 replies
TTCTheo's Typesafe Cult
Created by Debaucus on 6/16/2023 in #questions
With Planetscale (or others), what's the correct way to retroactively edit a prod database?
when adding new columns, if you want the column to be not null, you can use the default directive and on a later migration you can remove it if it annoys you with anything, though I wouldn't see the point.
5 replies
TTCTheo's Typesafe Cult
Created by .traevelliath on 6/22/2023 in #questions
Prisma 2-3 levels deep queries
Make sure your schema is correctly defined. You can either use self relations or a separate table to manage the friends. If the schema is correctly defined, you should be able to perform the nested includes to get friends of friends
17 replies
TTCTheo's Typesafe Cult
Created by VIIKKK on 6/1/2023 in #questions
Question about next auth.
sure, feel free to pm me
15 replies
TTCTheo's Typesafe Cult
Created by VIIKKK on 6/1/2023 in #questions
Question about next auth.
what seems to not work
15 replies
TTCTheo's Typesafe Cult
Created by VIIKKK on 6/1/2023 in #questions
Question about next auth.
you can also reffer to the official documentation for more details: https://trpc.io/docs/server/server-side-calls
15 replies
TTCTheo's Typesafe Cult
Created by VIIKKK on 6/1/2023 in #questions
Question about next auth.
CredentialsProvider({
name: 'Credentials',
credentials: {
username: { label: "email", type: "text", placeholder: "jsmith" },
password: { label: "password", type: "text", }
},
async authorize(credentials, req) {
const res = await fetch("test/login", {
method: 'POST',
body: JSON.stringify(credentials),
headers: { "Content-Type": "application/json" }
});

const response = await res.json();

if (res.ok && response.token) {
// If the API call was successful and the token exists
const user = {
id: response.token, // Provide a unique identifier for the user // Extract relevant user data from the API response
email: credentials.username, // Use the provided email as the user's email
password: credentials.password // Add any other relevant user data from the API response
};
// initialize the new tRPC router only if the other steps where successfull
const trpcRouter = appRouter.createCaller({});
const check = await trpcRouter.CompanyEmployeeRouter.Authorize(user);

console.log(check);

}
CredentialsProvider({
name: 'Credentials',
credentials: {
username: { label: "email", type: "text", placeholder: "jsmith" },
password: { label: "password", type: "text", }
},
async authorize(credentials, req) {
const res = await fetch("test/login", {
method: 'POST',
body: JSON.stringify(credentials),
headers: { "Content-Type": "application/json" }
});

const response = await res.json();

if (res.ok && response.token) {
// If the API call was successful and the token exists
const user = {
id: response.token, // Provide a unique identifier for the user // Extract relevant user data from the API response
email: credentials.username, // Use the provided email as the user's email
password: credentials.password // Add any other relevant user data from the API response
};
// initialize the new tRPC router only if the other steps where successfull
const trpcRouter = appRouter.createCaller({});
const check = await trpcRouter.CompanyEmployeeRouter.Authorize(user);

console.log(check);

}
15 replies
TTCTheo's Typesafe Cult
Created by VIIKKK on 6/1/2023 in #questions
Question about next auth.
The thing you explicitly outlined in the pseudocode would not work. You imported a specific router and tried to access a procedure on it. When tRPC initializes does a lot of things, constructs the context and other configurations ( especially if you have built it using create-t3-app ) which it then uses in the other underlying routers which you then compose in the appRouter. What you want to do is achievable, but you will have to import the appRouter and create a new instance by calling .createCaller({}) on it. It will give you a new tRPC router which you can use to authorize the user. Your code might look something like this:
15 replies
TTCTheo's Typesafe Cult
Created by Sebastian on 5/27/2023 in #questions
Neatly extract tRPC middleware to make it reusable
up
3 replies
TTCTheo's Typesafe Cult
Created by bassamanator on 5/15/2023 in #questions
TRCPClientError when creating an entry with blank `updatedAt`
You can use the @updatedAt directive for letting prisma correctly handling it
4 replies
TTCTheo's Typesafe Cult
Created by Sebastian on 5/12/2023 in #questions
Next-Auth in server rendered components aka appDir pages
I was mainly wondering how can we get the current user in a request. I digged very little in the getServerSession from next-auth/next and saw that for server components, they take the cookies from the head using next/head and then are able to authenticate the user and return a valid session. Just if anybody was wondering that. You just need to pass the authOptions object to the getServerSession
4 replies
TTCTheo's Typesafe Cult
Created by Sebastian on 2/10/2023 in #questions
Deployment error on vercel
it worked, thanks 👌🏻
9 replies