aboutsummaryrefslogtreecommitdiff
path: root/server/frontend/src
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-01-17 16:15:56 +0100
committerLinnea Gräf <nea@nea.moe>2025-01-17 16:15:56 +0100
commitd391ce632be29c49a612c64eb5f720238a46844d (patch)
treea0a8b92c9ec550a5c794fc6edaf9fd71e1621490 /server/frontend/src
parentaa7e28e799ce19f04c6c33782ea8d25ef4c3bb98 (diff)
downloadLocalTransactionLedger-d391ce632be29c49a612c64eb5f720238a46844d.tar.gz
LocalTransactionLedger-d391ce632be29c49a612c64eb5f720238a46844d.tar.bz2
LocalTransactionLedger-d391ce632be29c49a612c64eb5f720238a46844d.zip
feat(server): Add all in one http server
Diffstat (limited to 'server/frontend/src')
-rw-r--r--server/frontend/src/App.tsx14
-rw-r--r--server/frontend/src/Test.tsx48
-rw-r--r--server/frontend/src/api-schema.d.ts154
-rw-r--r--server/frontend/src/api.ts4
-rw-r--r--server/frontend/src/index.tsx20
5 files changed, 125 insertions, 115 deletions
diff --git a/server/frontend/src/App.tsx b/server/frontend/src/App.tsx
index 6773d90..e35bb42 100644
--- a/server/frontend/src/App.tsx
+++ b/server/frontend/src/App.tsx
@@ -1,11 +1,13 @@
-import type {Component} from "solid-js";
-import {A} from "@solidjs/router";
+import type { Component } from "solid-js";
+import { A } from "@solidjs/router";
const App: Component = () => {
- return <>
- Hello World
- <A href="/test">Test Page</A>
- </>;
+ return (
+ <>
+ Hello World
+ <A href="/test">Test Page</A>
+ </>
+ );
};
export default App;
diff --git a/server/frontend/src/Test.tsx b/server/frontend/src/Test.tsx
index 6eee2d6..15d2f73 100644
--- a/server/frontend/src/Test.tsx
+++ b/server/frontend/src/Test.tsx
@@ -1,23 +1,31 @@
-import {A, createAsync} from "@solidjs/router";
-import {client} from "./api.js";
-import {For, Suspense} from "solid-js";
+import { A, createAsync } from "@solidjs/router";
+import { client } from "./api.js";
+import { For, Suspense } from "solid-js";
export default function Test() {
- let items = createAsync(() => client.GET("/item", {
- params: {
- query: {
- itemId: ['HYPERION', 'BAT_WAND']
- }
- }
- }))
- return <>
- Test page <A href={"/"}>Back to main</A>
- <hr/>
- <Suspense fallback={"Loading items..."}>
- <p>Here are all Items:</p>
- <For each={Object.entries(items()?.data || {})}>
- { ([id, name]) => <li><code>{id}</code>: {name}</li>}
- </For>
- </Suspense>
+ let items = createAsync(() =>
+ client.GET("/item", {
+ params: {
+ query: {
+ itemId: ["HYPERION", "BAT_WAND"],
+ },
+ },
+ })
+ );
+ return (
+ <>
+ Test page <A href={"/"}>Back to main</A>
+ <hr />
+ <Suspense fallback={"Loading items..."}>
+ <p>Here are all Items:</p>
+ <For each={Object.entries(items()?.data || {})}>
+ {([id, name]) => (
+ <li>
+ <code>{id}</code>: {name}
+ </li>
+ )}
+ </For>
+ </Suspense>
</>
-} \ No newline at end of file
+ );
+}
diff --git a/server/frontend/src/api-schema.d.ts b/server/frontend/src/api-schema.d.ts
index 920cd4b..93bedc9 100644
--- a/server/frontend/src/api-schema.d.ts
+++ b/server/frontend/src/api-schema.d.ts
@@ -4,95 +4,95 @@
*/
export interface paths {
- "/profiles": {
- parameters: {
- query?: never;
- header?: never;
- path?: never;
- cookie?: never;
- };
- /** List all profiles and players known to ledger */
- get: operations["listProfiles"];
- put?: never;
- post?: never;
- delete?: never;
- options?: never;
- head?: never;
- patch?: never;
- trace?: never;
+ "/profiles": {
+ parameters: {
+ query?: never;
+ header?: never;
+ path?: never;
+ cookie?: never;
};
- "/item": {
- parameters: {
- query?: never;
- header?: never;
- path?: never;
- cookie?: never;
- };
- /** Get item names for item ids */
- get: operations["getItemNames"];
- put?: never;
- post?: never;
- delete?: never;
- options?: never;
- head?: never;
- patch?: never;
- trace?: never;
+ /** List all profiles and players known to ledger */
+ get: operations["listProfiles"];
+ put?: never;
+ post?: never;
+ delete?: never;
+ options?: never;
+ head?: never;
+ patch?: never;
+ trace?: never;
+ };
+ "/item": {
+ parameters: {
+ query?: never;
+ header?: never;
+ path?: never;
+ cookie?: never;
};
+ /** Get item names for item ids */
+ get: operations["getItemNames"];
+ put?: never;
+ post?: never;
+ delete?: never;
+ options?: never;
+ head?: never;
+ patch?: never;
+ trace?: never;
+ };
}
export type webhooks = Record<string, never>;
export interface components {
- schemas: never;
- responses: never;
- parameters: never;
- requestBodies: never;
- headers: never;
- pathItems: never;
+ schemas: never;
+ responses: never;
+ parameters: never;
+ requestBodies: never;
+ headers: never;
+ pathItems: never;
}
export type $defs = Record<string, never>;
export interface operations {
- listProfiles: {
- parameters: {
- query?: never;
- header?: never;
- path?: never;
- cookie?: never;
+ listProfiles: {
+ parameters: {
+ query?: never;
+ header?: never;
+ path?: never;
+ cookie?: never;
+ };
+ requestBody?: never;
+ responses: {
+ 200: {
+ headers: {
+ [name: string]: unknown;
};
- requestBody?: never;
- responses: {
- 200: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- playerId: string;
- profileId: string;
- }[];
- };
- };
+ content: {
+ "application/json": {
+ playerId: string;
+ profileId: string;
+ }[];
};
+ };
+ };
+ };
+ getItemNames: {
+ parameters: {
+ query?: {
+ itemId?: string[];
+ };
+ header?: never;
+ path?: never;
+ cookie?: never;
};
- getItemNames: {
- parameters: {
- query?: {
- itemId?: string[];
- };
- header?: never;
- path?: never;
- cookie?: never;
+ requestBody?: never;
+ responses: {
+ 200: {
+ headers: {
+ [name: string]: unknown;
};
- requestBody?: never;
- responses: {
- 200: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- [key: string]: string;
- };
- };
- };
+ content: {
+ "application/json": {
+ [key: string]: string;
+ };
};
+ };
};
+ };
}
diff --git a/server/frontend/src/api.ts b/server/frontend/src/api.ts
index 00273ec..22cf6ca 100644
--- a/server/frontend/src/api.ts
+++ b/server/frontend/src/api.ts
@@ -1,6 +1,6 @@
import createClient from "openapi-fetch";
-import type {paths} from "./api-schema.js";
+import type { paths } from "./api-schema.js";
const apiRoot = import.meta.env.DEV ? "//localhost:8080/api" : "/api";
-export const client = createClient<paths>({baseUrl: apiRoot}); \ No newline at end of file
+export const client = createClient<paths>({ baseUrl: apiRoot });
diff --git a/server/frontend/src/index.tsx b/server/frontend/src/index.tsx
index 023872c..6ab7d4e 100644
--- a/server/frontend/src/index.tsx
+++ b/server/frontend/src/index.tsx
@@ -1,21 +1,21 @@
/* @refresh reload */
-import {render} from "solid-js/web";
+import { render } from "solid-js/web";
import "./index.css";
-import type {RouteDefinition} from "@solidjs/router";
-import {Router} from "@solidjs/router";
-import {lazy} from "solid-js";
+import type { RouteDefinition } from "@solidjs/router";
+import { Router } from "@solidjs/router";
+import { lazy } from "solid-js";
const root = document.getElementById("root");
if (!(root instanceof HTMLElement)) {
- throw new Error(
- "Root element not found. Did you forget to add it to your index.html? Or maybe the id attribute got misspelled?"
- );
+ throw new Error(
+ "Root element not found. Did you forget to add it to your index.html? Or maybe the id attribute got misspelled?"
+ );
}
const routes: Array<RouteDefinition> = [
- {path: '/', component: lazy(() => import("./App.tsx"))},
- {path: "/test/", component: lazy(() => import("./Test.tsx"))}
-]
+ { path: "/", component: lazy(() => import("./App.tsx")) },
+ { path: "/test/", component: lazy(() => import("./Test.tsx")) },
+];
render(() => <Router>{routes}</Router>, root!);