Merge branch 'main' of http://113.45.67.59:3003/insiinc/nice
This commit is contained in:
commit
49f06dce50
|
@ -0,0 +1,15 @@
|
|||
ELASTICSEARCH_NODE=http://localhost:9200
|
||||
ELASTICSEARCH_USER=elastic
|
||||
ELASTICSEARCH_PASSWORD=changeme
|
||||
MINIO_ENDPOINT=localhost
|
||||
MINIO_PORT=9000
|
||||
MINIO_USE_SSL=false
|
||||
MINIO_ACCESS_KEY=minioadmin
|
||||
MINIO_SECRET_KEY=minioadmin
|
||||
REDIS_PASSWORD=nice
|
||||
|
||||
|
||||
# OIDC_COOKIE_KEY=
|
||||
OIDC_CLIENT_ID=your-client-id
|
||||
OIDC_CLIENT_SECRET=your-client-secret
|
||||
OIDC_REDIRECT_URI=https://your-frontend.com/callback
|
|
@ -17,6 +17,7 @@
|
|||
"nanoid": "^5.1.5",
|
||||
"node-cron": "^4.0.7",
|
||||
"oidc-provider": "^9.1.1",
|
||||
"superjson": "^2.2.2",
|
||||
"zod": "^3.25.23"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
import { Hono } from 'hono';
|
||||
import { logger } from 'hono/logger';
|
||||
import { contextStorage, getContext } from 'hono/context-storage';
|
||||
import { prettyJSON } from 'hono/pretty-json';
|
||||
import { Hono } from 'hono'
|
||||
import { logger } from 'hono/logger'
|
||||
import { contextStorage, getContext } from 'hono/context-storage'
|
||||
import { prettyJSON } from 'hono/pretty-json'
|
||||
import { cors } from 'hono/cors'
|
||||
|
||||
import { trpcServer } from '@hono/trpc-server';
|
||||
import { appRouter } from './router';
|
||||
import Redis from 'ioredis';
|
||||
import redis from './redis';
|
||||
import minioClient from './minio';
|
||||
import { Client } from 'minio';
|
||||
import oidc from './oidc/provider';
|
||||
import { trpcServer } from '@hono/trpc-server'
|
||||
|
||||
import Redis from 'ioredis'
|
||||
import redis from './redis'
|
||||
import minioClient from './minio'
|
||||
import { Client } from 'minio'
|
||||
import oidc from './oidc/provider'
|
||||
import { appRouter } from './trpc'
|
||||
type Env = {
|
||||
Variables: {
|
||||
redis: Redis;
|
||||
|
@ -19,6 +21,11 @@ type Env = {
|
|||
|
||||
const app = new Hono<Env>();
|
||||
|
||||
app.use('*', cors({
|
||||
origin: 'http://localhost:3001',
|
||||
credentials: true,
|
||||
}))
|
||||
|
||||
app.use('*', async (c, next) => {
|
||||
c.set('redis', redis);
|
||||
c.set('minio', minioClient);
|
||||
|
@ -38,9 +45,6 @@ app.use(
|
|||
}),
|
||||
);
|
||||
|
||||
app.get('/', (c) => {
|
||||
return c.text('Hello Hono!');
|
||||
});
|
||||
app.use('/oidc/*', async (c, next) => {
|
||||
// @ts-ignore
|
||||
await oidc.callback(c.req.raw, c.res.raw);
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
import { initTRPC } from '@trpc/server';
|
||||
|
||||
const t = initTRPC.create();
|
||||
|
||||
export const publicProcedure = t.procedure;
|
||||
export const router = t.router;
|
|
@ -0,0 +1,9 @@
|
|||
import { initTRPC } from '@trpc/server'
|
||||
import superjson from 'superjson'
|
||||
const t = initTRPC.create({
|
||||
transformer: superjson,
|
||||
})
|
||||
|
||||
export const publicProcedure = t.procedure
|
||||
export const router = t.router
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
import { userRouter } from "../user/user.trpc"
|
||||
import { router } from "./base"
|
||||
|
||||
export const appRouter = router({
|
||||
user: userRouter
|
||||
})
|
||||
|
||||
export type AppRouter = typeof appRouter
|
|
@ -1,7 +1,8 @@
|
|||
import { publicProcedure, router } from "../trpc";
|
||||
import { prisma } from "@repo/db";
|
||||
import { publicProcedure, router } from "../trpc/base"
|
||||
|
||||
export const userRouter = router({
|
||||
getUser: publicProcedure.query(async ({ ctx }) => {
|
||||
return prisma.user.findMany()
|
||||
|
||||
return '123'
|
||||
})
|
||||
})
|
|
@ -0,0 +1 @@
|
|||
DATABASE_URL="postgresql://root:Letusdoit000@localhost:5432/app?schema=public"
|
|
@ -1,20 +1,8 @@
|
|||
import { Geist, Geist_Mono } from 'next/font/google';
|
||||
|
||||
import '@repo/ui/globals.css';
|
||||
|
||||
import { Providers } from '@/components/providers';
|
||||
import type { Metadata } from 'next';
|
||||
|
||||
const fontSans = Geist({
|
||||
subsets: ['latin'],
|
||||
variable: '--font-sans',
|
||||
});
|
||||
|
||||
const fontMono = Geist_Mono({
|
||||
subsets: ['latin'],
|
||||
variable: '--font-mono',
|
||||
});
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Create Next App',
|
||||
description: 'Generated by create next app',
|
||||
|
@ -27,7 +15,7 @@ export default function RootLayout({
|
|||
}>) {
|
||||
return (
|
||||
<html lang="en" suppressHydrationWarning>
|
||||
<body className={`${fontSans.variable} ${fontMono.variable} font-sans antialiased `}>
|
||||
<body className={`font-sans antialiased `}>
|
||||
<Providers>{children}</Providers>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,49 +1,13 @@
|
|||
'use client';
|
||||
|
||||
import { useTRPC } from '@repo/client';
|
||||
|
||||
// import { api } from '@repo/client';
|
||||
// import { Button } from '@repo/ui/components/button';
|
||||
// import { useState } from 'react';
|
||||
// import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
// import { httpBatchLink } from '@trpc/client';
|
||||
|
||||
// function HomeContent() {
|
||||
// const [name, setName] = useState('');
|
||||
// const helloQuery = api.hello.useQuery(name || undefined);
|
||||
|
||||
// return (
|
||||
// <div className="p-4">
|
||||
// <input
|
||||
// type="text"
|
||||
// value={name}
|
||||
// onChange={(e) => setName(e.target.value)}
|
||||
// placeholder="输入名字"
|
||||
// className="border p-2 mr-2"
|
||||
// />
|
||||
// <Button onClick={() => helloQuery.refetch()}>{helloQuery.isLoading ? '加载中...' : helloQuery.data}</Button>
|
||||
// </div>
|
||||
// );
|
||||
// }
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
export default function Home() {
|
||||
// const [queryClient] = useState(() => new QueryClient());
|
||||
// const [trpcClient] = useState(() =>
|
||||
// api.createClient({
|
||||
// links: [
|
||||
// httpBatchLink({
|
||||
// url: 'http://localhost:3000/api/trpc',
|
||||
// }),
|
||||
// ],
|
||||
// }),
|
||||
// );
|
||||
|
||||
return (
|
||||
<div>123</div>
|
||||
// <QueryClientProvider client={queryClient}>
|
||||
// <api.Provider client={trpcClient} queryClient={queryClient}>
|
||||
// <HomeContent />
|
||||
// </api.Provider>
|
||||
// </QueryClientProvider>
|
||||
);
|
||||
const trpc = useTRPC();
|
||||
const { data, isLoading } = useQuery(trpc.user.getUser.queryOptions());
|
||||
useEffect(() => {
|
||||
console.log(data);
|
||||
}, [data]);
|
||||
return <div>123</div>;
|
||||
}
|
||||
|
|
|
@ -6,16 +6,14 @@ import QueryProvider from '@/providers/query-provider';
|
|||
|
||||
export function Providers({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<QueryProvider>
|
||||
<NextThemesProvider
|
||||
attribute="class"
|
||||
defaultTheme="system"
|
||||
enableSystem
|
||||
disableTransitionOnChange
|
||||
enableColorScheme
|
||||
>
|
||||
{children}
|
||||
</NextThemesProvider>
|
||||
</QueryProvider>
|
||||
<NextThemesProvider
|
||||
attribute="class"
|
||||
defaultTheme="system"
|
||||
enableSystem
|
||||
disableTransitionOnChange
|
||||
enableColorScheme
|
||||
>
|
||||
<QueryProvider>{children}</QueryProvider>
|
||||
</NextThemesProvider>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import { loggerLink, httpBatchLink, createTRPCClient } from '@trpc/client';
|
|||
import { TRPCProvider } from '@repo/client';
|
||||
import { useMemo, useState } from 'react';
|
||||
import superjson from 'superjson';
|
||||
import { AppRouter } from '@repo/backend/trpc';
|
||||
import { AppRouter } from '@repo/backend/trpc/index';
|
||||
|
||||
export default function QueryProvider({ children }) {
|
||||
// 将accessToken设置为空字符串
|
||||
|
|
|
@ -9,13 +9,6 @@
|
|||
"dist",
|
||||
"src"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"dev": "tsup --watch",
|
||||
"dev-static": "tsup --no-watch",
|
||||
"clean": "rimraf dist",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
},
|
||||
|
@ -30,7 +23,6 @@
|
|||
"axios": "^1.7.2",
|
||||
"dayjs": "^1.11.12",
|
||||
"react": "^19.1.0"
|
||||
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^6.0.1",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { AppRouter } from '@repo/backend/trpc';
|
||||
import { inferReactQueryProcedureOptions } from '@trpc/react-query';
|
||||
import { inferRouterInputs, inferRouterOutputs } from '@trpc/server';
|
||||
import { AppRouter } from "@repo/backend/trpc/index"
|
||||
import { inferReactQueryProcedureOptions } from "@trpc/react-query";
|
||||
import { inferRouterInputs, inferRouterOutputs } from "@trpc/server";
|
||||
import { createTRPCContext } from '@trpc/tanstack-react-query';
|
||||
export type ReactQueryOptions = inferReactQueryProcedureOptions<AppRouter>;
|
||||
export type RouterInputs = inferRouterInputs<AppRouter>;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { QueryClient } from "@tanstack/react-query";
|
||||
import { getQueryKey } from "@trpc/react-query";
|
||||
import { useTRPC } from "./trpc";
|
||||
|
||||
/**
|
||||
* 根据查询客户端缓存生成唯一数据列表的函数。
|
||||
|
|
|
@ -68,6 +68,9 @@ importers:
|
|||
oidc-provider:
|
||||
specifier: ^9.1.1
|
||||
version: 9.1.1
|
||||
superjson:
|
||||
specifier: ^2.2.2
|
||||
version: 2.2.2
|
||||
zod:
|
||||
specifier: ^3.25.23
|
||||
version: 3.25.23
|
||||
|
|
Loading…
Reference in New Issue