feat: express responses

This commit is contained in:
TresAbhi committed 2023-06-27 01:43:30 +00:00
1 parent 0f46f333b5
commit f2ae698438
45 files changed
+153 -93

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
export const DISCORD_TOKEN = process.env.DISCORD_TOKEN!;
export const WARGAMING_APPLICATION_ID = process.env.WARGAMING_APPLICATION_ID!;
if (!DISCORD_TOKEN) {
throw new Error('No Discord token provided');
}
if (!WARGAMING_APPLICATION_ID) {
throw new Error('No Wargaming application id provided}');
}
+3
View File
@@ -0,0 +1,3 @@
export default function errorWithCause(message: string, cause: string) {
return new Error(message, { cause });
}
+6
View File
@@ -0,0 +1,6 @@
import discord from '../../../discord.json' assert { type: 'json' };
import isDev from './isDev.js';
export default function getClientId() {
return isDev() ? discord.client_id_dev : discord.client_id;
}
+5
View File
@@ -0,0 +1,5 @@
const isDevBoolean = process.env.NODE_ENV === 'development';
export default function isDev() {
return isDevBoolean;
}
+3
View File
@@ -0,0 +1,3 @@
export default function isNumber(value: any) {
return typeof value === 'number' && !isNaN(value) && isFinite(value);
}
+20
View File
@@ -0,0 +1,20 @@
export interface PSAData {
title: string;
description: string;
}
export interface PSA {
data: PSAData | null;
}
export const psa: PSA = { data: null };
console.log('Caching PSA...');
fetch(
'https://gist.githubusercontent.com/tresabhi/ed4b136f08856e615212e573aabe1968/raw',
)
.then((response) => response.json())
.then((data) => {
psa.data = data as PSAData;
console.log('PSA cached');
});