-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.js
More file actions
106 lines (92 loc) · 3.59 KB
/
index.js
File metadata and controls
106 lines (92 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const bodyParser = require('body-parser');
const express = require('express');
const fs = require('fs');
const axios = require('axios');
const consoleoutput = require('./structs/consoleoutput');
var motd = ["stormzy is gay","Friendly faces everywhere Humble folks without temptation!","idk what to put here","notpies cool i guess", "im gonna fly for you", "nice computer you got here, can i have it?"];
var realmotd = motd[Math.floor(Math.random() * motd.length)];
class backend {
get directory() {
return `${__dirname}`;
}
constructor() {
this.config = require(`${this.directory}/config`);
this.app = express();
}
loadProfile(profileId) {
return JSON.parse(fs.readFileSync(`${this.directory}/cache/templates/profile_${profileId}.json`));
};
async updateAthena() {
while (true) {
const req = await axios.get(
'https://fortnite-api.com/v2/cosmetics/br/'
);
var athena = this.loadProfile("athena");
var items = req.data.data;
items.forEach(
cosmetic => {
var cosmeticVariants = [];
if (cosmetic.variants) {
cosmetic.variants.forEach(
variant => {
var owned = [];
variant.options.forEach(option => {owned.push(option.tag)});
cosmeticVariants.push({
'channel': variant.channel,
'active': owned[0],
'owned': owned
})
})
};
athena.items[`${cosmetic.type.backendValue}:${cosmetic.id}`] = {
'templateId': `${cosmetic.type.backendValue}:${cosmetic.id}`,
'attributes': {
'max_level_bonus': 69420,
'level': 1,
'item_seen': true,
'rnd_sel_cnt': 0,
'xp': 69420,
'variants': cosmeticVariants,
'favorite': false
},
'quantity': 1
};
}
)
fs.writeFileSync(`${this.directory}/cache/templates/profile_athena.json`, JSON.stringify(athena, null, 2));
consoleoutput.log("Reloaded cosmetics!")
await new Promise(r => setTimeout(r, 1800000));
}
}
router() {
this.app.use(
(req, res, next) => {
consoleoutput.request(`${req.url}`);
next();
}
)
fs.readdirSync(`${this.directory}/routes`).forEach(
route => {
this.app.use(require(`${this.directory}/routes/${route.split('.')[0]}`))
}
)
this.app.use("/", express.static("public"));
// n
}
init() {
this.app.use(bodyParser.json());
this.app.use(bodyParser.urlencoded({
extended: true
}));
this.updateAthena();
this.router();
this.app.listen(
process.env.PORT || this.config.port, () => {
consoleoutput.log(`Server is running on port ${process.env.PORT || this.config.port}.`);
consoleoutput.log(`MOTD: ${realmotd}`);
}
)
}
}
backendClass = new backend();
backendClass.init();