forked from minzeyaphyo/burmddit
Adapt for self-hosted deployment on Coolify
- Replace @vercel/postgres with standard pg library - Add Dockerfile for Next.js standalone build - Add tsconfig.json, postcss.config.js - Fix globals.css undefined tailwind utilities - Force dynamic rendering for DB-dependent pages - Add .dockerignore
This commit is contained in:
16
frontend/lib/db.ts
Normal file
16
frontend/lib/db.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Pool } from 'pg'
|
||||
|
||||
const pool = new Pool({
|
||||
connectionString: process.env.DATABASE_URL,
|
||||
})
|
||||
|
||||
// Tagged template literal that mimics @vercel/postgres sql`` syntax
|
||||
export async function sql(strings: TemplateStringsArray, ...values: any[]) {
|
||||
// Build parameterized query: replace template expressions with $1, $2, etc.
|
||||
let text = strings[0]
|
||||
for (let i = 0; i < values.length; i++) {
|
||||
text += `$${i + 1}` + strings[i + 1]
|
||||
}
|
||||
const result = await pool.query(text, values)
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user