diff --git a/src/server/api/router/admin/images.ts b/src/server/api/router/admin/images.ts index b69d3a66..3f991184 100644 --- a/src/server/api/router/admin/images.ts +++ b/src/server/api/router/admin/images.ts @@ -23,8 +23,10 @@ export const imagesAdminRouter = router({ return await getAllImages.execute() }), getById: adminProcedure.input(getByIdSchema).query(async ({ input }) => { - return await getById.execute({ - id: input.id, - }) + return ( + (await getById.execute({ + id: input.id, + })) ?? null + ) }), }) diff --git a/src/server/db/db.ts b/src/server/db/db.ts index 424c78e4..ae6e8177 100644 --- a/src/server/db/db.ts +++ b/src/server/db/db.ts @@ -1,8 +1,11 @@ import 'server-only' import { env } from '~/env.mjs' -import { neon } from '@neondatabase/serverless' -import { drizzle as drizzleNeon, NeonHttpDatabase } from 'drizzle-orm/neon-http' +import { Pool } from '@neondatabase/serverless' +import { + drizzle as drizzleNeon, + NeonDatabase, +} from 'drizzle-orm/neon-serverless' import { drizzle as drizzlePg } from 'drizzle-orm/postgres-js' import postgres from 'postgres' import * as schema from './schema' @@ -13,5 +16,5 @@ export const db = schema, // TODO: Remove this unsafe type cast when this issue is fixed: // https://github.com/drizzle-team/drizzle-orm/issues/1129 - }) as unknown as NeonHttpDatabase) - : drizzleNeon(neon(env.DATABASE_URL), { schema }) + }) as unknown as NeonDatabase) + : drizzleNeon(new Pool({ connectionString: env.DATABASE_URL }), { schema })