diff --git a/compose.yaml b/compose.yaml index 057ef8e..8c41ccd 100644 --- a/compose.yaml +++ b/compose.yaml @@ -23,8 +23,6 @@ services: db: image: postgres:18-alpine - # ports: - # - "5432:5432" volumes: - postgres_data:/var/lib/postgresql environment: diff --git a/public/robots.txt b/public/robots.txt index e9e57dc..eb05362 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,3 +1,2 @@ -# https://www.robotstxt.org/robotstxt.html User-agent: * Disallow: diff --git a/src/client/orpc.ts b/src/client/orpc.ts index 6b9abab..7bea292 100644 --- a/src/client/orpc.ts +++ b/src/client/orpc.ts @@ -24,30 +24,4 @@ const getORPCClient = createIsomorphicFn() const client: RouterClient = getORPCClient() -export const orpc = createTanstackQueryUtils(client, { - experimental_defaults: { - todo: { - create: { - mutationOptions: { - onSuccess: (_, __, ___, ctx) => { - ctx.client.invalidateQueries({ queryKey: orpc.todo.list.key() }) - }, - }, - }, - update: { - mutationOptions: { - onSuccess: (_, __, ___, ctx) => { - ctx.client.invalidateQueries({ queryKey: orpc.todo.list.key() }) - }, - }, - }, - remove: { - mutationOptions: { - onSuccess: (_, __, ___, ctx) => { - ctx.client.invalidateQueries({ queryKey: orpc.todo.list.key() }) - }, - }, - }, - }, - }, -}) +export const orpc = createTanstackQueryUtils(client) diff --git a/src/client/queries/todo.ts b/src/client/queries/todo.ts new file mode 100644 index 0000000..c02a71b --- /dev/null +++ b/src/client/queries/todo.ts @@ -0,0 +1,7 @@ +import { useQueryClient } from '@tanstack/react-query' +import { orpc } from '@/client/orpc' + +export const useInvalidateTodos = () => { + const queryClient = useQueryClient() + return () => queryClient.invalidateQueries({ queryKey: orpc.todo.list.key() }) +} diff --git a/src/env.ts b/src/env.ts index e8825d9..c2a89c6 100644 --- a/src/env.ts +++ b/src/env.ts @@ -6,9 +6,7 @@ export const env = createEnv({ DATABASE_URL: z.url(), }, clientPrefix: 'VITE_', - client: { - VITE_APP_TITLE: z.string().min(1).optional(), - }, + client: {}, runtimeEnv: process.env, emptyStringAsUndefined: true, }) diff --git a/src/routes/__root.tsx b/src/routes/__root.tsx index 5dea9b1..a26a840 100644 --- a/src/routes/__root.tsx +++ b/src/routes/__root.tsx @@ -4,6 +4,7 @@ import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools' import { createRootRouteWithContext, HeadContent, Scripts } from '@tanstack/react-router' import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools' import type { ReactNode } from 'react' +import { name } from '@/../package.json' import { ErrorComponent } from '@/components/Error' import { NotFoundComponent } from '@/components/NotFound' import appCss from '@/styles.css?url' @@ -23,7 +24,7 @@ export const Route = createRootRouteWithContext()({ content: 'width=device-width, initial-scale=1', }, { - title: 'Furtherverse', + title: name, }, ], links: [ diff --git a/src/routes/index.tsx b/src/routes/index.tsx index d3d052e..bc7fc53 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -1,6 +1,7 @@ import { useMutation, useSuspenseQuery } from '@tanstack/react-query' import { createFileRoute } from '@tanstack/react-router' import { orpc } from '@/client/orpc' +import { useInvalidateTodos } from '@/client/queries/todo' import { TodoForm } from '@/components/TodoForm' import { TodoItem } from '@/components/TodoItem' @@ -13,9 +14,11 @@ export const Route = createFileRoute('/')({ function Todos() { const listQuery = useSuspenseQuery(orpc.todo.list.queryOptions()) - const createMutation = useMutation(orpc.todo.create.mutationOptions()) - const updateMutation = useMutation(orpc.todo.update.mutationOptions()) - const deleteMutation = useMutation(orpc.todo.remove.mutationOptions()) + const invalidateTodos = useInvalidateTodos() + + const createMutation = useMutation(orpc.todo.create.mutationOptions({ onSuccess: invalidateTodos })) + const updateMutation = useMutation(orpc.todo.update.mutationOptions({ onSuccess: invalidateTodos })) + const deleteMutation = useMutation(orpc.todo.remove.mutationOptions({ onSuccess: invalidateTodos })) const todos = listQuery.data const completedCount = todos.filter((todo) => todo.completed).length @@ -25,7 +28,6 @@ function Todos() { return (
- {/* Header */}

ζˆ‘ηš„εΎ…εŠž

@@ -42,7 +44,6 @@ function Todos() { createMutation.mutate({ title })} isPending={createMutation.isPending} /> - {/* Progress Bar */} {totalCount > 0 && (
)} - {/* Todo List */}
{todos.length === 0 ? (
diff --git a/src/server/db/index.ts b/src/server/db/index.ts index 14db5da..7635f26 100644 --- a/src/server/db/index.ts +++ b/src/server/db/index.ts @@ -6,5 +6,3 @@ export const db = drizzle({ connection: env.DATABASE_URL, schema, }) - -export type DB = typeof db diff --git a/src/server/plugins/shutdown.ts b/src/server/plugins/shutdown.ts index b402e5a..1f54272 100644 --- a/src/server/plugins/shutdown.ts +++ b/src/server/plugins/shutdown.ts @@ -5,15 +5,14 @@ export default () => { let exiting = false - const shutdown = async () => { + const shutdown = () => { if (exiting) { process.exit(0) } exiting = true - setTimeout(async () => { - await db.$client.end() - process.exit(0) + setTimeout(() => { + db.$client.end().finally(() => process.exit(0)) }, 500) }