From 8d4933dd600e80bae3f6a6569e12041eba0325bf Mon Sep 17 00:00:00 2001
From: tresabhi <43380238+tresabhi@users.noreply.github.com>
Date: Tue, 18 Mar 2025 23:53:52 -0500
Subject: [PATCH] feat: some more apis
---
packages/core/src/blitzkit/index.ts | 1 +
packages/core/src/blitzkit/tanksFull.ts | 7 ++
packages/core/src/protos/i18n.ts | 2 +-
packages/core/src/protos/tank.ts | 2 +-
packages/website/src/constants/tools.ts | 2 +-
.../src/pages/[...locale]/api/index.astro | 98 ++++++++++---------
.../api/tankopedia/tank-icon/[id]/_index.tsx | 43 --------
.../api/tankopedia/tank-icon/[id]/index.astro | 30 ------
.../website/src/pages/api/tanks/[id].json.ts | 18 ++++
.../website/src/pages/api/tanks/full.json.ts | 13 +++
.../website/src/pages/api/tanks/list.json.ts | 12 +++
11 files changed, 108 insertions(+), 120 deletions(-)
create mode 100644 packages/core/src/blitzkit/tanksFull.ts
delete mode 100644 packages/website/src/pages/api/tankopedia/tank-icon/[id]/_index.tsx
delete mode 100644 packages/website/src/pages/api/tankopedia/tank-icon/[id]/index.astro
create mode 100644 packages/website/src/pages/api/tanks/[id].json.ts
create mode 100644 packages/website/src/pages/api/tanks/full.json.ts
create mode 100644 packages/website/src/pages/api/tanks/list.json.ts
diff --git a/packages/core/src/blitzkit/index.ts b/packages/core/src/blitzkit/index.ts
index 6c69eefc2..052f1c41c 100644
--- a/packages/core/src/blitzkit/index.ts
+++ b/packages/core/src/blitzkit/index.ts
@@ -48,4 +48,5 @@ export * from './metaSortTank';
export * from './romanize';
export * from './tank';
export * from './tanks';
+export * from './tanksFull';
export * from './youtubers';
diff --git a/packages/core/src/blitzkit/tanksFull.ts b/packages/core/src/blitzkit/tanksFull.ts
new file mode 100644
index 000000000..93435a313
--- /dev/null
+++ b/packages/core/src/blitzkit/tanksFull.ts
@@ -0,0 +1,7 @@
+import { fetchPB } from '../protobuf';
+import { TanksFull } from '../protos';
+import { asset } from './asset';
+
+export function fetchTanksFull() {
+ return fetchPB(asset('definitions/tanks-full.pb'), TanksFull);
+}
diff --git a/packages/core/src/protos/i18n.ts b/packages/core/src/protos/i18n.ts
index 56812cce5..27894724e 100644
--- a/packages/core/src/protos/i18n.ts
+++ b/packages/core/src/protos/i18n.ts
@@ -18,7 +18,7 @@ export interface I18n_LocalesEntry {
value: string;
}
-function createBaseI18n(): I18n {
+export function createBaseI18n(): I18n {
return { locales: {} };
}
diff --git a/packages/core/src/protos/tank.ts b/packages/core/src/protos/tank.ts
index b5043f5e8..ff3b06502 100644
--- a/packages/core/src/protos/tank.ts
+++ b/packages/core/src/protos/tank.ts
@@ -6,7 +6,7 @@
/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
-import { I18n } from "./i18n";
+import { I18n, createBaseI18n } from "./i18n";
export const protobufPackage = "blitzkit";
diff --git a/packages/website/src/constants/tools.ts b/packages/website/src/constants/tools.ts
index 6968b49d4..299bbd015 100644
--- a/packages/website/src/constants/tools.ts
+++ b/packages/website/src/constants/tools.ts
@@ -138,7 +138,7 @@ export const apiTool: Tool = {
button: {
color: 'indigo',
},
- image: '0bWE5hC',
+ image: 'dIfvWnV',
};
export const TOOLS: Tool[] = [
diff --git a/packages/website/src/pages/[...locale]/api/index.astro b/packages/website/src/pages/[...locale]/api/index.astro
index b0c51b59c..74909f454 100644
--- a/packages/website/src/pages/[...locale]/api/index.astro
+++ b/packages/website/src/pages/[...locale]/api/index.astro
@@ -1,5 +1,5 @@
---
-import { Code, Flex, Heading, Link } from '@radix-ui/themes';
+import { Code, Flex, Heading, Separator } from '@radix-ui/themes';
import { PageWrapper } from '../../../components/PageWrapper';
import { apiTool } from '../../../constants/tools';
import ToolLayout from '../../../layouts/ToolLayout.astro';
@@ -12,7 +12,7 @@ interface Tag {
description?: string;
}
-const getDocsRegex = /\/\*\*\n(( \*(.+)?\n?)+)\n \*\/\nexport const GET/gm;
+const getDocsRegex = /\/\*\*\n(( \*(.+)?\n?)+)\n \*\/\nexport const GET/;
const multiLineCommentPrefixRegex = /^ \* ?/gm;
const tagRegex = /(@[^\s]+)(?:\s(.+))?/;
const firstWordRegex = /(\S+)(?:\s(.+))?/;
@@ -22,7 +22,7 @@ const glob = import.meta.glob('/src/pages/api/**/*.ts', {
query: '?raw',
import: 'default',
});
-const apis: {
+let apis: {
path: string;
content: string;
comment: string;
@@ -31,7 +31,7 @@ const apis: {
for (const rawPath in glob) {
const content = (glob[rawPath] as string).replaceAll('\r', '');
- const regexExecution = getDocsRegex.exec(content);
+ const regexExecution = content.match(getDocsRegex);
const commentRaw = regexExecution?.[1];
if (!commentRaw) continue;
@@ -45,7 +45,7 @@ for (const rawPath in glob) {
const tags: Tag[] = [];
commentWithTags.split('\n').forEach((line) => {
- const match = tagRegex.exec(line);
+ const match = line.match(tagRegex);
if (match) {
const tag = match[1];
@@ -54,7 +54,7 @@ for (const rawPath in glob) {
let description: string | undefined;
if (tag === '@param') {
- const firstWordMatch = firstWordRegex.exec(descriptionRaw)!;
+ const firstWordMatch = descriptionRaw.match(firstWordRegex)!;
discriminator = firstWordMatch[1];
description = firstWordMatch[2];
} else {
@@ -75,53 +75,63 @@ for (const rawPath in glob) {
apis.push({ path, content, comment, tags });
}
+
+apis.sort((a, b) => a.path.localeCompare(b.path));
---
{api.path}
-
+ {api.path}
+
+
- {api.comment}
-
+
+ {api.comment}
+
- {api.tags.length > 0 && (
-
- {tag}
-
+ {api.tags.length > 0 && (
+
+ {tag}
+
- {discriminator && (
-
- {discriminator}
-
- )}
+ {discriminator && (
+
+ {discriminator}
+
+ )}
- {description && (
-
- {description}
-
- )}
+ {description && (
+
+ {description}
+
+ )}
+