Skip to content

Commit 3d943e1

Browse files
committed
✨ Add CitizenServer.module
1 parent a1a61c7 commit 3d943e1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/modules/CitizenServer.module.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const axios = require('axios');
2+
const CfxEndpoints = require('../enum/Endpoints');
3+
const AxiosConfig = require('../constant/AxiosConfig');
4+
const CitizenServer = require('../model/CitizenServer');
5+
6+
class CitizenServerModule {
7+
static self = null;
8+
9+
static get() {
10+
if (this.self === null) {
11+
this.self = new CitizenServerModule();
12+
}
13+
return this.self;
14+
}
15+
16+
async retrieve(id) {
17+
try {
18+
const response = await axios.get(CfxEndpoints.CFX_MASTERLIST + id, AxiosConfig);
19+
if (response.status !== 200) {
20+
new Error('Server not found or internal error occurred');
21+
}
22+
return new CitizenServer(response.data);
23+
} catch (error) {
24+
console.log('Error: ' + error);
25+
}
26+
}
27+
}
28+
29+
module.exports = CitizenServerModule;

0 commit comments

Comments
 (0)