diff --git a/frontend/src/routes/index.tsx b/frontend/src/routes/index.tsx index 173b786..30fe0b5 100644 --- a/frontend/src/routes/index.tsx +++ b/frontend/src/routes/index.tsx @@ -1,48 +1,51 @@ // src/routes/index.tsx -import * as fs from 'node:fs' -import { createFileRoute, useRouter } from '@tanstack/react-router' -import { createServerFn } from '@tanstack/react-start' +import * as fs from "node:fs"; +import { createFileRoute, useRouter } from "@tanstack/react-router"; +import { createServerFn } from "@tanstack/react-start"; -const filePath = 'count.txt' +const filePath = "count.txt"; async function readCount() { - return parseInt( - await fs.promises.readFile(filePath, 'utf-8').catch(() => '0'), - ) + return parseInt( + await fs.promises.readFile(filePath, "utf-8").catch(() => "0") + ); } const getCount = createServerFn({ - method: 'GET', + method: "GET", }).handler(() => { - return readCount() -}) + return readCount(); +}); -const updateCount = createServerFn({ method: 'POST' }) - .validator((d: number) => d) - .handler(async ({ data }) => { - const count = await readCount() - await fs.promises.writeFile(filePath, `${count + data}`) - }) +const updateCount = createServerFn({ method: "POST" }) + .validator((d: number) => d) + .handler(async ({ data }) => { + const count = await readCount(); + await fs.promises.writeFile(filePath, `${count + data}`); + }); -export const Route = createFileRoute('/')({ - component: Home, - loader: async () => await getCount(), -}) +export const Route = createFileRoute("/")({ + component: Home, + loader: async () => await getCount(), +}); function Home() { - const router = useRouter() - const state = Route.useLoaderData() + const router = useRouter(); + const state = Route.useLoaderData(); - return ( - - ) -} \ No newline at end of file + return ( +
This is just something to put in here
+ +