N
Nuxtβ€’6mo 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β€’6mo ago
you try to use postgres on the client side? πŸ€”
ethan!
ethan!OPβ€’6mo 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β€’6mo 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β€’6mo 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β€’6mo ago
and where do you use db?
ethan!
ethan!OPβ€’6mo 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β€’6mo 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β€’6mo ago
what are the pros of using nitro as opposed to a custom backend?
manniL
manniLβ€’6mo 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β€’6mo ago
ah, are there any docs on that?
manniL
manniLβ€’6mo ago
Nitro - Next Generation Server Toolkit
Create web servers with everything you need and deploy them wherever you prefer.
manniL
manniLβ€’6mo ago
and there is a "server" section in the nuxt docs
ethan!
ethan!OPβ€’6mo ago
thank you
Want results from more Discord servers?
Add your server