Adds inital stuff, inlcudes basic documentation.

This commit is contained in:
James Quinley 2023-06-18 09:31:07 -07:00
parent f4c1c6d406
commit 37be23c824
3 changed files with 70 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
package-lock.json
node_modules

4
config.json Normal file
View File

@ -0,0 +1,4 @@
{
"clientID" : "1046218306736095352",
"clientSecret": "WLFoLaE_Kx5yRMhBfiaGWZmsWsLL3BaQ"
}

64
server.js Normal file
View File

@ -0,0 +1,64 @@
const Express = require("express");
const BodyParser = require("body-parser");
const mongodb = require("mongodb");
const ObjectId = require("mongodb").ObjectID;
const CONNECTION_URL = "mongodb+srv://edgenetworknode:yUiWfJBYCGwdRayj@matchnethop.hgxv0xd.mongodb.net/?retryWrites=true&w=majority";
const DATABASE_NAME = "DelegationRequest";
const COLLECTION_NAME = "nettranslate";
const sha256 = require('js-sha256');
var cors = require('cors');
const Collection = require("mongodb/lib/collection");
const Db = require("mongodb/lib/db");
const MongoClient = require("mongodb").MongoClient;
const request = require('undici');
const axios = require('axios');
const requestIp = require('request-ip');
let requestEnable = false;
var app = Express();
app.use(cors());
app.use(BodyParser.json());
app.use(BodyParser.urlencoded({ extended: true }));
app.use(requestIp.mw());
app.enable('trust proxy');
var corsOptions = {
origin: 'http://matchmaking.obsidiancorestudios.com',
optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
}
var database, collection;
/**GET*/
app.get("/", (request, response) => {
response.json({
Error: "Please refer to documentation.",
Status: "Failed",
Info: "Matchmaking Server"
})
});
/**GET:USRPASS:SESSION*/
app.get("/lobbylist/", async (request, response) => {
/**
Field LobbyCount notifies the client of the number of indexed lobbies in the response
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
*/
response.status(200).json({
LobbyCount: 2,
LBN1: "DebugLobbyOne",
LBIP1: "xxx.xxx.xxx.xxx",
LBN2: "DebugLobbyTwo",
LBIP2: "xxx.xxx.xxx.xxx"
});
});
app.listen(10000, () => {
console.log("Application is now online, attempting to connect to Database. Requests will be set to 503 until connected!")
MongoClient.connect(CONNECTION_URL, { useNewUrlParser: true, useUnifiedTopology: true} , (error, client) => {
if(error) {
throw error;
}
database = client.db(DATABASE_NAME);
auth = database.collection(COLLECTION_NAME);
requestEnable = true;
console.log("Database is connected and requests are enabled...");
});
});