mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 18:59:19 +00:00
Formatted code and clean up
This commit is contained in:
@@ -1,20 +1,13 @@
|
||||
import * as path from "path";
|
||||
import * as dotenv from "dotenv";
|
||||
import * as path from 'path';
|
||||
import * as dotenv from 'dotenv';
|
||||
|
||||
import Logger from "../libs/Logger";
|
||||
import Logger from '../libs/Logger';
|
||||
|
||||
const requiredENV = [
|
||||
'NODE_ENV',
|
||||
'DATABASE_URL',
|
||||
'DISCORD_TOKEN',
|
||||
'PRIVATE_BOT',
|
||||
'OSU_API_KEY'
|
||||
];
|
||||
const requiredENV = ['NODE_ENV', 'DATABASE_URL', 'DISCORD_TOKEN', 'PRIVATE_BOT', 'OSU_API_KEY'];
|
||||
|
||||
class Environment {
|
||||
|
||||
public init(): void {
|
||||
dotenv.config({ path: path.resolve(__dirname, "../../.env") });
|
||||
dotenv.config({ path: path.resolve(__dirname, '../../.env') });
|
||||
|
||||
for (let param of requiredENV) {
|
||||
if (this.isUndefinedOrEmpty(process.env[param]))
|
||||
@@ -22,7 +15,7 @@ class Environment {
|
||||
}
|
||||
|
||||
// NODE_ENV Checks
|
||||
if (this.get().NODE_ENV != "production" && this.get().NODE_ENV != "development")
|
||||
if (this.get().NODE_ENV != 'production' && this.get().NODE_ENV != 'development')
|
||||
throw new Error('.env NODE_ENV must be either "production" or "development"');
|
||||
|
||||
// TODO: Discord token check
|
||||
@@ -31,7 +24,6 @@ class Environment {
|
||||
}
|
||||
|
||||
public get(): any {
|
||||
|
||||
const NODE_ENV = process.env.NODE_ENV;
|
||||
|
||||
const DISCORD_TOKEN = process.env.DISCORD_TOKEN;
|
||||
@@ -40,7 +32,7 @@ class Environment {
|
||||
|
||||
const OSU_API_KEY = process.env.OSU_API_KEY;
|
||||
const YOUTUBE_COOKIE_BASE64 = process.env.YOUTUBE_COOKIE_BASE64;
|
||||
|
||||
|
||||
return {
|
||||
NODE_ENV,
|
||||
|
||||
@@ -54,18 +46,14 @@ class Environment {
|
||||
}
|
||||
|
||||
private isUndefinedOrEmpty(value: String | undefined): boolean {
|
||||
if(typeof value === 'undefined')
|
||||
return true;
|
||||
if (typeof value === 'undefined') return true;
|
||||
|
||||
if(value === undefined)
|
||||
return true;
|
||||
if (value === undefined) return true;
|
||||
|
||||
if(value === '')
|
||||
return true;
|
||||
if (value === '') return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default new Environment();
|
||||
|
||||
Reference in New Issue
Block a user