mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: removed server
This commit is contained in:
1 parent
eb24f49766
commit
38f912dc0a
17 files changed
+14
-181
No files matched your search
@@ -1,43 +0,0 @@
|
|||||||
name: CI Build
|
|
||||||
|
|
||||||
on: [push, pull_request]
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Use node
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: 18
|
|
||||||
cache: 'npm'
|
|
||||||
|
|
||||||
- name: Install Yarn
|
|
||||||
run: npm install --location=global yarn
|
|
||||||
|
|
||||||
- name: Use node_modules cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: '**/node_modules'
|
|
||||||
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: yarn
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: yarn build:server
|
|
||||||
|
|
||||||
- name: Archive build
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: server
|
|
||||||
path: dist/server
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Blitzkrieg 1.30.0
|
||||||
|
|
||||||
|
One of the biggest updates ever! This changelog's size does not truly represent the work (and brain cells) spent.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
- Disabled the `/clan-event` command
|
||||||
@@ -21,7 +21,7 @@ import addRegionChoices from '../core/discord/addRegionChoices';
|
|||||||
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
||||||
import autocompleteUsername from '../core/discord/autocompleteUsername';
|
import autocompleteUsername from '../core/discord/autocompleteUsername';
|
||||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||||
import { octokit } from '../core/express/octokit';
|
import { octokit } from '../core/github/octokit';
|
||||||
import throwError from '../core/node/throwError';
|
import throwError from '../core/node/throwError';
|
||||||
import { CommandRegistryRaw } from '../events/interactionCreate';
|
import { CommandRegistryRaw } from '../events/interactionCreate';
|
||||||
import { AccountInfo } from '../types/accountInfo';
|
import { AccountInfo } from '../types/accountInfo';
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { RatingsInfo } from '../../commands/ratings';
|
import { RatingsInfo } from '../../commands/ratings';
|
||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import { DATABASE_REPO } from '../database/getMidnightLeaderboard';
|
import { DATABASE_REPO } from '../database/getMidnightLeaderboard';
|
||||||
import { octokit } from '../express/octokit';
|
import { octokit } from '../github/octokit';
|
||||||
import throwError from '../node/throwError';
|
import throwError from '../node/throwError';
|
||||||
|
|
||||||
export default async function getArchivedRatingsInfo(
|
export default async function getArchivedRatingsInfo(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { BlitzkriegRatingsLeaderboard } from '../../../scripts/buildRatingsLeaderboard';
|
import { BlitzkriegRatingsLeaderboard } from '../../../scripts/buildRatingsLeaderboard';
|
||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import { octokit } from '../express/octokit';
|
import { octokit } from '../github/octokit';
|
||||||
|
|
||||||
export const DATABASE_REPO = { owner: 'tresabhi', repo: 'blitzkrieg-db' };
|
export const DATABASE_REPO = { owner: 'tresabhi', repo: 'blitzkrieg-db' };
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ButtonInteraction, CacheType } from 'discord.js';
|
import { ButtonInteraction, CacheType } from 'discord.js';
|
||||||
import { CYCLIC_API } from '../../constants/cyclic';
|
import { CYCLIC_API } from '../../constants/cyclic';
|
||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import resolvePeriodFromURL from '../express/resolvePeriodFromURL';
|
import resolvePeriodFromURL from './resolvePeriodFromURL';
|
||||||
|
|
||||||
export default function resolvePeriodFromButton(
|
export default function resolvePeriodFromButton(
|
||||||
server: Region,
|
server: Region,
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ import { Region } from '../../constants/regions';
|
|||||||
import getPeriodNow from '../blitzstars/getPeriodNow';
|
import getPeriodNow from '../blitzstars/getPeriodNow';
|
||||||
import getPeriodStart from '../blitzstars/getPeriodStart';
|
import getPeriodStart from '../blitzstars/getPeriodStart';
|
||||||
import getTimeDaysAgo from '../blitzstars/getTimeDaysAgo';
|
import getTimeDaysAgo from '../blitzstars/getTimeDaysAgo';
|
||||||
import { PeriodSize, PeriodType } from '../discord/addPeriodSubCommands';
|
import { PeriodSize, PeriodType } from './addPeriodSubCommands';
|
||||||
import {
|
import {
|
||||||
ResolvedPeriod,
|
ResolvedPeriod,
|
||||||
getPeriodOptionName,
|
getPeriodOptionName,
|
||||||
} from '../discord/resolvePeriodFromCommand';
|
} from './resolvePeriodFromCommand';
|
||||||
|
|
||||||
export default function resolvePeriodFromURL(
|
export default function resolvePeriodFromURL(
|
||||||
server: Region,
|
server: Region,
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ButtonInteraction, CacheType } from 'discord.js';
|
import { ButtonInteraction, CacheType } from 'discord.js';
|
||||||
import { CYCLIC_API } from '../../constants/cyclic';
|
import { CYCLIC_API } from '../../constants/cyclic';
|
||||||
import resolvePlayerFromURL from '../express/resolvePlayerFromURL';
|
import resolvePlayerFromURL from './resolvePlayerFromURL';
|
||||||
|
|
||||||
export default async function resolvePlayerFromButton(
|
export default async function resolvePlayerFromButton(
|
||||||
interaction: ButtonInteraction<CacheType>,
|
interaction: ButtonInteraction<CacheType>,
|
||||||
|
|||||||
File renamed without changes.
@@ -1,11 +0,0 @@
|
|||||||
import { RouteReturnable } from '../../server';
|
|
||||||
import jsxToSvg from '../node/jsxToSvg';
|
|
||||||
|
|
||||||
export default async function normalizeRouteReturnable(
|
|
||||||
returnable: RouteReturnable,
|
|
||||||
) {
|
|
||||||
const awaitedReturnable = await returnable;
|
|
||||||
const svg = await jsxToSvg(awaitedReturnable);
|
|
||||||
|
|
||||||
return svg;
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { Request } from 'express';
|
|
||||||
import { CYCLIC_API } from '../../constants/cyclic';
|
|
||||||
import { Region } from '../../constants/regions';
|
|
||||||
import resolvePeriodFromURL from './resolvePeriodFromURL';
|
|
||||||
|
|
||||||
export default function resolvePeriodFromRequest(
|
|
||||||
server: Region,
|
|
||||||
request: Request,
|
|
||||||
) {
|
|
||||||
return resolvePeriodFromURL(server, `${CYCLIC_API}${request.url}`);
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import { Request } from 'express';
|
|
||||||
import { CYCLIC_API } from '../../constants/cyclic';
|
|
||||||
import resolvePlayerFromURL from './resolvePlayerFromURL';
|
|
||||||
|
|
||||||
export default function resolvePlayerFromRequest(request: Request) {
|
|
||||||
return resolvePlayerFromURL(`${CYCLIC_API}${request.originalUrl}`);
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
export default function withAutoRefresh(svg: string, refreshAfter: number) {
|
|
||||||
return `
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<script>
|
|
||||||
setTimeout(() => {
|
|
||||||
window.location.reload();
|
|
||||||
}, ${refreshAfter});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
${svg}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
File renamed without changes.
@@ -1,23 +0,0 @@
|
|||||||
import resolvePeriodFromRequest from '../core/express/resolvePeriodFromRequest';
|
|
||||||
import resolvePlayerFromRequest from '../core/express/resolvePlayerFromRequest';
|
|
||||||
import stats, { StatType } from '../renderers/stats';
|
|
||||||
import { RouteRegistry } from '../server';
|
|
||||||
|
|
||||||
export const statsRoute: RouteRegistry = {
|
|
||||||
route: '/stats/:type/:period',
|
|
||||||
inProduction: true,
|
|
||||||
|
|
||||||
async handler(req) {
|
|
||||||
const type = req.params.type as StatType;
|
|
||||||
const player = resolvePlayerFromRequest(req);
|
|
||||||
const period = resolvePeriodFromRequest(player.region, req);
|
|
||||||
|
|
||||||
return await stats(
|
|
||||||
type,
|
|
||||||
period,
|
|
||||||
player,
|
|
||||||
parseInt(req.query.tankId as string),
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
import resolvePlayerFromRequest from '../core/express/resolvePlayerFromRequest';
|
|
||||||
import today from '../renderers/today';
|
|
||||||
import { RouteRegistry } from '../server';
|
|
||||||
|
|
||||||
export const todayRoute: RouteRegistry = {
|
|
||||||
route: '/today',
|
|
||||||
inProduction: true,
|
|
||||||
|
|
||||||
async handler(req) {
|
|
||||||
const player = resolvePlayerFromRequest(req);
|
|
||||||
|
|
||||||
return await today(
|
|
||||||
player,
|
|
||||||
req.query.cutoff ? parseInt(req.query.cutoff as string) : undefined,
|
|
||||||
req.query.maximized ? parseInt(req.query.maximized as string) : undefined,
|
|
||||||
req.query['show-total'] ? req.query['show-total'] === 'true' : undefined,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
import express, { Request, Response } from 'express';
|
|
||||||
import normalizeRouteReturnable from './core/express/normalizeRouteReturnable';
|
|
||||||
import withAutoRefresh from './core/express/withAutoRefresh';
|
|
||||||
import { Registry } from './events/interactionCreate';
|
|
||||||
import { statsRoute } from './routes/stats';
|
|
||||||
import { todayRoute } from './routes/today';
|
|
||||||
|
|
||||||
export type RouteReturnable = JSX.Element | Promise<JSX.Element>;
|
|
||||||
|
|
||||||
export interface RouteRegistry<HandlesInteraction extends boolean = false>
|
|
||||||
extends Registry {
|
|
||||||
route: string;
|
|
||||||
handlesInteraction?: HandlesInteraction;
|
|
||||||
|
|
||||||
handler: (
|
|
||||||
req: Request,
|
|
||||||
res: Response,
|
|
||||||
) => HandlesInteraction extends true ? void : RouteReturnable;
|
|
||||||
}
|
|
||||||
|
|
||||||
const app = express();
|
|
||||||
|
|
||||||
([statsRoute, todayRoute] as RouteRegistry[]).forEach((registry) => {
|
|
||||||
app.get(registry.route, async (req, res) => {
|
|
||||||
console.log(req.originalUrl);
|
|
||||||
|
|
||||||
const returnable = registry.handler(req, res);
|
|
||||||
if (registry.handlesInteraction) return;
|
|
||||||
|
|
||||||
res.send(
|
|
||||||
withAutoRefresh(await normalizeRouteReturnable(returnable), 30 * 1000),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
app.listen(process.env.PORT ?? 3000);
|
|
||||||
Reference in new issue
Block a user