All checks were successful
Deploy Palico Bot / deploy (push) Successful in 32s
- Deploy workflow: pin node:24-bookworm; install openssh-client only if missing - Auth failure limiter counts only 401s (422/404 no longer lock out clients) - trust proxy configurable (WEB_TRUSTED_PROXIES), never "true" - DM route: loopback connections only, dedicated NOTIFICATIONS_API_KEY, 503 when unset - Jukebox: no polling without a key, stop on 401 - /invitation: posts the temporary invite message after checking the link - Stop tracking storage/library.json; README describes the real deployment Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
2 KiB
JavaScript
64 lines
2 KiB
JavaScript
const requiredVariables = [
|
|
"NODE_ENV",
|
|
"DISCORD_GUILD_ID",
|
|
"SHINUWA_USER_ID",
|
|
"WEB_SERVER_PORT",
|
|
"WEB_API_KEY",
|
|
"DISCORD_APPLICATION_ID",
|
|
"DISCORD_TOKEN",
|
|
"VOICE_CHANNEL_ID",
|
|
"TEXT_CHANNEL_ID",
|
|
"GAME_SERVERS_MESSAGE_ID",
|
|
];
|
|
|
|
const missingVariables = requiredVariables.filter(
|
|
(name) => !process.env[name]?.trim()
|
|
);
|
|
|
|
if (missingVariables.length > 0) {
|
|
throw new Error(
|
|
`Variables d'environnement manquantes : ${missingVariables.join(", ")}`
|
|
);
|
|
}
|
|
|
|
const webServerPort = Number(process.env.WEB_SERVER_PORT);
|
|
|
|
if (
|
|
!Number.isInteger(webServerPort) ||
|
|
webServerPort <= 0 ||
|
|
webServerPort > 65_535
|
|
) {
|
|
throw new Error("WEB_SERVER_PORT doit être compris entre 1 et 65535");
|
|
}
|
|
|
|
// Variables facultatives.
|
|
// WEB_TRUSTED_PROXIES : proxys dont on accepte l'en-tête X-Forwarded-For (syntaxe
|
|
// « trust proxy » d'Express). Ne jamais mettre « true » : le port est joignable sans proxy.
|
|
const webTrustedProxies = process.env.WEB_TRUSTED_PROXIES?.trim() || "loopback";
|
|
// NOTIFICATIONS_API_KEY : clé des applications de confiance (Sokko TCG). Sans elle, la
|
|
// route des messages privés est désactivée.
|
|
const notificationsApiKey = process.env.NOTIFICATIONS_API_KEY?.trim() || null;
|
|
// INVITE_LINK : lien publié par /invitation quand la commande ne reçoit pas de lien.
|
|
const inviteLink = process.env.INVITE_LINK?.trim() || null;
|
|
|
|
if (notificationsApiKey && notificationsApiKey === process.env.WEB_API_KEY) {
|
|
throw new Error("NOTIFICATIONS_API_KEY doit être différente de WEB_API_KEY");
|
|
}
|
|
|
|
const config = Object.freeze({
|
|
environnement: process.env.NODE_ENV,
|
|
discordGuildId: process.env.DISCORD_GUILD_ID,
|
|
shinuwaUserId: process.env.SHINUWA_USER_ID,
|
|
webServerPort,
|
|
webApiKey: process.env.WEB_API_KEY,
|
|
webTrustedProxies,
|
|
notificationsApiKey,
|
|
inviteLink,
|
|
applicationId: process.env.DISCORD_APPLICATION_ID,
|
|
token: process.env.DISCORD_TOKEN,
|
|
voiceChannelId: process.env.VOICE_CHANNEL_ID,
|
|
textChannelId: process.env.TEXT_CHANNEL_ID,
|
|
gameServersMessageId: process.env.GAME_SERVERS_MESSAGE_ID,
|
|
});
|
|
|
|
export { config };
|