I can't be bothered to even explain what happene here
This commit is contained in:
8
src/routes/api.ts
Normal file
8
src/routes/api.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { route as VersionCheckRoute } from "./api/versioncheck.ts";
|
||||
import { route as ConfigRoute } from "./api/config.ts";
|
||||
import { APIUtils } from "../apiutils.ts";
|
||||
|
||||
export const route = APIUtils.createRouter('/api');
|
||||
|
||||
route.router.use(VersionCheckRoute.router);
|
||||
route.router.use(ConfigRoute.router);
|
||||
10
src/routes/api/config.ts
Normal file
10
src/routes/api/config.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { APIUtils } from "../../apiutils.ts";
|
||||
import { GameConfigs } from "../../data/config.ts";
|
||||
|
||||
export const route = APIUtils.createRouter('/config');
|
||||
|
||||
route.router.get('/v2', (rq, rs) => {
|
||||
const config = GameConfigs.getConfig();
|
||||
if (config == null) rs.sendStatus(500);
|
||||
else rs.json(config);
|
||||
});
|
||||
24
src/routes/api/versioncheck.ts
Normal file
24
src/routes/api/versioncheck.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { APIUtils } from "../../apiutils.ts";
|
||||
|
||||
export const route = APIUtils.createRouter('/versioncheck');
|
||||
|
||||
const validVersion = '20191120';
|
||||
|
||||
type ValidVersionResponse = {
|
||||
ValidVersion: boolean
|
||||
}
|
||||
|
||||
route.router.get('/v3', (rq, rs) => {
|
||||
const requestedVer = rq.query['v'];
|
||||
if (typeof requestedVer !== 'string' || requestedVer !== validVersion) {
|
||||
const res: ValidVersionResponse = {
|
||||
ValidVersion: false
|
||||
}
|
||||
rs.json(res);
|
||||
} else {
|
||||
const res: ValidVersionResponse = {
|
||||
ValidVersion: true
|
||||
}
|
||||
rs.json(res);
|
||||
}
|
||||
});
|
||||
40
src/routes/nameserver.ts
Normal file
40
src/routes/nameserver.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { APIUtils } from "../apiutils.ts";
|
||||
import { Config } from "../config.ts";
|
||||
|
||||
const config = Config.getConfig() as Config.GalvanicConfiguration;
|
||||
const protocol = config.web.secureNameserverHost ? 'https' : 'http';
|
||||
|
||||
export const route = APIUtils.createRouter('/ns');
|
||||
|
||||
type NameserverHosts = {
|
||||
Auth: string,
|
||||
API: string,
|
||||
WWW: string,
|
||||
Notifications: string,
|
||||
Images: string,
|
||||
CDN: string,
|
||||
Commerce: string,
|
||||
Matchmaking: string,
|
||||
Storage: string,
|
||||
Chat: string,
|
||||
Leaderboard: string
|
||||
}
|
||||
|
||||
const path = `${protocol}://${config.web.nameserverHost}`;
|
||||
const nameserver: NameserverHosts = {
|
||||
Auth: path,
|
||||
API: path,
|
||||
WWW: path,
|
||||
Notifications: path,
|
||||
Images: path,
|
||||
CDN: path,
|
||||
Commerce: path,
|
||||
Matchmaking: path,
|
||||
Storage: path,
|
||||
Chat: path,
|
||||
Leaderboard: path
|
||||
}
|
||||
|
||||
route.router.get('*', (_rq, rs) => {
|
||||
rs.json(nameserver);
|
||||
});
|
||||
Reference in New Issue
Block a user