Let DB_PATH be configurable
This commit is contained in:
parent
8ebd85b760
commit
14eb3cb43b
|
@ -5,7 +5,7 @@
|
|||
"start": "deno run --allow-read --allow-write=data --allow-env --allow-net --unstable src/server.ts",
|
||||
"dev": "deno run --allow-read --allow-write=data --allow-env --allow-net --unstable --watch src/server.ts",
|
||||
"debug": "deno run --allow-read --allow-write=data --allow-env --allow-net --unstable --inspect src/server.ts",
|
||||
"test": "deno test --allow-read --allow-write=data --allow-env --unstable src",
|
||||
"test": "DB_PATH=\":memory:\" deno test --allow-read --allow-write=data --allow-env --unstable src",
|
||||
"check": "deno check --unstable src/server.ts"
|
||||
},
|
||||
"imports": {
|
||||
|
|
|
@ -45,6 +45,9 @@ const Conf = {
|
|||
get localDomain() {
|
||||
return Deno.env.get('LOCAL_DOMAIN') || 'http://localhost:8000';
|
||||
},
|
||||
get dbPath() {
|
||||
return Deno.env.get('DB_PATH') || 'data/db.sqlite3';
|
||||
},
|
||||
get postCharLimit() {
|
||||
return Number(Deno.env.get('POST_CHAR_LIMIT') || 5000);
|
||||
},
|
||||
|
|
|
@ -2,6 +2,7 @@ import fs from 'node:fs/promises';
|
|||
import path from 'node:path';
|
||||
|
||||
import { DenoSqliteDialect, FileMigrationProvider, Kysely, Migrator, Sqlite } from '@/deps.ts';
|
||||
import { Conf } from '@/config.ts';
|
||||
|
||||
interface DittoDB {
|
||||
events: EventRow;
|
||||
|
@ -35,7 +36,7 @@ interface UserRow {
|
|||
|
||||
const db = new Kysely<DittoDB>({
|
||||
dialect: new DenoSqliteDialect({
|
||||
database: new Sqlite('data/db.sqlite3'),
|
||||
database: new Sqlite(Conf.dbPath),
|
||||
}),
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue