-
Notifications
You must be signed in to change notification settings - Fork 78
/
index.js
65 lines (56 loc) · 2.28 KB
/
index.js
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
const Express = require("express");
const express = Express();
const fs = require("fs");
const path = require("path");
const cookieParser = require("cookie-parser");
express.use(Express.json());
express.use(Express.urlencoded({ extended: true }));
express.use(Express.static('public'));
express.use(cookieParser());
express.use(require("./structure/party.js"));
express.use(require("./structure/discovery.js"))
express.use(require("./structure/privacy.js"));
express.use(require("./structure/timeline.js"));
express.use(require("./structure/user.js"));
express.use(require("./structure/contentpages.js"));
express.use(require("./structure/friends.js"));
express.use(require("./structure/main.js"));
express.use(require("./structure/storefront.js"));
express.use(require("./structure/version.js"));
express.use(require("./structure/lightswitch.js"));
express.use(require("./structure/affiliate.js"));
express.use(require("./structure/matchmaking.js"));
express.use(require("./structure/cloudstorage.js"));
express.use(require("./structure/mcp.js"));
const port = process.env.PORT || 3551;
express.listen(port, () => {
console.log("LawinServer started listening on port", port);
require("./structure/xmpp.js");
}).on("error", (err) => {
if (err.code == "EADDRINUSE") console.log(`\x1b[31mERROR\x1b[0m: Port ${port} is already in use!`);
else throw err;
process.exit(0);
});
try {
if (!fs.existsSync(path.join(process.env.LOCALAPPDATA, "LawinServer"))) fs.mkdirSync(path.join(process.env.LOCALAPPDATA, "LawinServer"));
} catch (err) {
// fallback
if (!fs.existsSync(path.join(__dirname, "ClientSettings"))) fs.mkdirSync(path.join(__dirname, "ClientSettings"));
}
// if endpoint not found, return this error
express.use((req, res, next) => {
var XEpicErrorName = "errors.com.lawinserver.common.not_found";
var XEpicErrorCode = 1004;
res.set({
'X-Epic-Error-Name': XEpicErrorName,
'X-Epic-Error-Code': XEpicErrorCode
});
res.status(404);
res.json({
"errorCode": XEpicErrorName,
"errorMessage": "Sorry the resource you were trying to find could not be found",
"numericErrorCode": XEpicErrorCode,
"originatingService": "any",
"intent": "prod"
});
});