Joseph Ferano 9b753cf103 Porting database from SQLite to PostgreSQL
- New Postgres table schemas
- Using Stored Procedures with transactions that validate business logic
- User Ids now use UUID
- Updated and simplified all endpoints to call the stored procedures

Notes: There are still a few things missing that broke because of the migration,
in particular, because we moved a lot of the business logic into the database,
we now require that certain data that lived in the game-config.json to be
present in the database as well, to prevent cheating and truly have a single
source of truth.
2023-03-30 14:13:30 +07:00

17 lines
397 B
TypeScript

import sqlite3 from "sqlite3";
import { open } from "sqlite";
import { Pool } from "pg";
export const dbConnection = open({
filename: "database.db",
driver: sqlite3.Database,
});
export const postgresConnection = new Pool({
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
host: process.env.DB_HOST,
port: +process.env.DB_PORT!,
database: process.env.DB_DATABASE,
});