1.1.0 #29
@@ -3,9 +3,12 @@
|
||||
"module": "index.ts",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"devDependencies": {},
|
||||
"devDependencies": {
|
||||
"@blade-and-brawn/api": "workspace:*"
|
||||
},
|
||||
"peerDependencies": {},
|
||||
"dependencies": {
|
||||
"@elysia/eden": "^1.4.10",
|
||||
"discord.js": "^14.27.0"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Client, Events, GatewayIntentBits } from 'discord.js';
|
||||
import { CommandService } from './services/cmd/service';
|
||||
|
||||
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
|
||||
const client = new Client({
|
||||
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
|
||||
});
|
||||
|
||||
// SERVICES
|
||||
// -----------------------
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import cluster from "node:cluster";
|
||||
import { pino } from "pino";
|
||||
import { treaty } from '@elysia/eden';
|
||||
import { type API } from "@blade-and-brawn/api";
|
||||
|
||||
export const log = pino({
|
||||
level: Bun.env.LOG_LEVEL ?? "info",
|
||||
transport: Bun.env.NODE_ENV != "production"
|
||||
? { target: "pino-pretty" }
|
||||
: undefined,
|
||||
});
|
||||
|
||||
export const env = {
|
||||
PUBLIC_API_URL: requireEnv("PUBLIC_API_URL"),
|
||||
BOT_TOKEN: requireEnv("BOT_TOKEN"),
|
||||
};
|
||||
|
||||
export const api = treaty<API>(env.PUBLIC_API_URL ?? "");
|
||||
|
||||
function requireEnv(key: string): string {
|
||||
const val = Bun.env[key];
|
||||
if (!val) {
|
||||
if (cluster.worker?.id === 1)
|
||||
log.error({ name: key }, "Missing required environment variable");
|
||||
throw new Error(`Missing required environment variable: ${key}`)
|
||||
};
|
||||
return val;
|
||||
}
|
||||
|
||||
function optionEnv(key: string, fallback: string = ""): string {
|
||||
const val = Bun.env[key];
|
||||
if (!val) {
|
||||
if (cluster.worker?.id === 1)
|
||||
log.warn({ name: key }, `Missing optional environmental variable, falling back to "${fallback}"`)
|
||||
return fallback
|
||||
};
|
||||
return val;
|
||||
}
|
||||
@@ -37,10 +37,11 @@
|
||||
"apps/bot": {
|
||||
"name": "@blade-and-brawn/bot",
|
||||
"dependencies": {
|
||||
"@elysia/eden": "^1.4.10",
|
||||
"discord.js": "^14.27.0",
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "^1.3.14",
|
||||
"@blade-and-brawn/api": "workspace:*",
|
||||
},
|
||||
},
|
||||
"apps/portal": {
|
||||
@@ -59,7 +60,6 @@
|
||||
"@blade-and-brawn/api": "workspace:*",
|
||||
"@sveltejs/kit": "^2.70.2",
|
||||
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
||||
"@types/bun": "^1.3.14",
|
||||
"elysia": "^1.4.29",
|
||||
"svelte": "^5.56.9",
|
||||
"svelte-adapter-bun": "^1.0.1",
|
||||
|
||||
Reference in New Issue
Block a user