Foundry and discord bot
All checks were successful
Build and Deploy Nuxt / build (push) Successful in 1m51s

This commit is contained in:
2026-10-11 22:26:29 +02:00
parent a2b512699a
commit 1402045001
65 changed files with 5962 additions and 144 deletions

41
discord-bot/src/config.js Normal file
View File

@@ -0,0 +1,41 @@
const dotenv = require('dotenv');
dotenv.config();
function required(name) {
const value = process.env[name]?.trim();
if (!value) throw new Error(`Missing required environment variable: ${name}`);
return value;
}
function apiUrl(value, name) {
const url = value.trim().replace(/\/+$/, '');
if (!/^https?:\/\//i.test(url)) throw new Error(`${name} must start with http:// or https://`);
return url;
}
// Frontend address, not the API: the sign-in page people open from Discord lives there.
function frontendUrl(value, name) {
const url = apiUrl(value, name).replace(/\/api$/i, '');
if (!url) throw new Error(`${name} must be the Dragonroll frontend address, like http://localhost:3000`);
return url;
}
function getConfig() {
const apiUrlValue = process.env.DRAGONROLL_API_URL || 'http://localhost:5000/api';
const apiBaseUrl = apiUrl(apiUrlValue, 'DRAGONROLL_API_URL');
const frontendBaseUrl = frontendUrl(
process.env.DRAGONROLL_FRONTEND_URL || process.env.DRAGONROLL_PUBLIC_API_URL || 'http://localhost:3000',
'DRAGONROLL_FRONTEND_URL'
);
return {
apiBaseUrl,
frontendBaseUrl,
discordBotSecret: process.env.DRAGONROLL_DISCORD_BOT_SECRET?.trim() || '',
discordToken: required('DISCORD_TOKEN'),
discordClientId: required('DISCORD_CLIENT_ID')
};
}
module.exports = { getConfig };