Skip to content

Commit 220905b

Browse files
committed
chore: parse logos config
1 parent de8a3c7 commit 220905b

File tree

4 files changed

+62
-39
lines changed

4 files changed

+62
-39
lines changed

apps/frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
},
3737
"devDependencies": {
3838
"@anolilab/unplugin-favicons": "^1.0.5",
39+
"@sinclair/typebox": "^0.34.33",
3940
"@tanstack/router-devtools": "^1.114.31",
4041
"@tanstack/router-plugin": "^1.114.31",
4142
"@testing-library/jest-dom": "^6.6.3",

apps/frontend/src/routes/__root.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,20 @@ import { DefaultError, useQueryClient } from "@tanstack/react-query";
2929
import { i18n } from "../stores/i18n";
3030
import { C } from "../configuration";
3131
import logo from "/logo.svg";
32+
import { LogosConfig, logosConfigSchema } from "../schemas/logosConfigSchema";
33+
import { Value } from "@sinclair/typebox/value";
3234

3335
const messages = i18n("RootRoute", {
3436
title: "Home",
3537
});
3638

37-
let logos;
39+
let logos: LogosConfig;
40+
3841
try {
39-
logos = JSON.parse(C.env.logos);
42+
logos = Value.Parse(logosConfigSchema, JSON.parse(C.env.logos));
4043
} catch (error) {
4144
console.error("Failed to parse C.env.logos:", error);
42-
logos = []; // Default fallback value
45+
logos = [];
4346
}
4447

4548
function Root() {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Type, type Static } from "@sinclair/typebox";
2+
3+
export const logosConfigSchema = Type.Array(
4+
Type.Object({
5+
path: Type.String(),
6+
alt: Type.String(),
7+
url: Type.String(),
8+
})
9+
);
10+
11+
export type LogosConfig = Static<typeof logosConfigSchema>;

pnpm-lock.yaml

Lines changed: 44 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)