That's a spicy meatball

* APIUtils additions
* Socket and web server listen on dedicated ports (see denoland/deno socket issue created by ZombieB1309 on GitHub)
* Coach and Server created automatically (untested)
* Profile content functions split into 'managers'
* Progression temporary implementation
* Settings placed into profile content manager
* Relationships and messages return temporary empty array
* Socket targets defined, message delivery to target, exec returned (goes unused for now)
This commit is contained in:
2025-03-29 01:59:28 -04:00
parent 6b97e3800a
commit 6aae9129b5
28 changed files with 529 additions and 148 deletions

View File

@@ -2,6 +2,8 @@ import { route as VersionCheckRoute } from "./api/versioncheck.ts";
import { route as ConfigRoute } from "./api/config.ts";
import { route as GameConfig } from "./api/gameconfigs.ts";
import { route as PlayerReportingRoute } from "./api/PlayerReporting.ts";
import { route as MessagesRoute } from "./api/messages.ts";
import { route as RelationshipsRoute } from "./api/relationships.ts";
import { APIUtils } from "../apiutils.ts";
export const route = APIUtils.createRouter("/api");
@@ -9,4 +11,6 @@ export const route = APIUtils.createRouter("/api");
route.router.use(VersionCheckRoute.path, VersionCheckRoute.router);
route.router.use(ConfigRoute.path, ConfigRoute.router);
route.router.use(GameConfig.path, GameConfig.router);
route.router.use(PlayerReportingRoute.path, PlayerReportingRoute.router);
route.router.use(PlayerReportingRoute.path, PlayerReportingRoute.router);
route.router.use(MessagesRoute.path, MessagesRoute.router);
route.router.use(RelationshipsRoute.path, RelationshipsRoute.router);

View File

@@ -8,3 +8,10 @@ route.router.get("/v2", (_rq, rs) => {
if (config == null) rs.sendStatus(500);
else rs.json(config);
});
route.router.get('/v1/amplitude',
APIUtils.setCacheAllowed,
(_rq, rs) => {
rs.json({AmplitudeKey: ""});
}
);

View File

@@ -0,0 +1,13 @@
import { APIUtils } from "../../apiutils.ts";
export const route = APIUtils.createRouter("/messages");
route.router.get('/v2/get',
APIUtils.Authentication,
(_rq, rs) => {
rs.json([]); // temporary
}
)

17
src/routes/api/players.ts Normal file
View File

@@ -0,0 +1,17 @@
import { APIUtils } from "../../apiutils.ts";
export const route = APIUtils.createRouter("/players");
route.router.get('/v1/progression/:id',
APIUtils.Authentication,
async (_rq, rs) => {
rs.json({
PlayerId: rs.locals.profile.getId(),
Level: await rs.locals.profile.Progression.getLevel(), // await is temporary
Xp: await rs.locals.profile.Progression.getXp()
});
}
);

View File

@@ -0,0 +1,15 @@
import { APIUtils } from "../../apiutils.ts";
import { AuthType } from "../../data/users.ts";
export const route = APIUtils.createRouter("/relationships");
route.router.get('/v2/get',
APIUtils.Authentication,
APIUtils.AuthenticationType(AuthType.Game),
(_rq, rs) => {
rs.json([]); // temporary
}
);

View File

@@ -1,10 +1,12 @@
import { APIUtils } from "../../apiutils.ts";
import { AuthType } from "../../data/users.ts";
export const route = APIUtils.createRouter("/cachedlogin");
route.router.get("/forplatformid/:platformtype/:platformid",
APIUtils.Authentication,
APIUtils.AuthenticationType(AuthType.Web),
async (_rq, rs) => {
const profiles = await rs.locals.user.exportAssociatedProfiles();

View File

@@ -5,6 +5,7 @@ import { decode } from "@gz/jwt";
import { Config } from "../../config.ts";
import Logging from "@proxnet/undead-logging";
import { z } from "zod";
import { AuthType } from "../../data/users.ts";
const config = Config.getConfig();
@@ -75,6 +76,7 @@ interface TokenResponseBody {
route.router.post("/token",
APIUtils.Authentication,
APIUtils.AuthenticationType(AuthType.Web),
express.urlencoded({ extended: true }),
APIUtils.validateRequestBody<AuthBodyBase>(TokenRequestBodySchema),
@@ -149,6 +151,9 @@ route.router.post("/token",
return;
}
const details = await profile.export();
log.i(`Player ${details?.username} "${details?.displayName}" (${profile.getId()}) logged in`);
const token = await profile.getToken();
rs.json({
access_token: token,

View File

@@ -3,6 +3,7 @@ import { APIUtils, NoBody } from "../../apiutils.ts";
import express from "express";
import Matchmaking from "../../data/live/base.ts";
import Presence from "../../data/live/presence.ts";
import { AuthType } from "../../data/users.ts";
export const route = APIUtils.createRouter('/player');
@@ -17,6 +18,7 @@ const LoginSchema = z.object({
route.router.post('/login',
APIUtils.Authentication,
APIUtils.AuthenticationType(AuthType.Game),
express.urlencoded({extended: true}),
APIUtils.validateRequestBody(LoginSchema),

View File

@@ -2,7 +2,7 @@ import { APIUtils } from "../apiutils.ts";
import { Config } from "../config.ts";
const config = Config.getConfig() as Config.GalvanicConfiguration;
const protocol = config.web.securepublichost ? "https" : "http";
const protocol = config.web.api.securepublichost ? "https" : "http";
export const route = APIUtils.createRouter("/ns");
@@ -21,17 +21,17 @@ type NameserverHosts = {
};
const nameserver: NameserverHosts = {
Auth: `${protocol}://${config.web.publichost}/auth`,
API: `${protocol}://${config.web.publichost}`,
WWW: `${protocol}://${config.web.publichost}`,
Notifications: `${protocol}://${config.web.publichost}/notify`,
Images: `${protocol}://${config.web.publichost}/img`,
CDN: `${protocol}://${config.web.publichost}/cdn`,
Commerce: `${protocol}://${config.web.publichost}/commerce`,
Matchmaking: `${protocol}://${config.web.publichost}/match`,
Storage: `${protocol}://${config.web.publichost}/storage`,
Chat: `${protocol}://${config.web.publichost}/chat`,
Leaderboard: `${protocol}://${config.web.publichost}/leaderboard`,
Auth: `${protocol}://${config.web.api.publichost}/auth`,
API: `${protocol}://${config.web.api.publichost}`,
WWW: `${protocol}://${config.web.api.publichost}`,
Notifications: `${protocol}://${config.web.api.publichost}/notify`,
Images: `${protocol}://${config.web.api.publichost}/img`,
CDN: `${protocol}://${config.web.api.publichost}/cdn`,
Commerce: `${protocol}://${config.web.api.publichost}/commerce`,
Matchmaking: `${protocol}://${config.web.api.publichost}/match`,
Storage: `${protocol}://${config.web.api.publichost}/storage`,
Chat: `${protocol}://${config.web.api.publichost}/chat`,
Leaderboard: `${protocol}://${config.web.api.publichost}/leaderboard`,
};
route.router.get("*", (_rq, rs) => {