diff --git a/backend/src/configController.ts b/backend/src/configController.ts index e0cf2b0..cb42f92 100644 --- a/backend/src/configController.ts +++ b/backend/src/configController.ts @@ -1,6 +1,6 @@ import { Controller, Get, NoSecurity, Route, Security } from '@tsoa/runtime'; import { TMT_LOG_ADDRESS } from '.'; -import { IConfig } from '../../common/types/config'; +import { IConfig } from '../../common'; @Route('/api/config') @Security('bearer_token') diff --git a/backend/src/debugController.ts b/backend/src/debugController.ts index db80bdf..6a04bd1 100644 --- a/backend/src/debugController.ts +++ b/backend/src/debugController.ts @@ -1,8 +1,9 @@ import { Controller, Get, Route, Security } from '@tsoa/runtime'; -import * as WebSocket from './webSocket'; import { PORT, TMT_LOG_ADDRESS, VERSION } from '.'; +import { IDebugResponse } from '../../common'; import { Settings } from './settings'; import { STORAGE_FOLDER } from './storage'; +import * as WebSocket from './webSocket'; @Route('/api/debug') @Security('bearer_token') @@ -16,7 +17,7 @@ export class DebugController extends Controller { } @Get('/') - async getInfos() { + async getInfos(): Promise { return { tmtVersion: VERSION, tmtStorageFolder: STORAGE_FOLDER, diff --git a/backend/src/presets.ts b/backend/src/presets.ts index d471788..82cc490 100644 --- a/backend/src/presets.ts +++ b/backend/src/presets.ts @@ -1,5 +1,5 @@ import { generate as shortUuid } from 'short-uuid'; -import { IPreset, IPresetCreateDto, IPresetUpdateDto } from '../../common/types/preset'; +import { IPreset, IPresetCreateDto, IPresetUpdateDto } from '../../common'; import * as Storage from './storage'; const FILE_NAME = 'presets.json'; diff --git a/backend/src/presetsController.ts b/backend/src/presetsController.ts index c605d2e..fb952de 100644 --- a/backend/src/presetsController.ts +++ b/backend/src/presetsController.ts @@ -10,7 +10,7 @@ import { Security, SuccessResponse, } from '@tsoa/runtime'; -import { IPreset, IPresetCreateDto } from '../../common/types/preset'; +import { IPreset, IPresetCreateDto } from '../../common'; import { ExpressRequest, IAuthResponse } from './auth'; import * as Presets from './presets'; diff --git a/backend/src/routes.ts b/backend/src/routes.ts index d91a693..4bd4713 100644 --- a/backend/src/routes.ts +++ b/backend/src/routes.ts @@ -1123,6 +1123,31 @@ const models: TsoaRoute.Models = { additionalProperties: false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + IDebugResponse: { + dataType: 'refObject', + properties: { + tmtVersion: { + dataType: 'union', + subSchemas: [{ dataType: 'string' }, { dataType: 'enum', enums: [null] }], + required: true, + }, + tmtStorageFolder: { dataType: 'string', required: true }, + tmtPort: { + dataType: 'union', + subSchemas: [{ dataType: 'string' }, { dataType: 'double' }], + required: true, + }, + tmtLogAddress: { + dataType: 'union', + subSchemas: [{ dataType: 'string' }, { dataType: 'enum', enums: [null] }], + required: true, + }, + tmtSayPrefix: { dataType: 'string', required: true }, + webSockets: { dataType: 'array', array: { dataType: 'any' }, required: true }, + }, + additionalProperties: false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa IConfig: { dataType: 'refObject', properties: { diff --git a/backend/swagger.json b/backend/swagger.json index 58114ac..1de512e 100644 --- a/backend/swagger.json +++ b/backend/swagger.json @@ -2187,6 +2187,49 @@ "type": "object", "additionalProperties": false }, + "IDebugResponse": { + "properties": { + "tmtVersion": { + "type": "string", + "nullable": true + }, + "tmtStorageFolder": { + "type": "string" + }, + "tmtPort": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "number", + "format": "double" + } + ] + }, + "tmtLogAddress": { + "type": "string", + "nullable": true + }, + "tmtSayPrefix": { + "type": "string" + }, + "webSockets": { + "items": {}, + "type": "array" + } + }, + "required": [ + "tmtVersion", + "tmtStorageFolder", + "tmtPort", + "tmtLogAddress", + "tmtSayPrefix", + "webSockets" + ], + "type": "object", + "additionalProperties": false + }, "IConfig": { "properties": { "tmtLogAddress": { @@ -2998,44 +3041,7 @@ "content": { "application/json": { "schema": { - "properties": { - "webSockets": { - "items": {}, - "type": "array" - }, - "tmtSayPrefix": { - "type": "string" - }, - "tmtLogAddress": { - "type": "string" - }, - "tmtPort": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number", - "format": "double" - } - ] - }, - "tmtStorageFolder": { - "type": "string" - }, - "tmtVersion": { - "type": "string" - } - }, - "required": [ - "webSockets", - "tmtSayPrefix", - "tmtLogAddress", - "tmtPort", - "tmtStorageFolder", - "tmtVersion" - ], - "type": "object" + "$ref": "#/components/schemas/IDebugResponse" } } } diff --git a/common/types/debug.ts b/common/types/debug.ts new file mode 100644 index 0000000..604cc09 --- /dev/null +++ b/common/types/debug.ts @@ -0,0 +1,8 @@ +export interface IDebugResponse { + tmtVersion: string | null; + tmtStorageFolder: string; + tmtPort: string | number; + tmtLogAddress: string | null; + tmtSayPrefix: string; + webSockets: any[]; +} diff --git a/common/types/index.ts b/common/types/index.ts index 9d29df9..ee427de 100644 --- a/common/types/index.ts +++ b/common/types/index.ts @@ -1,3 +1,5 @@ +export * from './config'; +export * from './debug'; export * from './election'; export * from './electionStep'; export * from './events'; @@ -6,6 +8,7 @@ export * from './log'; export * from './match'; export * from './matchMap'; export * from './player'; +export * from './preset'; export * from './stuff'; export * from './team'; export * from './webSocket'; diff --git a/frontend/src/components/CreateUpdateMatch.tsx b/frontend/src/components/CreateUpdateMatch.tsx index 0b85ba2..22d8216 100644 --- a/frontend/src/components/CreateUpdateMatch.tsx +++ b/frontend/src/components/CreateUpdateMatch.tsx @@ -2,17 +2,18 @@ import autoAnimate from '@formkit/auto-animate'; import { Component, For, Match, Show, Switch, createEffect, createSignal, onMount } from 'solid-js'; import { createStore } from 'solid-js/store'; import { + IConfig, IElectionStep, IMatchCreateDto, IMatchResponse, IMatchUpdateDto, + IPreset, + IPresetCreateDto, TMatchEndAction, TMatchMode, TTeamAB, getOtherTeamAB, } from '../../../common'; -import { IConfig } from '../../../common/types/config'; -import { IPreset, IPresetCreateDto } from '../../../common/types/preset'; import { SvgAdd, SvgDelete, diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx index ad384a6..7bceae2 100644 --- a/frontend/src/index.tsx +++ b/frontend/src/index.tsx @@ -3,6 +3,7 @@ import { Route, Router } from '@solidjs/router'; import { render } from 'solid-js/web'; import { App } from './App'; import { CreatePage } from './pages/create'; +import { DebugPage } from './pages/debug'; import { GameServersPage } from './pages/gameServers'; import { LoginPage } from './pages/login'; import { LogoutPage } from './pages/logout'; @@ -23,6 +24,7 @@ render( + ), diff --git a/frontend/src/pages/debug.tsx b/frontend/src/pages/debug.tsx new file mode 100644 index 0000000..c4b0bbf --- /dev/null +++ b/frontend/src/pages/debug.tsx @@ -0,0 +1,20 @@ +import { Component, createEffect, createSignal } from 'solid-js'; +import { Card } from '../components/Card'; +import { createFetcher } from '../utils/fetcher'; +import { IDebugResponse } from '../../../common'; + +export const DebugPage: Component = () => { + const fetcher = createFetcher(); + const [debugData, setDebugData] = createSignal(); + createEffect(() => { + fetcher('GET', '/api/debug').then((debug) => { + setDebugData(debug); + }); + }); + + return ( + +
{JSON.stringify(debugData(), null, 4)}
+
+ ); +};