feat(release): Setup automatic docker build
This commit is contained in:
parent
a3c1bae6db
commit
d5f5fe5f1a
8 changed files with 79 additions and 5 deletions
|
|
@ -30,6 +30,7 @@ export class Services {
|
|||
container.set<Logger>(logger, 'logger');
|
||||
|
||||
const database = new DatabaseConnection(env.database);
|
||||
database.connect()
|
||||
container.set<DatabaseConnection>(database);
|
||||
|
||||
const eventHandler = new EventHandler();
|
||||
|
|
|
|||
|
|
@ -3,12 +3,22 @@ import Sqlite3 from "better-sqlite3";
|
|||
import Database from "better-sqlite3";
|
||||
import {Container} from "../Container/Container";
|
||||
import {Logger} from "log4js";
|
||||
import path from "node:path";
|
||||
import * as fs from "node:fs";
|
||||
|
||||
export class DatabaseConnection {
|
||||
private database: Sqlite3.Database;
|
||||
|
||||
constructor(env: DatabaseEnvironment) {
|
||||
this.database = new Database(env.path, {
|
||||
constructor(private readonly env: DatabaseEnvironment) {
|
||||
}
|
||||
|
||||
public connect() {
|
||||
const directory = path.dirname(this.env.path);
|
||||
fs.mkdirSync(directory, {
|
||||
recursive: true
|
||||
})
|
||||
|
||||
this.database = new Database(this.env.path, {
|
||||
nativeBinding: "node_modules/better-sqlite3/build/Release/better_sqlite3.node",
|
||||
})
|
||||
this.database.pragma('journal_mode = WAL');
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import dotenv from "dotenv";
|
||||
import path from "node:path";
|
||||
import * as fs from "node:fs";
|
||||
|
||||
type DiscordEnvironment = {
|
||||
token: string;
|
||||
guildId: string;
|
||||
clientId: string;
|
||||
}
|
||||
|
||||
|
|
@ -15,7 +15,6 @@ export class Environment {
|
|||
get discord(): DiscordEnvironment {
|
||||
return {
|
||||
token: process.env.DISCORD_API_KEY ?? '',
|
||||
guildId: process.env.DISCORD_GUILD_ID ?? '',
|
||||
clientId: process.env.DISCORD_CLIENT_ID ?? '',
|
||||
}
|
||||
}
|
||||
|
|
@ -27,8 +26,14 @@ export class Environment {
|
|||
}
|
||||
|
||||
public setup() {
|
||||
const dotenvPath = path.resolve(__dirname, "../environment/.env");
|
||||
|
||||
if (!fs.existsSync(dotenvPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
dotenv.config({
|
||||
path: path.resolve(__dirname, "../environment/.env"),
|
||||
path: dotenvPath,
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue