Acro
Acro
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Acro on 10/8/2024 in #questions
T3 Env: Unconventional Setup: SvelteKit + Payload CMS
Turborepo 1. Frontend: SvelteKit - Node Adapter > build artifact in backend folder 2. Backend: Payload CMS v3 - Next.js Custom Express Server -> /admin route handled by Next.js, all other routes handled by handler.js build artifact by SvelteKit. Running backend dev (Next.js) admin - no ENV issues. It has its own .env on its root. Frontend running dev - Importing my payload.config.ts from backend to SvelteKit to make local API calls gives Required issue on all ENV variables. Meaning it isn't detecting any ENV variables. I have a .env file in root of SvelteKit. console.log() env variables and they show up. SvelteKit file that reaches outside of its project folder to get payload.config.ts from backend. The payload.config.ts references the env.MY_VARIABLE
import { type BasePayload, getPayload } from 'payload';
import config from '../../../backend/src/payload.config'

let payloadInstance: BasePayload;

export async function initializePayload() {
payloadInstance = await getPayload({ config })
}
import { type BasePayload, getPayload } from 'payload';
import config from '../../../backend/src/payload.config'

let payloadInstance: BasePayload;

export async function initializePayload() {
payloadInstance = await getPayload({ config })
}
My createEnv is at backend/src/env.ts How do I get @t3-oss/env-core to find env files like this? @t3-oss/env-core is only installed on backend. Do I need it in frontend (SvelteKit) as well? Just tried this, didn't work...
2 replies
DTDrizzle Team
Created by Acro on 3/21/2024 in #help
Examples for Error Handling?
I am looking through docs on how to handle DB errors, but not finding a list of error codes. For example, UNIQUE or NOT NULL constraints to check for. Or is this something I need to look at Postgres.js docs for? Pseudocode below using Sqlite, but want to know for Postgres.js
try {
...
} catch (e) {
if (e instanceof SqliteError && e.code === "SQLITE_CONSTRAINT_UNIQUE") {
return setError(form, 'email', "E-mail already used")
}
}
try {
...
} catch (e) {
if (e instanceof SqliteError && e.code === "SQLITE_CONSTRAINT_UNIQUE") {
return setError(form, 'email', "E-mail already used")
}
}
2 replies
DTDrizzle Team
Created by Acro on 3/21/2024 in #help
When to use what? drizzle-kit push:* Vs. having a file with drizzle migrate client?
Option 1: package.json script drizzle-kit push:pg Option 2: migrate.ts script
import { migrate } from 'drizzle-orm/postgres-js/migrator';
import postgres from 'postgres';

const migrationClient = postgres("postgres://postgres:[email protected]:5432/db", { max: 1 });
migrate(drizzle(migrationClient), ...)
import { migrate } from 'drizzle-orm/postgres-js/migrator';
import postgres from 'postgres';

const migrationClient = postgres("postgres://postgres:[email protected]:5432/db", { max: 1 });
migrate(drizzle(migrationClient), ...)
6 replies
CDCloudflare Developers
Created by Acro on 12/27/2023 in #pages-help
Cloudflare Pages + TurboRepo + PNPM
I have deployed one of my apps successfully to Vercel (so I know nothing wrong with my apps) I want to deploy on Cloudflare Pages, I get this Error: npm ERR! code EUNSUPPORTEDPROTOCOL. Which makes a lot of sense. as I specified in the root package.json as pnpm to be my packageManager. Even though I set my build command correctly. Cloudflare Pages still always runs Installing project dependencies: npm install --progress=false, before my actual build command. So it fails, as I restricted it to only allow pnpm. Why does Cloudflare pages assumes npm by default? Doesn't seem a way to disable it... I am on Build System Version: 2
27 replies