Maastonakki
Maastonakki
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Maastonakki on 6/21/2024 in #questions
How T3Stack env.js actually works?
I'm trying to figure out what kind of black magic that createEnv function does behind the curtains, when I'm running my application. The reason is that I'm having seed.ts at the root of my project, which I'm using to seed the database, by calling tsx seed.ts. Problem is, that if I import env.js into that seeder-file, it does not have env variables available. Same thing when I'm trying to call Encryption.encrypt() method from one of my lib-files, to encrypt some data, and that lib-file imports env.js, I get error that environmental variable are not set. Should I somehow load the .env file manually on tsx call, or what might I be missing?
6 replies
TTCTheo's Typesafe Cult
Created by Maastonakki on 5/16/2024 in #questions
Database seeding with latest T3 Stack (/w Drizzle) and Faker
Hello! I've been now working a project based on latest Theo's The Modern React Tutorial (https://www.youtube.com/watch?v=d5x0JCZbAJs) Project that I'm working requires migration from existing system to new one, after it is ready. And before that I would like to use a lot of seeded data in database, for testing UI/UX and other functionalities. Issues that I have run into, are that @faker-js/faker isn't able to provide proper types for typescript, and what I found from their documentation, for Typescript support tsconfig.json should have moduleResolution: "node", while on T3 stack it's set as Bundler. moduleResolution goes out of my understanding, and just blindly changing that to node, obviously seems to break rest of application. The second thing is with initialising Drizzle connection to Vercel Postgres. I've checked tutorial mentioned previously here on https://dev.to/anasrin/seeding-database-with-drizzle-orm-fga but in my opinion, that feels so much extra hustle (half a dozen extra packages), for just getting db seeding done, while all db-connections are done so elegantly in the stack. I would imagine that many others are also looking for faked data for their development workflow, could there maybe be demand for great YT tutorial on this?
2 replies