server for my chess game
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import pg from "pg";
const { Pool } = pg;

const pool = new Pool({
  connectionString: process.env.DATABASE_URL,
  ssl: { rejectUnauthorized: false },
});

pool.on("error", (err, client) => {
  console.error("Error:", err);
});

export async function command(command) {
  let client;
  try {
    client = await pool.connect();
    const res = await client.query(command);
    return res;
  } catch (err) {
    console.error(err.stack);
  } finally {
    client.release();
  }
}