diff --git a/fxmanifest.lua b/fxmanifest.lua index ebf219b..fb2dfd5 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -14,6 +14,7 @@ server_script { ui_page 'resources/html/index.html' files { + 'config.json', 'resources/html/index.html', 'resources/html/*.js', 'resources/html/*.map', diff --git a/resources/client/cl_main.ts b/resources/client/cl_main.ts index 0291c65..ab10c9a 100644 --- a/resources/client/cl_main.ts +++ b/resources/client/cl_main.ts @@ -1,4 +1,3 @@ -import config from '../utils/config'; import { sendMessage } from '../utils/messages'; import { PhoneEvents } from '../../typings/phone'; import { TwitterEvents } from '../../typings/twitter'; @@ -11,6 +10,7 @@ import { BankEvents } from '../../typings/bank'; import { PhotoEvents } from '../../typings/photo'; import { CallEvents } from '../../typings/call'; import { MatchEvents } from '../../typings/match'; +import { config } from './client'; let isPhoneOpen = false; let isPlayerReady = false; diff --git a/resources/client/client.ts b/resources/client/client.ts index c7dbed6..7b192e3 100644 --- a/resources/client/client.ts +++ b/resources/client/client.ts @@ -1,4 +1,10 @@ import ClientUtils from './cl_utils'; +import { IServerConfig } from '../../typings/config'; + +// Setup and export the config for the resource +export const config: IServerConfig = JSON.parse( + LoadResourceFile(GetCurrentResourceName(), 'config.json'), +); import './cl_main'; import './cl_twitter'; diff --git a/resources/server/functions.ts b/resources/server/functions.ts index 399d301..b406ebc 100644 --- a/resources/server/functions.ts +++ b/resources/server/functions.ts @@ -1,5 +1,5 @@ import { pool } from './db'; -import config from '../utils/config'; +import { config } from './server'; import { mainLogger } from './sv_logger'; import { Player, Players, PlayersByIdentifier } from './players/sv_players'; diff --git a/resources/server/server.ts b/resources/server/server.ts index fa984a5..f53a096 100644 --- a/resources/server/server.ts +++ b/resources/server/server.ts @@ -1,4 +1,10 @@ import { Server } from 'esx.js'; +import { IServerConfig } from '../../typings/config'; + +// Setup and export config loaded at runtime +export const config: IServerConfig = JSON.parse( + LoadResourceFile(GetCurrentResourceName(), 'config.json'), +); import './db'; import './sv_twitter'; diff --git a/resources/server/sv_logger.ts b/resources/server/sv_logger.ts index 38cc67d..cdcbe85 100644 --- a/resources/server/sv_logger.ts +++ b/resources/server/sv_logger.ts @@ -1,5 +1,5 @@ import winston from 'winston'; -import config from '../utils/config'; +import { config } from './server'; import path from 'path'; // Needed to manually apply a color to componenent property of log @@ -13,8 +13,7 @@ const formatLogs = (log: winston.Logform.TransformableInfo): string => { return `${log.label} [${log.level}]: ${log.message}`; }; -const findLogPath = () => - `${path.join(GetResourcePath(GetCurrentResourceName()), 'sv_npwd.log')}`; +const findLogPath = () => `${path.join(GetResourcePath(GetCurrentResourceName()), 'sv_npwd.log')}`; // Initiate the main logger for NPWD export const mainLogger = winston.createLogger({ diff --git a/resources/server/sv_match.ts b/resources/server/sv_match.ts index 41c2137..96b57a2 100644 --- a/resources/server/sv_match.ts +++ b/resources/server/sv_match.ts @@ -2,7 +2,7 @@ import { ResultSetHeader, RowDataPacket } from 'mysql2'; import { pool } from './db'; import { getIdentifier, getSource } from './functions'; -import config from '../utils/config'; +import { config } from './server'; import { Like, Match, Profile, MatchEvents, NewProfile } from '../../typings/match'; import { mainLogger } from './sv_logger'; import { generateProfileName } from './players/sv_players'; diff --git a/resources/server/sv_twitter.ts b/resources/server/sv_twitter.ts index 2d78b75..4830c02 100644 --- a/resources/server/sv_twitter.ts +++ b/resources/server/sv_twitter.ts @@ -2,7 +2,7 @@ import { ResultSetHeader } from 'mysql2'; import { pool } from './db'; import { getIdentifier, getSource } from './functions'; import { NewTweet, Tweet, Profile } from '../../typings/twitter'; -import config from '../utils/config'; +import { config } from './server'; import { reportTweetToDiscord } from './discord'; import { mainLogger } from './sv_logger'; import { generateProfileName, getDefaultProfileNames } from './players/sv_players'; diff --git a/resources/utils/config.ts b/resources/utils/config.ts deleted file mode 100644 index e62e78f..0000000 --- a/resources/utils/config.ts +++ /dev/null @@ -1,4 +0,0 @@ -import config from '../../config.json'; -import { IServerConfig } from '../../typings/config'; - -export default config;