mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: start of all tanks
This commit is contained in:
1 parent
53d05e73a6
commit
fcfc97b964
14 files changed
+174
-58
No files matched your search
@@ -1,12 +1,19 @@
|
||||
import { fetchPB } from "@blitzkit/core";
|
||||
import { Tank } from "../../protos/tank";
|
||||
import { TankList } from "../../protos/tank_list";
|
||||
import { Tanks } from "../../protos/tanks";
|
||||
import { AbstractAPI } from "./abstract";
|
||||
|
||||
export class ClientAPI extends AbstractAPI {
|
||||
async tank(id: string) {
|
||||
const response = await fetch(`/api/tanks/${id}.pb`);
|
||||
const buffer = await response.arrayBuffer();
|
||||
const array = new Uint8Array(buffer);
|
||||
tanks() {
|
||||
return fetchPB("/api/tanks.pb", Tanks);
|
||||
}
|
||||
|
||||
return Tank.decode(array);
|
||||
tankList() {
|
||||
return fetchPB("/api/tanks/list.pb", TankList);
|
||||
}
|
||||
|
||||
tank(id: string) {
|
||||
return fetchPB(`/api/tanks/${id}.pb`, Tank);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user