partap
partap
NNuxt
Created by partap on 10/12/2024 in #❓・help
Server-only modules for Nitro
tldr; Define types separately from db implementation
4 replies
NNuxt
Created by partap on 10/12/2024 in #❓・help
Server-only modules for Nitro
Ok, I figured it out... Just forgot how I initially set up the code on the client side of the login before I implemented the server side... Turns out I was defining and exporting my User type (needed on client side) in the same module where I eventually defined the db functions (createUser, getUserByUsername, etc...) So on the client side I was using:
import type { User } from '~/lib/types'
import type { User } from '~/lib/types'
but types.ts had:
import type { User } from '~/server/lib/db/users'
export type { User }
import type { User } from '~/server/lib/db/users'
export type { User }
and in users.ts:
import sql from 'mssql'
import sql from 'mssql'
...so the client now needed to load mssql 😱
4 replies