N
Nuxtβ€’5mo ago
ethan!

Buffer is not defined

Buffer is not defined

at http://localhost:3000/_nuxt/@fs/C:/Users/ethan/Desktop/Projects/watchdog/website/node_modules/.cache/vite/client/deps/postgres.js?v=9ecbf21c:617:14
Buffer is not defined

at http://localhost:3000/_nuxt/@fs/C:/Users/ethan/Desktop/Projects/watchdog/website/node_modules/.cache/vite/client/deps/postgres.js?v=9ecbf21c:617:14
13 Replies
manniL
manniLβ€’5mo ago
you try to use postgres on the client side? πŸ€”
ethan!
ethan!OPβ€’5mo ago
the only place i reference postgres is in src/server/db/index.ts how do i know if i'm on the client or server side?
manniL
manniLβ€’5mo ago
where do you use server/db/index.ts? http://localhost:3000/_nuxt/@fs/C:/Users/ethan/Desktop/Projects/watchdog/website/node_modules/.cache/vite/client/deps/postgres.js?v=9ecbf21c:617:14 looks like it is part of the client. Most vite-related things are
ethan!
ethan!OPβ€’5mo ago
all i have in that file is
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import * as schema from "~/server/db/schema";
import { env } from "~/env";

const db = drizzle(postgres(env.DATABASE_URL), { schema });
export { db };
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import * as schema from "~/server/db/schema";
import { env } from "~/env";

const db = drizzle(postgres(env.DATABASE_URL), { schema });
export { db };
manniL
manniLβ€’5mo ago
and where do you use db?
ethan!
ethan!OPβ€’5mo ago
ah i use it in src/lib there's a lot of api calls in that file, how do i go about moving that to the server and using it in the client?
manniL
manniLβ€’5mo ago
well if you use a DB there you don't use it on the client you'd create an API endpoint in nitro and call this one instead πŸ™‚
ethan!
ethan!OPβ€’5mo ago
what are the pros of using nitro as opposed to a custom backend?
manniL
manniLβ€’5mo ago
e2e typesafety, all in one codebase, easy deployment, same language (JS/TS), fast + modern etc. you can also still use a third party backend together or without nitro, not a problem
ethan!
ethan!OPβ€’5mo ago
ah, are there any docs on that?
manniL
manniLβ€’5mo ago
Nitro - Next Generation Server Toolkit
Create web servers with everything you need and deploy them wherever you prefer.
manniL
manniLβ€’5mo ago
and there is a "server" section in the nuxt docs
ethan!
ethan!OPβ€’5mo ago
thank you
Want results from more Discord servers?
Add your server