mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 03:07:04 +02:00
feat: express responses
This commit is contained in:
1 parent
0f46f333b5
commit
f2ae698438
45 files changed
+153
-93
No files matched your search
@@ -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}');
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function errorWithCause(message: string, cause: string) {
|
||||
return new Error(message, { cause });
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
const isDevBoolean = process.env.NODE_ENV === 'development';
|
||||
|
||||
export default function isDev() {
|
||||
return isDevBoolean;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function isNumber(value: any) {
|
||||
return typeof value === 'number' && !isNaN(value) && isFinite(value);
|
||||
}
|
||||
@@ -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');
|
||||
});
|
||||
Reference in new issue
Block a user