Rooms and matchmaking

* Added missing config (route) data
* Fetch room class, database hash
* Basic room querying
* Built-in room generation during first runtime
* Matchmaking response base and notes for myself, later today
* Instance fixes
* Challenge and quick play routes
(unused for now)
* Rooms route (untested)
* Matchmaking goto route
* Avatar route addition
* Settings/set route
This commit is contained in:
2025-04-02 00:27:10 -04:00
parent e9830dcb19
commit 27b3754330
68 changed files with 1745 additions and 27 deletions

View File

@@ -1,3 +1,20 @@
/* Galvanic Corrosion - Rec Room custom server for communities.
<https://gitea.proxnet.dev/zombieb-galvanic-corrosion>
Copyright (C) 2025 @zombieb (Discord / proxnet Gitea)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
import * as Log from "@proxnet/undead-logging";
import * as Config from "./config.ts";
import { Database } from "./db.ts";
@@ -10,6 +27,7 @@ import { decode } from "@gz/jwt";
import UnifiedProfile, { ProfileTokenFormat } from "./data/profiles.ts";
import { SocketHandoff } from "./socket/handoff.ts";
import { SignalRSocketHandler } from "./socket/socket.ts";
import Rooms from "./data/content/rooms.ts";
const instanceId = generateRandomString(64);
@@ -42,11 +60,6 @@ try {
Deno.exit(1);
}
const port = config.web.api.port;
const host = config.web.api.host;
log.n(`Starting HTTP server on http://${host}:${port}`);
const app = express();
app.disable("etag");
@@ -92,11 +105,13 @@ app.use(notifyRouter.route.path, notifyRouter.route.router);
app.use(cdnRouter.route.path, cdnRouter.route.router);
app.use((rq: express.Request, rs: express.Response) => {
log.e(`${APIUtils.getSrcIpDefault(rq)} 404 ${rq.method} ${rq.url.toString()}`);
log.e(`${rs.locals.reqId} ${APIUtils.getSrcIpDefault(rq)} 404 ${rq.method} ${rq.url.toString()}`);
rs.statusCode = 404;
rs.json(APIUtils.genericResponseFormat(true, "Endpoint not found. Check your syntax and/or method."));
});
if (!(await Rooms.generateBuiltinRooms())) log.i(`Generated built-in rooms`);
try {
/**
@@ -127,6 +142,11 @@ try {
else return { token: decodedToken, valid: true } as AuthResult;
}
const port = config.web.api.port;
const host = config.web.api.host;
log.n(`Starting HTTP server on http://${host}:${port}`);
const abort = new AbortController();
// Galvanic WebSocket
@@ -186,11 +206,6 @@ try {
for (const handoff of SocketHandoff.all()) handoff.complete();
});
/*
PLACE TEST HERE
*/
if (!(await UnifiedProfile.existsByName("Coach"))) UnifiedProfile.create({ username: "Coach", id: 1 }); // create Coach id 1 if they do not exist
if (!(await UnifiedProfile.existsByName("Server"))) UnifiedProfile.create({ username: "Server", id: 2 }); // create Server id 2 if they do not exist