diff --git a/apis/websocket/docs/2_running_and_deploying.md b/apis/websocket/docs/2_running_and_deploying.md index ae57227..08dafc9 100644 --- a/apis/websocket/docs/2_running_and_deploying.md +++ b/apis/websocket/docs/2_running_and_deploying.md @@ -25,8 +25,6 @@ The distribution files will be placed inside the `dist` directory. Inside will i - The default configuration for the API - Compiled source files of the API -You'll need to also copy the `node_modules` directory dereferenced if you want to run the distribution files somewhere else. - ## ✈️ Deploying To deploy the API, you'll need to: @@ -43,7 +41,8 @@ To deploy the API, you'll need to: 3. Replace the default configuration *(optional)* 4. Configure environment variables - As seen in [`.env.example`](../.env.example). You can also optionally use a `.env` file which **Bun will automatically load**. + As seen in [`.env.example`](../.env.example). You can also optionally use a `.env` file which **Bun will automatically load**. + It is recommended to set `NODE_ENV` to `production` when deploying production builds. 5. Finally, you can run the API using these commands diff --git a/bots/discord/.env.example b/bots/discord/.env.example index f1eefc5..8685374 100644 --- a/bots/discord/.env.example +++ b/bots/discord/.env.example @@ -1,2 +1,2 @@ DISCORD_TOKEN="YOUR-TOKEN-HERE" -DATABASE_URL=file:./db.sqlite3 \ No newline at end of file +DATABASE_PATH=./db.sqlite3 \ No newline at end of file diff --git a/bots/discord/docs/1_configuration.md b/bots/discord/docs/1_configuration.md index 09106d0..0a6a634 100644 --- a/bots/discord/docs/1_configuration.md +++ b/bots/discord/docs/1_configuration.md @@ -61,10 +61,10 @@ You can set environment variables in your shell or use a `.env` file which **Bun The Discord bot token. -#### `DATABASE_URL` +#### `DATABASE_PATH` -The database URL, since we're using SQLite, we'll be using the `file` protocol. -Example values are: `file:./revanced.db`, `file:./db.sqlite`, `file:./discord_bot.sqlite` +The database path. +Example values are: `./revanced.db`, `db.sqlite3`, `../some/path/discord_bot.sqlite` ## ⏭️ What's next diff --git a/bots/discord/drizzle.config.ts b/bots/discord/drizzle.config.ts index f50247d..3c1920e 100644 --- a/bots/discord/drizzle.config.ts +++ b/bots/discord/drizzle.config.ts @@ -4,6 +4,6 @@ export default defineConfig({ dialect: 'sqlite', schema: './src/database/schemas.ts', dbCredentials: { - url: process.env['DATABASE_URL'], + url: `file:./${process.env['DATABASE_PATH']}`, }, }) diff --git a/bots/discord/package.json b/bots/discord/package.json index 780b8a9..0fc0978 100644 --- a/bots/discord/package.json +++ b/bots/discord/package.json @@ -10,7 +10,7 @@ "start": "bun run scripts/generate-indexes.ts && bun run src/index.ts", "dev": "bun run scripts/generate-indexes.ts && bun --watch src/index.ts", "build:config": "bun build config.ts --outdir=dist", - "build": "bun prepare && bun build:config && bun build src/index.ts -e ./config.js --target=bun --outdir=dist/src && DATABASE_URL=dist/db.sqlite3 drizzle-kit push", + "build": "bun prepare && bun build:config && bun build src/index.ts -e ./config.js --target=bun --outdir=dist/src && DATABASE_PATH=dist/db.sqlite3 drizzle-kit push", "watch": "bun dev", "prepare": "bun run scripts/generate-indexes.ts" }, diff --git a/bots/discord/src/commands/index.ts b/bots/discord/src/commands/index.ts index 3bd4ce2..58723ee 100644 --- a/bots/discord/src/commands/index.ts +++ b/bots/discord/src/commands/index.ts @@ -1,16 +1,16 @@ // AUTO-GENERATED BY A SCRIPT, DON'T TOUCH import './index' -import './fun/reply' import './fun/coinflip' -import './development/eval' -import './development/stop' -import './development/exception-test' +import './fun/reply' +import './moderation/unban' import './moderation/purge' import './moderation/cure' -import './moderation/role-preset' -import './moderation/mute' import './moderation/unmute' -import './moderation/unban' -import './moderation/slowmode' +import './moderation/mute' import './moderation/ban' +import './moderation/role-preset' +import './moderation/slowmode' +import './development/stop' +import './development/exception-test' +import './development/eval' diff --git a/bots/discord/src/context.ts b/bots/discord/src/context.ts index 2908e4f..a4806ee 100644 --- a/bots/discord/src/context.ts +++ b/bots/discord/src/context.ts @@ -29,7 +29,7 @@ export const api = { disconnectCount: 0, } -const db = new Database(process.env['DATABASE_URL']) +const db = new Database(process.env['DATABASE_PATH']) export const database = drizzle(db, { schema: schemas, @@ -61,5 +61,8 @@ export const discord = { ], }, }), - commands: Object.fromEntries(Object.values(commands).map((cmd) => [cmd.data.name, cmd])) as Record, + commands: Object.fromEntries(Object.values(commands).map(cmd => [cmd.data.name, cmd])) as Record< + string, + Command + >, } as const diff --git a/bots/discord/src/events/api/index.ts b/bots/discord/src/events/api/index.ts index 80e2524..0c774fe 100644 --- a/bots/discord/src/events/api/index.ts +++ b/bots/discord/src/events/api/index.ts @@ -1,5 +1,5 @@ // AUTO-GENERATED BY A SCRIPT, DON'T TOUCH import './ready' -import './disconnect' import './index' +import './disconnect' diff --git a/bots/discord/src/events/discord/index.ts b/bots/discord/src/events/discord/index.ts index 4f305b0..9e3e80f 100644 --- a/bots/discord/src/events/discord/index.ts +++ b/bots/discord/src/events/discord/index.ts @@ -4,7 +4,7 @@ import './ready' import './cureRequired' import './index' import './messageCreate/messageScanRequired' -import './messageReactionAdd/correctResponse' -import './interactionCreate/chatCommand' -import './interactionCreate/correctResponse' import './guildMemberAdd/applyRolePresets' +import './interactionCreate/correctResponse' +import './interactionCreate/chatCommand' +import './messageReactionAdd/correctResponse' diff --git a/bots/discord/src/index.ts b/bots/discord/src/index.ts index 1588c24..f7e77fd 100644 --- a/bots/discord/src/index.ts +++ b/bots/discord/src/index.ts @@ -4,7 +4,7 @@ import { getMissingEnvironmentVariables } from '@revanced/bot-shared' import './events/register' // Check if token exists -const missingEnvs = getMissingEnvironmentVariables(['DISCORD_TOKEN', 'DATABASE_URL']) +const missingEnvs = getMissingEnvironmentVariables(['DISCORD_TOKEN', 'DATABASE_PATH']) if (missingEnvs.length) { for (const env of missingEnvs) logger.fatal(`${env} is not defined in environment variables`) process.exit(1) diff --git a/bun.lockb b/bun.lockb old mode 100644 new mode 100755 index b4f32d2..64e6cbb Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index db9b265..566d1e8 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ "author": "Palm (https://palmdevs.me)", "workspaces": ["packages/*", "apis/*", "bots/*"], "scripts": { - "build": "turbo run build", - "build:packages": "turbo run build --filter=\"./packages/*\"", + "build:all": "turbo run build", + "build:packages": "turbo build --filter=\"./packages/*\"", "watch": "turbo run watch", "flint": "biome check --write .", "flint:check": "biome check .", @@ -27,7 +27,7 @@ "Palm (https://palmdevs.me)", "ReVanced (https://revanced.app)" ], - "packageManager": "pnpm@9.4.0", + "packageManager": "bun@1.1.18", "devDependencies": { "@biomejs/biome": "^1.8.2", "@commitlint/cli": "^19.3.0",