forked from minzeyaphyo/burmddit
- 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
17 lines
505 B
TypeScript
17 lines
505 B
TypeScript
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
|
|
}
|