hopesix
hopesix
Explore posts from servers
TTCTheo's Typesafe Cult
Created by hopesix on 4/3/2024 in #questions
Can't set env variables in package.json scripts?
src/env.js 1:
import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";

export const env = createEnv({
/**
* Specify your server-side environment variables schema here. This way you can ensure the app
* isn't built with invalid env vars.
*/
server: {
DATABASE_URL: z
.string()
.url()
.refine(
(str) => !str.includes("YOUR_PSQL_URL_HERE"),
"You forgot to change the default URL",
),
TEST_DATABASE_URL: z
.string()
.url()
.refine(
(str) => !str.includes("YOUR_TEST_PSQL_URL_HERE"),
"You forgot to change the test URL",
),
NODE_ENV: z
.enum(["development", "test", "production"])
.default("development"),
// APP_ENV: z.string(),
// ENVIRONMENT: z.string(),
},

/**
* Specify your client-side environment variables schema here. This way you can ensure the app
* isn't built with invalid env vars. To expose them to the client, prefix them with
* `NEXT_PUBLIC_`.
*/
client: {
// NEXT_PUBLIC_CLIENTVAR: z.string(),
},

/**
* You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
* middlewares) or client-side so we need to destruct manually.
*/
runtimeEnv: {
DATABASE_URL: process.env.DATABASE_URL,
TEST_DATABASE_URL: process.env.TEST_DATABASE_URL,
NODE_ENV: process.env.NODE_ENV,
// APP_ENV: process.env.APP_ENV,
// ENVIRONMENT: process.env.ENVIRONMENT,
// NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
},
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
* useful for Docker builds.
*/
skipValidation: !!process.env.SKIP_ENV_VALIDATION,
/**
* Makes it so that empty strings are treated as undefined.
* `SOME_VAR: z.string()` and `SOME_VAR=''` will throw an error.
*/
emptyStringAsUndefined: true,
});
import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";

export const env = createEnv({
/**
* Specify your server-side environment variables schema here. This way you can ensure the app
* isn't built with invalid env vars.
*/
server: {
DATABASE_URL: z
.string()
.url()
.refine(
(str) => !str.includes("YOUR_PSQL_URL_HERE"),
"You forgot to change the default URL",
),
TEST_DATABASE_URL: z
.string()
.url()
.refine(
(str) => !str.includes("YOUR_TEST_PSQL_URL_HERE"),
"You forgot to change the test URL",
),
NODE_ENV: z
.enum(["development", "test", "production"])
.default("development"),
// APP_ENV: z.string(),
// ENVIRONMENT: z.string(),
},

/**
* Specify your client-side environment variables schema here. This way you can ensure the app
* isn't built with invalid env vars. To expose them to the client, prefix them with
* `NEXT_PUBLIC_`.
*/
client: {
// NEXT_PUBLIC_CLIENTVAR: z.string(),
},

/**
* You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
* middlewares) or client-side so we need to destruct manually.
*/
runtimeEnv: {
DATABASE_URL: process.env.DATABASE_URL,
TEST_DATABASE_URL: process.env.TEST_DATABASE_URL,
NODE_ENV: process.env.NODE_ENV,
// APP_ENV: process.env.APP_ENV,
// ENVIRONMENT: process.env.ENVIRONMENT,
// NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
},
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
* useful for Docker builds.
*/
skipValidation: !!process.env.SKIP_ENV_VALIDATION,
/**
* Makes it so that empty strings are treated as undefined.
* `SOME_VAR: z.string()` and `SOME_VAR=''` will throw an error.
*/
emptyStringAsUndefined: true,
});
3 replies
TTCTheo's Typesafe Cult
Created by rampa2510 on 3/31/2024 in #questions
A guide for tRPC MySQL drizzle testing setup
If you find anything please let me know, I'm also starting unit testing for my app and have no idea where to start. Seems like vitest is pretty widely used, right now I'm trying to get trpc + context working.
5 replies
TTCTheo's Typesafe Cult
Created by hopesix on 1/18/2024 in #questions
T3 tRPC tutorials/videos show useQuery / useMutation, but I only see query / mutate?
Figured it out, I was importing import { api } from "@/trpc/server"; instead of import { api } from "@/trpc/react";
6 replies
TTCTheo's Typesafe Cult
Created by hopesix on 1/18/2024 in #questions
T3 tRPC tutorials/videos show useQuery / useMutation, but I only see query / mutate?
No description
6 replies
TTCTheo's Typesafe Cult
Created by Cxstum on 11/29/2023 in #questions
What are the best resources to learn t3 stack right now (with Clerk if possible)??
I've been trying to poke around with this as well, I just finished a react course and I think I need to do a proper NextJS course before dipping my feet into T3 properly lol
5 replies