Skip to content

Commit 2cbe64c

Browse files
committed
[ADD] FiveM's schema for request information on server (in progress)
1 parent 101937b commit 2cbe64c

File tree

2 files changed

+99
-10
lines changed

2 files changed

+99
-10
lines changed

src/fivem/fivem.controller.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ApiOkResponse, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagg
55
import { Cache } from 'cache-manager';
66
import ServerTrackedDto from 'src/dto/serverTrackedDto';
77
import ServerCfxDto from 'src/dto/serverCfxDto';
8-
import { fivemPlayersResponse, fivemResponse } from './fivem.schema';
8+
import { fivemCfxResponse, fivemPlayersResponse, fivemResponse } from './fivem.schema';
99

1010
/*
1111
CODE CacheKey
@@ -47,15 +47,11 @@ export class FivemController {
4747
@Get('/cfx/:code')
4848
@ApiOperation({
4949
summary: "Track a FiveM Server by his cfx code",
50-
description: "Return a JSON response",
50+
description: "Return a JSON response with information about the server from FiveM's API",
5151
})
52-
@ApiResponse({
53-
status: 200,
54-
schema: {
55-
example: {
56-
message: "Todo"
57-
}
58-
}
52+
@ApiOkResponse({
53+
description: 'Server information',
54+
schema: fivemCfxResponse
5955
})
6056
async trackServerByCfx(@Param() code: ServerCfxDto): Promise<any> {
6157
const cache: any = await this.cacheManager.get(`FMCFX:${code.code}`);

src/fivem/fivem.schema.ts

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,100 @@ const fivemPlayersResponse: SchemaObject & Partial<ReferenceObject> = {
108108
}
109109
};
110110

111+
const fivemCfxResponse: SchemaObject & Partial<ReferenceObject> = {
112+
type: 'object',
113+
properties: {
114+
cfx: { type: 'string', description: "Server's CFX code" },
115+
online: { type: 'boolean', description: "Server's status. If the bool is true, the server is online" },
116+
EndPoint: { type: 'string', description: "Server's CFX code used as an Endpoint" },
117+
Data: { type: 'object', description: "Server's Data" },
118+
cacheTime: { type: 'number', description: "UNIX timestamp when the response was cached" },
119+
cacheExpire: { type: 'number', description: "UNIX timestamp when the response will be remove from cache. Around 5 minutes." }
120+
},
121+
required: [
122+
"cfx",
123+
"online",
124+
"EndPoint",
125+
"Data",
126+
"cacheTime",
127+
"cacheExpire"
128+
],
129+
example: {
130+
"cfx": "45yo89",
131+
"online": true,
132+
"EndPoint": "45yo89",
133+
"Data": {
134+
"clients": 51,
135+
"gametype": "Minigames, Races, and Free Mode",
136+
"hostname": "^5Mega's Games (US): ^5Minigames ^9|^4 Sumo ^9|^1 Races ^9|^3 Freeroam",
137+
"mapname": "Various",
138+
"sv_maxclients": 2048,
139+
"enhancedHostSupport": true,
140+
"requestSteamTicket": "off",
141+
"resources": [
142+
"hardcap",
143+
"_cfx_internal",
144+
"ivpack"
145+
],
146+
"server": "FXServer-master SERVER v1.0.0.6228 win32",
147+
"vars": {
148+
"gamename": "gta5",
149+
"locale": "en-US",
150+
"onesync_enabled": "true",
151+
"sv_enforceGameBuild": "2802",
152+
},
153+
"selfReportedClients": 51,
154+
"players": [
155+
{
156+
"endpoint": "127.0.0.1:1234",
157+
"id": 82,
158+
"identifiers": [
159+
"license:9b510e4fd9ea81065ff5ff95dbec0f5cbbf9a70a",
160+
"discord:855375608708464651",
161+
"fivem:3966756",
162+
"license2:9b510e4fd9ea81065ff5ff95dbec0f5cbbf9a70a"
163+
],
164+
"name": "qwetti",
165+
"ping": 246
166+
},
167+
{
168+
"endpoint": "127.0.0.1:1234",
169+
"id": 106,
170+
"identifiers": [
171+
"license:b0b4d13aadbb79f8f4ab557aea934a9cd14c89ec",
172+
"xbl:2535435310984194",
173+
"live:1055518852711614",
174+
"discord:412397129638739978",
175+
"fivem:5839602",
176+
"license2:88ff199d67171af80acb08c04ce12115b8a45763"
177+
],
178+
"name": "ur cooked",
179+
"ping": 87
180+
}
181+
],
182+
"ownerID": 46512,
183+
"private": false,
184+
"fallback": false,
185+
"connectEndPoints": [
186+
"192.223.26.51:15000"
187+
],
188+
"upvotePower": 168,
189+
"burstPower": 0,
190+
"support_status": "supported",
191+
"svMaxclients": 2048,
192+
"ownerName": "MegaGTAVMaster",
193+
"ownerProfile": "https://forum.cfx.re/u/MegaGTAVMaster",
194+
"ownerAvatar": "https://forum.cfx.re/user_avatar/forum.cfx.re/megagtavmaster/128/2049360_2.png",
195+
"lastSeen": "2023-03-01T07:49:41.9488692Z",
196+
"iconVersion": -1146343723
197+
},
198+
"cacheTime": 1677657024,
199+
"cacheExpire": 1677657324
200+
}
201+
}
202+
111203
export {
112204
fivemResponse,
113-
fivemPlayersResponse
205+
fivemPlayersResponse,
206+
fivemCfxResponse
114207
};

0 commit comments

Comments
 (0)