This commit updates how the service handles startup
This commit is contained in:
parent
614886fcd7
commit
8888b5d1ad
21
server.js
21
server.js
@ -5,15 +5,9 @@ const ObjectId = require("mongodb").ObjectID;
|
|||||||
const CONNECTION_URL = "mongodb+srv://edgenetworknode:yUiWfJBYCGwdRayj@matchnethop.hgxv0xd.mongodb.net/?retryWrites=true&w=majority";
|
const CONNECTION_URL = "mongodb+srv://edgenetworknode:yUiWfJBYCGwdRayj@matchnethop.hgxv0xd.mongodb.net/?retryWrites=true&w=majority";
|
||||||
const DATABASE_NAME = "edgecomm";
|
const DATABASE_NAME = "edgecomm";
|
||||||
const COLLECTION_NAME = "nettranslate";
|
const COLLECTION_NAME = "nettranslate";
|
||||||
const sha256 = require('js-sha256');
|
|
||||||
var cors = require('cors');
|
var cors = require('cors');
|
||||||
const Collection = require("mongodb/lib/collection");
|
|
||||||
const Db = require("mongodb/lib/db");
|
|
||||||
const MongoClient = require("mongodb").MongoClient;
|
const MongoClient = require("mongodb").MongoClient;
|
||||||
const request = require('undici');
|
|
||||||
const axios = require('axios');
|
|
||||||
const requestIp = require('request-ip');
|
const requestIp = require('request-ip');
|
||||||
let requestEnable = false;
|
|
||||||
var app = Express();
|
var app = Express();
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
app.use(BodyParser.json());
|
app.use(BodyParser.json());
|
||||||
@ -25,6 +19,7 @@ var corsOptions = {
|
|||||||
optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
|
optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
|
||||||
}
|
}
|
||||||
var database, collection;
|
var database, collection;
|
||||||
|
var requestEnable = false;
|
||||||
/**GET*/
|
/**GET*/
|
||||||
app.get("/", (request, response) => {
|
app.get("/", (request, response) => {
|
||||||
response.json({
|
response.json({
|
||||||
@ -41,6 +36,7 @@ app.get("/lobby/listall/", async (request, response) => {
|
|||||||
Field LBN[num] breaks down into Lobby Name [Number], this informs the client what the name is of the assosiated lobby
|
Field LBN[num] breaks down into Lobby Name [Number], this informs the client what the name is of the assosiated lobby
|
||||||
Field LBIP[num] breaks down into Lobby IP [Number], this informs the client what the IP is of the assosiated lobby
|
Field LBIP[num] breaks down into Lobby IP [Number], this informs the client what the IP is of the assosiated lobby
|
||||||
*/
|
*/
|
||||||
|
if (requestEnable) {
|
||||||
var o_id = new mongodb.ObjectID();
|
var o_id = new mongodb.ObjectID();
|
||||||
var ar;
|
var ar;
|
||||||
auth.insertOne({
|
auth.insertOne({
|
||||||
@ -71,6 +67,7 @@ app.get("/lobby/listall/", async (request, response) => {
|
|||||||
responseEnabled = false;
|
responseEnabled = false;
|
||||||
enableLookup = false;
|
enableLookup = false;
|
||||||
response.status(200).json({
|
response.status(200).json({
|
||||||
|
Info: "Good",
|
||||||
LBN : res.lobbies,
|
LBN : res.lobbies,
|
||||||
LBIP : res.ip,
|
LBIP : res.ip,
|
||||||
LobbyCount : res.LobbyCount
|
LobbyCount : res.LobbyCount
|
||||||
@ -104,7 +101,10 @@ app.get("/lobby/listall/", async (request, response) => {
|
|||||||
enableLookup = false;
|
enableLookup = false;
|
||||||
res = null;
|
res = null;
|
||||||
if (responseEnabled) {
|
if (responseEnabled) {
|
||||||
response.sendStatus(500);
|
response.status(503).json({
|
||||||
|
Info: "Forbidden",
|
||||||
|
Message: "Something went wrong..."
|
||||||
|
});
|
||||||
}
|
}
|
||||||
responseEnabled = false;
|
responseEnabled = false;
|
||||||
console.log(err);
|
console.log(err);
|
||||||
@ -113,6 +113,13 @@ app.get("/lobby/listall/", async (request, response) => {
|
|||||||
}
|
}
|
||||||
verifyUser();
|
verifyUser();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
response.status(503).json({
|
||||||
|
Info: "Forbidden",
|
||||||
|
Message: "The server is starting up, please retry again in a moment."
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
app.get("/lobby/submit/", async (request, response) => {
|
app.get("/lobby/submit/", async (request, response) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user