mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
feat: start of scraping
This commit is contained in:
1 parent
4a20102de3
commit
ef154f99d5
11 files changed
+73
-19
No files matched your search
+1
-1
@@ -22,7 +22,7 @@ depots
|
|||||||
public/sitemap*
|
public/sitemap*
|
||||||
/firebase.json
|
/firebase.json
|
||||||
target
|
target
|
||||||
# packages/core/src/protos/*.ts
|
packages/website-ue/src/protos/*.ts
|
||||||
/.vercel
|
/.vercel
|
||||||
.astro
|
.astro
|
||||||
.vercel
|
.vercel
|
||||||
|
|||||||
+1
-1
Submodule packages/closed updated: 5b4a85d503...2c0b660702.
@@ -11,7 +11,8 @@ const TS_PROTO_EXECUTABLE_LOCATIONS = [
|
|||||||
|
|
||||||
const roots = [
|
const roots = [
|
||||||
// "../../packages/core/src/protos",
|
// "../../packages/core/src/protos",
|
||||||
"../../packages/closed/protos",
|
// "../../packages/closed/protos",
|
||||||
|
"../../packages/website-ue/src/protos",
|
||||||
];
|
];
|
||||||
|
|
||||||
const exec = promisify(execSync);
|
const exec = promisify(execSync);
|
||||||
|
|||||||
@@ -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 {}
|
export class ClientAPI extends AbstractAPI {}
|
||||||
@@ -1,11 +1,20 @@
|
|||||||
import { ClientAPI } from "./client";
|
import type { AbstractAPI } from "./abstract";
|
||||||
import { ServerAPI } from "./server";
|
|
||||||
|
|
||||||
let dynamicAPI: AbstractAPI;
|
let dynamicAPI: AbstractAPI;
|
||||||
|
|
||||||
if (typeof window === "undefined") {
|
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 {
|
} else {
|
||||||
|
const { ClientAPI } = await import("./client");
|
||||||
|
|
||||||
dynamicAPI = new ClientAPI();
|
dynamicAPI = new ClientAPI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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";
|
import { api } from "../../core/api/dynamic";
|
||||||
|
|
||||||
const tanksList = await api.tanksList();
|
const tanksList = await api.tanks();
|
||||||
---
|
---
|
||||||
|
|
||||||
<h1>Tanks</h1>
|
<h1>Tanks</h1>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{
|
{
|
||||||
tanksList.map((tank) => (
|
tanksList.tanks.map(({ id, slug }) => (
|
||||||
<li>
|
<li>
|
||||||
<a href={`/tanks/${tank}`}>{tank}</a>
|
<a href={`/tanks/${slug}`}>
|
||||||
|
{slug} ({id})
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package blitzkit;
|
||||||
|
|
||||||
|
message Tanks {
|
||||||
|
repeated TanksEntry tanks = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TanksEntry {
|
||||||
|
string id = 1;
|
||||||
|
string slug = 2;
|
||||||
|
}
|
||||||
@@ -1,3 +1,8 @@
|
|||||||
{
|
{
|
||||||
"extends": ["../../tsconfig.json", "astro/tsconfigs/base"]
|
"extends": ["../../tsconfig.json", "astro/tsconfigs/base"],
|
||||||
|
"compilerOptions": {
|
||||||
|
"paths": {
|
||||||
|
"@protos/*": ["../../packages/closed/protos/*"]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user