feat: start of scraping

This commit is contained in:
TrèsAbhi committed 2025-11-28 13:51:17 -06:00
1 parent 4a20102de3
commit ef154f99d5
11 files changed
+73 -19

No files matched your search

+1 -1
View File
@@ -22,7 +22,7 @@ depots
public/sitemap*
/firebase.json
target
# packages/core/src/protos/*.ts
packages/website-ue/src/protos/*.ts
/.vercel
.astro
.vercel
+2 -1
View File
@@ -11,7 +11,8 @@ const TS_PROTO_EXECUTABLE_LOCATIONS = [
const roots = [
// "../../packages/core/src/protos",
"../../packages/closed/protos",
// "../../packages/closed/protos",
"../../packages/website-ue/src/protos",
];
const exec = promisify(execSync);
+5 -1
View File
@@ -1 +1,5 @@
abstract class AbstractAPI {}
import type { Tanks } from "../../protos/tanks";
export abstract class AbstractAPI {
abstract tanks(): Promise<Tanks>;
}
@@ -1 +1,3 @@
import { AbstractAPI } from "./abstract";
export class ClientAPI extends AbstractAPI {}
+12 -3
View File
@@ -1,11 +1,20 @@
import { ClientAPI } from "./client";
import { ServerAPI } from "./server";
import type { AbstractAPI } from "./abstract";
let dynamicAPI: AbstractAPI;
if (typeof window === "undefined") {
dynamicAPI = new ServerAPI();
const { ProxyClient } = await import("@blitzkit/closed");
const { ServerAPI } = await import("./server");
const proxyClient = await new ProxyClient(
import.meta.env.WOTB_SERVER
).handshake();
const metadata = await proxyClient.metadata();
dynamicAPI = new ServerAPI(metadata);
} else {
const { ClientAPI } = await import("./client");
dynamicAPI = new ClientAPI();
}
+27 -1
View File
@@ -1 +1,27 @@
export class ServerAPI extends AbstractAPI {}
import type { MetadataAccessor } from "@blitzkit/closed";
import type { TanksEntry } from "../../protos/tanks";
import { AbstractAPI } from "./abstract";
export class ServerAPI extends AbstractAPI {
constructor(private metadata: MetadataAccessor) {
super();
console.log(Object.keys(metadata.groups).join("\n"));
}
async tanks() {
const group = this.metadata.group("TankEntity");
const tanks: TanksEntry[] = [];
for (const item of group) {
const tankCatalog = item.TankCatalog();
const id = item.id;
const slug = tankCatalog.name?.value;
tanks.push({ id, slug });
}
return { tanks };
}
}
@@ -1,7 +0,0 @@
import { ProxyClient } from "@blitzkit/closed";
export const proxyClient = await new ProxyClient(
import.meta.env.WOTB_SERVER
).handshake();
export const metadata = await proxyClient.metadata();
@@ -1,16 +1,18 @@
---
import { api } from "../../core/api/dynamic";
const tanksList = await api.tanksList();
const tanksList = await api.tanks();
---
<h1>Tanks</h1>
<ul>
{
tanksList.map((tank) => (
tanksList.tanks.map(({ id, slug }) => (
<li>
<a href={`/tanks/${tank}`}>{tank}</a>
<a href={`/tanks/${slug}`}>
{slug} ({id})
</a>
</li>
))
}
@@ -0,0 +1,12 @@
syntax = "proto3";
package blitzkit;
message Tanks {
repeated TanksEntry tanks = 1;
}
message TanksEntry {
string id = 1;
string slug = 2;
}
+6 -1
View File
@@ -1,3 +1,8 @@
{
"extends": ["../../tsconfig.json", "astro/tsconfigs/base"]
"extends": ["../../tsconfig.json", "astro/tsconfigs/base"],
"compilerOptions": {
"paths": {
"@protos/*": ["../../packages/closed/protos/*"]
}
}
}