mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-10-01 23:58:36 -05:00
SQL solution migration to Kysely + getting rid of routes folder (#1530)
* Kysely initial * Badges initial * Badge routes migrated * Badges migrated * Calendar work * Fix one type problem * Calendar work * findResultsByUserId work * Calendar reworking finished * PlusSuggestions work * Migrated suggestions * Builds progress * Migrated builds * Admin migrated * Migrate articles * User search * Faster getUser * Selectable/insertable as global * Refresh prod db script + patronTier index * identifierToUserId * updateProfile * findByIdentifier * More indexes * User upsert * upsertLite * findAllPlusMembers * updateResultHighlights * updateMany * User finished migration * Fix types * Fix PlusVotingResult typing * PlusVotingRepository WIP * Migrated resultsByMonthYear * Migrated plusVotes (done with db. related migrations) * Plus code to features folder * Fix TODOs * Export * Fix range * Migrate some user pages * Move rest user routes * Move /play * Map list generator * Front page * Move map list generation logic * Move plus voting logic * Info * API * Adjust TODOs * theme * Auth * Remove TODO
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import Database from "better-sqlite3";
|
||||
import invariant from "tiny-invariant";
|
||||
import { Kysely, ParseJSONResultsPlugin, SqliteDialect } from "kysely";
|
||||
import type { DB } from "./tables";
|
||||
|
||||
invariant(process.env["DB_PATH"], "DB_PATH env variable must be set");
|
||||
export const sql = new Database(process.env["DB_PATH"]);
|
||||
@@ -7,3 +9,11 @@ export const sql = new Database(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,
|
||||
}),
|
||||
log: process.env.NODE_ENV === "development" ? ["query"] : undefined,
|
||||
plugins: [new ParseJSONResultsPlugin()],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user