Files
Yumi/src/providers/App.ts
T

72 lines
1.9 KiB
TypeScript
Raw Normal View History

2021-09-14 09:56:11 -07:00
import Environment from './Environment';
2022-06-06 14:59:53 +07:00
import Configuration from './Configuration';
2021-09-14 09:56:11 -07:00
import Prisma from './Prisma';
import Discord from './Discord';
2021-09-19 08:40:09 -07:00
import osu from './osuAPI';
2023-04-23 13:13:20 +07:00
import VRChat from './VRChatAPI';
2022-08-26 06:36:45 +07:00
import Express from './Express';
2021-09-14 09:56:11 -07:00
2022-06-06 14:59:53 +07:00
import Logger from '../libs/Logger';
2022-06-06 20:11:54 +07:00
import Locale from './Locale';
2021-09-14 09:56:11 -07:00
class App {
2023-04-23 19:53:05 +07:00
public readonly versionNumber = `0.12`;
2022-06-06 14:59:53 +07:00
public readonly version = `${this.versionNumber}${
Environment.get().NODE_ENV === 'development' ? ' / Development Build' : ''
}`;
2021-09-14 09:56:11 -07:00
2022-01-27 18:00:47 +07:00
public loadConfig(): void {
Logger.log('info', 'Loading configuration');
Configuration.init();
}
2021-09-14 09:56:11 -07:00
public loadENV(): void {
Logger.log('info', 'Loading environment');
Environment.init();
}
public loadPrisma(): void {
Logger.log('info', 'Loading Prisma');
Prisma.init();
}
public loadDiscord(): void {
Logger.log('info', 'Loading Discord Client');
Discord.init();
}
2021-09-19 04:03:13 -07:00
2022-06-06 20:11:54 +07:00
public loadLocale(): void {
Logger.log('info', 'Loading Locale');
Locale.init();
}
2023-04-23 13:13:20 +07:00
public loadVRChat(): void {
Logger.log('info', 'Loading VRChat');
VRChat.init();
}
2021-09-19 04:03:13 -07:00
public load_osu(): void {
if (!Environment.get().OSU_API_KEY) {
Logger.log('warn', 'OSU_API_KEY is not defined in .env, osu! features will be disabled');
return;
}
2021-09-19 04:03:13 -07:00
Logger.log('info', 'Loading osu! Client');
osu.init();
}
2022-08-26 06:36:45 +07:00
public loadExpress(): void {
2022-11-13 19:01:29 +09:00
if (!Environment.get().WEB_HOST || !Environment.get().WEB_PORT) {
Logger.log('warn', 'WEB_HOST or WEB_PORT is not defined in .env, not starting web server');
return;
}
2022-08-26 06:36:45 +07:00
Logger.log('info', 'Loading Express');
Express.init();
}
public endExpress(): void {
Logger.log('info', 'Ending Express');
Express.end();
}
2021-09-14 09:56:11 -07:00
}
2022-06-06 14:59:53 +07:00
export default new App();