Skip to content

Commit

Permalink
wip: small random + few more migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Oct 18, 2023
1 parent 8150ddd commit 7731ecb
Show file tree
Hide file tree
Showing 14 changed files with 2,233 additions and 10,395 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
es2017: true,
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 2021,
},
};
4 changes: 0 additions & 4 deletions core/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ module.exports = {
VerifyPasswordHash: 'readonly',
},
extends: [],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2021,
},
ignorePatterns: [
'*.ignore.*',
],
Expand Down
2 changes: 1 addition & 1 deletion core/components/DiscordBot/discordHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const ensurePermission = async (interaction: CommandInteraction, txAdmin:


/**
* Equivalent to ctx.utils.logAction()
* Equivalent to ctx.admin.logAction()
*/
export const logDiscordAdminAction = async (txAdmin: TxAdmin, adminName: string, message: string) => {
txAdmin.logger.admin.write(adminName, message);
Expand Down
4 changes: 2 additions & 2 deletions core/components/DynamicAds.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class DynamicAds {

//Set default ads
let loginAds, mainAds;
if(convars.isZapHosting){
if (convars.isZapHosting) {
loginAds = defaultAds.loginZap;
mainAds = defaultAds.mainZap;
} else {
Expand Down Expand Up @@ -56,7 +56,7 @@ export default class DynamicAds {
try {
const res = await got(indexURL).json();
let loginAds, mainAds;
if(convars.isZapHosting){
if (convars.isZapHosting) {
loginAds = res.loginZap;
mainAds = res.mainZap;
} else {
Expand Down
6 changes: 3 additions & 3 deletions core/components/FxRunner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,11 @@ export default class FXRunner {
//================================================================
/**
* Handles a live console command input
* @param {object} session
* @param {import('../WebServer/authLogic').AuthedAdminType} admin
* @param {string} command
*/
liveConsoleCmdHandler(session, command) {
globals.logger.admin.write(session.auth.username, command, 'command');
liveConsoleCmdHandler(admin, command) {
admin.logCommand(command, 'command');
globals.fxRunner.srvCmd(command);
}

Expand Down
11 changes: 7 additions & 4 deletions core/components/Translator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Polyglot from 'node-polyglot';
import { txEnv } from '@core/globalData';
import localeMap from '@shared/localeMap';
import consoleFactory from '@extras/console';
import TxAdmin from '@core/txAdmin';
const console = consoleFactory(modulename);


Expand All @@ -14,13 +15,15 @@ const console = consoleFactory(modulename);
* For the future, its probably a good idea to upgrade to i18next
*/
export default class Translator {
readonly #txAdmin: TxAdmin;
language: string;
canonical: string = 'en-GB';
readonly customLocalePath: string;
#polyglot: Polyglot | null = null;

constructor() {
this.language = globals.config.language;
constructor(txAdmin: TxAdmin) {
this.#txAdmin = txAdmin;
this.language = txAdmin.globalConfig.language;
this.customLocalePath = path.join(txEnv.dataPath, 'locale.json');

//Load language
Expand Down Expand Up @@ -61,12 +64,12 @@ export default class Translator {
*/
refreshConfig() {
//Change config and restart polyglot
this.language = globals.config.language;
this.language = this.#txAdmin.globalConfig.language;
this.setupTranslator(false);

//Rebuild Monitor's schedule with new text and refreshes fxserver convars
try {
globals.fxRunner.resetConvars();
this.#txAdmin.fxRunner.resetConvars();
} catch (error) {
console.verbose.dir(error);
}
Expand Down
2 changes: 1 addition & 1 deletion core/components/WebServer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default class WebServer {
public luaComToken: string;
//setupKoa
private app: Koa;
private koaSessionMemoryStore: typeof KoaSessionMemoryStoreClass;
public koaSessionMemoryStore: typeof KoaSessionMemoryStoreClass;
private sessionInstance: typeof KoaSession;
private koaCallback: (req: any, res: any) => Promise<void>;
//setupWebSocket
Expand Down
4 changes: 2 additions & 2 deletions core/extras/banner.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const console = consoleFactory();

const getIPs = async () => {
const reqOptions = {
timeout: { request: 2500 }
timeout: { request: 2500 },
};
const allOps = await Promise.allSettled([
// op.value.ip
got('https://ip.seeip.org/json', reqOptions).json(),
// got('https://ip.seeip.org/json', reqOptions).json(), //expired cert?
got('https://api.ipify.org/?format=json', reqOptions).json(),
got('https://api.myip.com', reqOptions).json(),

Expand Down
8 changes: 6 additions & 2 deletions docs/dev_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ Processo:
- [x] testar rotas websocket
- [x] corrigir rotas nui iframe
- [x] deal with the nui auth rate limiting (no more middleware)
- [ ] pesquisar por `ctx.session.auth`
- [ ] aplicar novo tipo e trocar todos os ctx.session e ctx.utils.xxxxx de todas as rotas
- [x] pesquisar por `ctx.session.auth`
- [x] aplicar novo tipo e trocar todos os ctx.session e ctx.utils.xxxxx de todas as rotas
- [x] remove all `globals.` in the webroutes folder from typescript files
- [x] test and commit all changed files
- [ ] check `playerDatabase.registerAction` expiration type error
- [ ] translation fix the `The player was xxxxx` lines in all files
- [ ] renomear csrfToken e forumUsername pra snake case, mas no AuthedAdmin pode ficar tudo como camel
- sim, colocar o csrfToken pra dentro do admin, e tb editar o preAuth
- [ ] corrigir comportamento dos profile pictures
Expand Down
8 changes: 4 additions & 4 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ npm run dev
```sh
cd nui

#To run Vite on browser dev mode:
npm run dev:browser

#To run Vite on game dev mode:
npm run dev:game
npm run dev

#To run Vite on browser dev mode:
npm run browser
```
Keep in mind that for every change you will need to restart the `monitor` resource, and unless you started the server with `+setr txAdmin-debugMode true` txAdmin will detect that as a crash and restart your server.
Also, when running in game mode, it takes between 10 and 30 seconds for the vite builder to finish for you to be able to restart the `monitor` resource ingame.
Expand Down
4 changes: 2 additions & 2 deletions nui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"main": "index.js",
"scripts": {
"build": "vite build --mode production",
"dev:browser": "vite dev --port 40121 --strictPort --mode devNuiBrowser",
"dev:game": "vite build --watch --mode development",
"dev": "vite build --watch --mode development",
"browser": "vite dev --port 40121 --strictPort --mode devNuiBrowser",
"typecheck": "tsc -p tsconfig.json --noEmit"
},
"keywords": [],
Expand Down
Loading

0 comments on commit 7731ecb

Please sign in to comment.