mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-03-21 18:04:39 -05:00
* Remove old code * Add prefetching * Elim bracket initial * Hide rounds with only byes * Round hiding logic * Align stuff * Add TODO * Adjustments * Deadline * Compactify button * Simulations * Round robin bracket initial * eventId -> tournamentId * seedByTeamId removed * Couple more TODOs * RR placements table * Locking matches * Extract TournamentStream component * Bracket streams * Remove extras for tournament-manager, misc * Fix E2E tests * Fix SKALOP_SYSTEM_MESSAGE_URL in env.example * TODOs * TODO moved to GitHub * Handle team changing in match cache invalidation * Fix streamer seeing undo last score button * Show "Sub" badge on team roster page * Show who didn't play yet on match teams preview * Ranked/unranked badge * Bracket hover show roster * Add lock/unlock match test * Fix score reporting
33 lines
1012 B
TypeScript
33 lines
1012 B
TypeScript
import Database from "better-sqlite3";
|
|
import invariant from "tiny-invariant";
|
|
import { Kysely, ParseJSONResultsPlugin, SqliteDialect } from "kysely";
|
|
import type { DB } from "./tables";
|
|
|
|
const migratedEmptyDb = new Database("db-test.sqlite3").serialize();
|
|
|
|
invariant(process.env["DB_PATH"], "DB_PATH env variable must be set");
|
|
const isInMemoryDB = process.env["DB_PATH"] === ":memory:";
|
|
|
|
export const sql = new Database(
|
|
isInMemoryDB ? migratedEmptyDb : process.env["DB_PATH"],
|
|
);
|
|
|
|
sql.pragma("journal_mode = WAL");
|
|
sql.pragma("foreign_keys = ON");
|
|
sql.pragma("busy_timeout = 5000");
|
|
|
|
export const db = new Kysely<DB>({
|
|
dialect: new SqliteDialect({
|
|
database: sql,
|
|
}),
|
|
// uncomment if you want examine the queries
|
|
// log: process.env.NODE_ENV === "development" ? ["query"] : undefined,
|
|
// log(event): void {
|
|
// if (event.level === "query") {
|
|
// console.log(event.query.sql);
|
|
// console.log(event.query.parameters);
|
|
// }
|
|
// },
|
|
plugins: [new ParseJSONResultsPlugin()],
|
|
});
|