Sturlen
Sturlen
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Sturlen on 5/16/2024 in #questions
Vercel Data Cache Debugging
No description
2 replies
TTCTheo's Typesafe Cult
Created by Sturlen on 2/5/2024 in #questions
How do you safely store your API keys?
I currently store a lot of different API keys and secrets across various .env files (which are not checked in to git) on my local machine. If I need to reuse a key usually look into other project files and copy it from there. Is this considered good practice or should I be using something like a password manager for them?
7 replies
TTCTheo's Typesafe Cult
Created by Sturlen on 7/17/2023 in #questions
Should you validate the output of DB query?
I know user input should always be validated before being stored in a DB, but what about query results? should they also be validated with zod or in a tRPC output function? interested to know if anyone has any thoughts on this.
5 replies
DTDrizzle Team
Created by Sturlen on 6/12/2023 in #help
Drizzle-kit can't load env file via t3-env
I'd like to use t3-env to validate my env variables in my Drizzle config file. I've tried importing t3-env in the config.ts file, but I'm hit with the error SyntaxError: Cannot use import statement outside a module in env.mjs, which I find odd since it is explicitly marked as an ES module. Other than this, t3-env works fine with drizzle-orm. Full Error:
Reading config file 'F:\Projects\PROJECTNAME\drizzle.config.ts'
F:\Projects\PROJECTNAME\src\env.mjs:2
import { createEnv } from "@t3-oss/env-nextjs";
^^^^^^

SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:360:18)
at wrapSafe (node:internal/modules/cjs/loader:1048:15)
at Module._compile (node:internal/modules/cjs/loader:1083:27)
at Module._compile (F:\Projects\PROJECTNAME\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\index.js:16334:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
at Object.newLoader [as .mjs] (F:\Projects\PROJECTNAME\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\index.js:16338:13)
at Module.load (node:internal/modules/cjs/loader:997:32)
at Module._load (node:internal/modules/cjs/loader:838:12)
at Module.require (node:internal/modules/cjs/loader:1021:19)
at require (node:internal/modules/cjs/helpers:103:18)

Node.js v18.9.0
Reading config file 'F:\Projects\PROJECTNAME\drizzle.config.ts'
F:\Projects\PROJECTNAME\src\env.mjs:2
import { createEnv } from "@t3-oss/env-nextjs";
^^^^^^

SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:360:18)
at wrapSafe (node:internal/modules/cjs/loader:1048:15)
at Module._compile (node:internal/modules/cjs/loader:1083:27)
at Module._compile (F:\Projects\PROJECTNAME\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\index.js:16334:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
at Object.newLoader [as .mjs] (F:\Projects\PROJECTNAME\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\index.js:16338:13)
at Module.load (node:internal/modules/cjs/loader:997:32)
at Module._load (node:internal/modules/cjs/loader:838:12)
at Module.require (node:internal/modules/cjs/loader:1021:19)
at require (node:internal/modules/cjs/helpers:103:18)

Node.js v18.9.0
This is my Drizzle config file:
import type { Config } from "drizzle-kit";
import { env } from "~/env.mjs";

export default {
schema: "./src/server/schema.ts",
out: "./drizzle",
connectionString: env.DATABASE_URL,
} satisfies Config;
import type { Config } from "drizzle-kit";
import { env } from "~/env.mjs";

export default {
schema: "./src/server/schema.ts",
out: "./drizzle",
connectionString: env.DATABASE_URL,
} satisfies Config;
I am I doing something wrong or is this just something drizzle-kit does not support atm?
17 replies
TTCTheo's Typesafe Cult
Created by Sturlen on 6/11/2023 in #questions
Is it possible to use t3env from a Drizzle config file?
I'm using create-t3-app but I'd like to use Drizzle instead of Prisma. I've managed to get it working, but the one pain point I have is that I can't get t3env to validate variables in my Drizzle config file. I've tried importing it normally but I'm hit with the error SyntaxError: Cannot use import statement outside a module in env.mjs, which I find odd since it is explicitly marked as an ES module and runs fine when building the page. Full Error:
Reading config file 'F:\Projects\PROJECTNAME\drizzle.config.ts'
F:\Projects\PROJECTNAME\src\env.mjs:2
import { createEnv } from "@t3-oss/env-nextjs";
^^^^^^

SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:360:18)
at wrapSafe (node:internal/modules/cjs/loader:1048:15)
at Module._compile (node:internal/modules/cjs/loader:1083:27)
at Module._compile (F:\Projects\PROJECTNAME\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\index.js:16334:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
at Object.newLoader [as .mjs] (F:\Projects\PROJECTNAME\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\index.js:16338:13)
at Module.load (node:internal/modules/cjs/loader:997:32)
at Module._load (node:internal/modules/cjs/loader:838:12)
at Module.require (node:internal/modules/cjs/loader:1021:19)
at require (node:internal/modules/cjs/helpers:103:18)

Node.js v18.9.0
Reading config file 'F:\Projects\PROJECTNAME\drizzle.config.ts'
F:\Projects\PROJECTNAME\src\env.mjs:2
import { createEnv } from "@t3-oss/env-nextjs";
^^^^^^

SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:360:18)
at wrapSafe (node:internal/modules/cjs/loader:1048:15)
at Module._compile (node:internal/modules/cjs/loader:1083:27)
at Module._compile (F:\Projects\PROJECTNAME\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\index.js:16334:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
at Object.newLoader [as .mjs] (F:\Projects\PROJECTNAME\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\index.js:16338:13)
at Module.load (node:internal/modules/cjs/loader:997:32)
at Module._load (node:internal/modules/cjs/loader:838:12)
at Module.require (node:internal/modules/cjs/loader:1021:19)
at require (node:internal/modules/cjs/helpers:103:18)

Node.js v18.9.0
This is my Drizzle config file:
import type { Config } from "drizzle-kit";
import { env } from "~/env.mjs";

export default {
schema: "./src/server/schema.ts",
out: "./drizzle",
connectionString: env.DATABASE_URL,
} satisfies Config;
import type { Config } from "drizzle-kit";
import { env } from "~/env.mjs";

export default {
schema: "./src/server/schema.ts",
out: "./drizzle",
connectionString: env.DATABASE_URL,
} satisfies Config;
Let me know if this is right place to post this or if a gh issue would be more appropriate
4 replies