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",
|
"nanoid": "^5.1.5",
|
||||||
"node-cron": "^4.0.7",
|
"node-cron": "^4.0.7",
|
||||||
"oidc-provider": "^9.1.1",
|
"oidc-provider": "^9.1.1",
|
||||||
|
"superjson": "^2.2.2",
|
||||||
"zod": "^3.25.23"
|
"zod": "^3.25.23"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
import { Hono } from 'hono';
|
import { Hono } from 'hono'
|
||||||
import { logger } from 'hono/logger';
|
import { logger } from 'hono/logger'
|
||||||
import { contextStorage, getContext } from 'hono/context-storage';
|
import { contextStorage, getContext } from 'hono/context-storage'
|
||||||
import { prettyJSON } from 'hono/pretty-json';
|
import { prettyJSON } from 'hono/pretty-json'
|
||||||
|
import { cors } from 'hono/cors'
|
||||||
|
|
||||||
import { trpcServer } from '@hono/trpc-server';
|
import { trpcServer } from '@hono/trpc-server'
|
||||||
import { appRouter } from './router';
|
|
||||||
import Redis from 'ioredis';
|
import Redis from 'ioredis'
|
||||||
import redis from './redis';
|
import redis from './redis'
|
||||||
import minioClient from './minio';
|
import minioClient from './minio'
|
||||||
import { Client } from 'minio';
|
import { Client } from 'minio'
|
||||||
import oidc from './oidc/provider';
|
import oidc from './oidc/provider'
|
||||||
|
import { appRouter } from './trpc'
|
||||||
type Env = {
|
type Env = {
|
||||||
Variables: {
|
Variables: {
|
||||||
redis: Redis;
|
redis: Redis;
|
||||||
|
@ -19,6 +21,11 @@ type Env = {
|
||||||
|
|
||||||
const app = new Hono<Env>();
|
const app = new Hono<Env>();
|
||||||
|
|
||||||
|
app.use('*', cors({
|
||||||
|
origin: 'http://localhost:3001',
|
||||||
|
credentials: true,
|
||||||
|
}))
|
||||||
|
|
||||||
app.use('*', async (c, next) => {
|
app.use('*', async (c, next) => {
|
||||||
c.set('redis', redis);
|
c.set('redis', redis);
|
||||||
c.set('minio', minioClient);
|
c.set('minio', minioClient);
|
||||||
|
@ -38,9 +45,6 @@ app.use(
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
app.get('/', (c) => {
|
|
||||||
return c.text('Hello Hono!');
|
|
||||||
});
|
|
||||||
app.use('/oidc/*', async (c, next) => {
|
app.use('/oidc/*', async (c, next) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
await oidc.callback(c.req.raw, c.res.raw);
|
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 { publicProcedure, router } from "../trpc/base"
|
||||||
import { prisma } from "@repo/db";
|
|
||||||
export const userRouter = router({
|
export const userRouter = router({
|
||||||
getUser: publicProcedure.query(async ({ ctx }) => {
|
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 '@repo/ui/globals.css';
|
||||||
|
|
||||||
import { Providers } from '@/components/providers';
|
import { Providers } from '@/components/providers';
|
||||||
import type { Metadata } from 'next';
|
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 = {
|
export const metadata: Metadata = {
|
||||||
title: 'Create Next App',
|
title: 'Create Next App',
|
||||||
description: 'Generated by create next app',
|
description: 'Generated by create next app',
|
||||||
|
@ -27,7 +15,7 @@ export default function RootLayout({
|
||||||
}>) {
|
}>) {
|
||||||
return (
|
return (
|
||||||
<html lang="en" suppressHydrationWarning>
|
<html lang="en" suppressHydrationWarning>
|
||||||
<body className={`${fontSans.variable} ${fontMono.variable} font-sans antialiased `}>
|
<body className={`font-sans antialiased `}>
|
||||||
<Providers>{children}</Providers>
|
<Providers>{children}</Providers>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,49 +1,13 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useTRPC } from '@repo/client';
|
import { useTRPC } from '@repo/client';
|
||||||
|
import { useQuery } from '@tanstack/react-query';
|
||||||
// import { api } from '@repo/client';
|
import { useEffect } from 'react';
|
||||||
// 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>
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
// const [queryClient] = useState(() => new QueryClient());
|
const trpc = useTRPC();
|
||||||
// const [trpcClient] = useState(() =>
|
const { data, isLoading } = useQuery(trpc.user.getUser.queryOptions());
|
||||||
// api.createClient({
|
useEffect(() => {
|
||||||
// links: [
|
console.log(data);
|
||||||
// httpBatchLink({
|
}, [data]);
|
||||||
// url: 'http://localhost:3000/api/trpc',
|
return <div>123</div>;
|
||||||
// }),
|
|
||||||
// ],
|
|
||||||
// }),
|
|
||||||
// );
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>123</div>
|
|
||||||
// <QueryClientProvider client={queryClient}>
|
|
||||||
// <api.Provider client={trpcClient} queryClient={queryClient}>
|
|
||||||
// <HomeContent />
|
|
||||||
// </api.Provider>
|
|
||||||
// </QueryClientProvider>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,16 +6,14 @@ import QueryProvider from '@/providers/query-provider';
|
||||||
|
|
||||||
export function Providers({ children }: { children: React.ReactNode }) {
|
export function Providers({ children }: { children: React.ReactNode }) {
|
||||||
return (
|
return (
|
||||||
<QueryProvider>
|
<NextThemesProvider
|
||||||
<NextThemesProvider
|
attribute="class"
|
||||||
attribute="class"
|
defaultTheme="system"
|
||||||
defaultTheme="system"
|
enableSystem
|
||||||
enableSystem
|
disableTransitionOnChange
|
||||||
disableTransitionOnChange
|
enableColorScheme
|
||||||
enableColorScheme
|
>
|
||||||
>
|
<QueryProvider>{children}</QueryProvider>
|
||||||
{children}
|
</NextThemesProvider>
|
||||||
</NextThemesProvider>
|
|
||||||
</QueryProvider>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { loggerLink, httpBatchLink, createTRPCClient } from '@trpc/client';
|
||||||
import { TRPCProvider } from '@repo/client';
|
import { TRPCProvider } from '@repo/client';
|
||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import superjson from 'superjson';
|
import superjson from 'superjson';
|
||||||
import { AppRouter } from '@repo/backend/trpc';
|
import { AppRouter } from '@repo/backend/trpc/index';
|
||||||
|
|
||||||
export default function QueryProvider({ children }) {
|
export default function QueryProvider({ children }) {
|
||||||
// 将accessToken设置为空字符串
|
// 将accessToken设置为空字符串
|
||||||
|
|
|
@ -9,13 +9,6 @@
|
||||||
"dist",
|
"dist",
|
||||||
"src"
|
"src"
|
||||||
],
|
],
|
||||||
"scripts": {
|
|
||||||
"build": "tsup",
|
|
||||||
"dev": "tsup --watch",
|
|
||||||
"dev-static": "tsup --no-watch",
|
|
||||||
"clean": "rimraf dist",
|
|
||||||
"typecheck": "tsc --noEmit"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -30,7 +23,6 @@
|
||||||
"axios": "^1.7.2",
|
"axios": "^1.7.2",
|
||||||
"dayjs": "^1.11.12",
|
"dayjs": "^1.11.12",
|
||||||
"react": "^19.1.0"
|
"react": "^19.1.0"
|
||||||
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"rimraf": "^6.0.1",
|
"rimraf": "^6.0.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { AppRouter } from '@repo/backend/trpc';
|
import { AppRouter } from "@repo/backend/trpc/index"
|
||||||
import { inferReactQueryProcedureOptions } from '@trpc/react-query';
|
import { inferReactQueryProcedureOptions } from "@trpc/react-query";
|
||||||
import { inferRouterInputs, inferRouterOutputs } from '@trpc/server';
|
import { inferRouterInputs, inferRouterOutputs } from "@trpc/server";
|
||||||
import { createTRPCContext } from '@trpc/tanstack-react-query';
|
import { createTRPCContext } from '@trpc/tanstack-react-query';
|
||||||
export type ReactQueryOptions = inferReactQueryProcedureOptions<AppRouter>;
|
export type ReactQueryOptions = inferReactQueryProcedureOptions<AppRouter>;
|
||||||
export type RouterInputs = inferRouterInputs<AppRouter>;
|
export type RouterInputs = inferRouterInputs<AppRouter>;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { QueryClient } from "@tanstack/react-query";
|
import { QueryClient } from "@tanstack/react-query";
|
||||||
import { getQueryKey } from "@trpc/react-query";
|
import { getQueryKey } from "@trpc/react-query";
|
||||||
|
import { useTRPC } from "./trpc";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据查询客户端缓存生成唯一数据列表的函数。
|
* 根据查询客户端缓存生成唯一数据列表的函数。
|
||||||
|
|
|
@ -68,6 +68,9 @@ importers:
|
||||||
oidc-provider:
|
oidc-provider:
|
||||||
specifier: ^9.1.1
|
specifier: ^9.1.1
|
||||||
version: 9.1.1
|
version: 9.1.1
|
||||||
|
superjson:
|
||||||
|
specifier: ^2.2.2
|
||||||
|
version: 2.2.2
|
||||||
zod:
|
zod:
|
||||||
specifier: ^3.25.23
|
specifier: ^3.25.23
|
||||||
version: 3.25.23
|
version: 3.25.23
|
||||||
|
|
Loading…
Reference in New Issue