add
This commit is contained in:
parent
54c8fa6bf2
commit
2ea9522940
|
@ -1,50 +1,50 @@
|
||||||
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 { trpcServer } from '@hono/trpc-server'
|
import { trpcServer } from '@hono/trpc-server';
|
||||||
import { appRouter } from './trpc'
|
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';
|
||||||
type Env = {
|
type Env = {
|
||||||
Variables: {
|
Variables: {
|
||||||
redis: Redis
|
redis: Redis;
|
||||||
minio: Client
|
minio: Client;
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
const app = new Hono<Env>()
|
const app = new Hono<Env>();
|
||||||
|
|
||||||
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);
|
||||||
await next()
|
await next();
|
||||||
})
|
|
||||||
app.use('*', async (c, next) => {
|
|
||||||
c.set('redis', redis);
|
|
||||||
await next();
|
|
||||||
});
|
});
|
||||||
app.use(contextStorage())
|
app.use('*', async (c, next) => {
|
||||||
app.use(prettyJSON()) // With options: prettyJSON({ space: 4 })
|
c.set('redis', redis);
|
||||||
app.use(logger())
|
await next();
|
||||||
|
});
|
||||||
|
app.use(contextStorage());
|
||||||
|
app.use(prettyJSON()); // With options: prettyJSON({ space: 4 })
|
||||||
|
app.use(logger());
|
||||||
app.use(
|
app.use(
|
||||||
'/trpc/*',
|
'/trpc/*',
|
||||||
trpcServer({
|
trpcServer({
|
||||||
router: appRouter,
|
router: appRouter,
|
||||||
})
|
}),
|
||||||
)
|
);
|
||||||
|
|
||||||
app.get('/', (c) => {
|
app.get('/', (c) => {
|
||||||
return c.text('Hello Hono!')
|
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);
|
||||||
// return void 也可以
|
// return void 也可以
|
||||||
return
|
return;
|
||||||
})
|
});
|
||||||
export default app
|
export default app;
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { router } from './trpc';
|
||||||
|
import { userRouter } from './user/user.trpc';
|
||||||
|
|
||||||
|
export const appRouter = router({
|
||||||
|
user: userRouter,
|
||||||
|
});
|
||||||
|
|
||||||
|
export type AppRouter = typeof appRouter;
|
|
@ -1,14 +1,6 @@
|
||||||
import { z } from 'zod'
|
import { initTRPC } from '@trpc/server';
|
||||||
import { initTRPC } from '@trpc/server'
|
|
||||||
import { userRouter } from './user/user.trpc'
|
|
||||||
|
|
||||||
const t = initTRPC.create()
|
const t = initTRPC.create();
|
||||||
|
|
||||||
export const publicProcedure = t.procedure
|
export const publicProcedure = t.procedure;
|
||||||
export const router = t.router
|
export const router = t.router;
|
||||||
|
|
||||||
export const appRouter = router({
|
|
||||||
user: userRouter
|
|
||||||
})
|
|
||||||
|
|
||||||
export type AppRouter = typeof appRouter
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": "@repo/typescript-config/hono.json",
|
"extends": "@repo/typescript-config/hono.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./*"],
|
"@/*": ["./*"],
|
||||||
"@repo/db/*": ["../../packages/db/src/*"],
|
"@repo/db/*": ["../../packages/db/src/*"]
|
||||||
},
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import { useTRPC } from '@repo/client';
|
||||||
|
|
||||||
// import { api } from '@repo/client';
|
// import { api } from '@repo/client';
|
||||||
// import { Button } from '@repo/ui/components/button';
|
// import { Button } from '@repo/ui/components/button';
|
||||||
// import { useState } from 'react';
|
// import { useState } from 'react';
|
||||||
|
|
|
@ -2,17 +2,20 @@
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { ThemeProvider as NextThemesProvider } from 'next-themes';
|
import { ThemeProvider as NextThemesProvider } from 'next-themes';
|
||||||
|
import QueryProvider from '@/providers/query-provider';
|
||||||
|
|
||||||
export function Providers({ children }: { children: React.ReactNode }) {
|
export function Providers({ children }: { children: React.ReactNode }) {
|
||||||
return (
|
return (
|
||||||
<NextThemesProvider
|
<QueryProvider>
|
||||||
attribute="class"
|
<NextThemesProvider
|
||||||
defaultTheme="system"
|
attribute="class"
|
||||||
enableSystem
|
defaultTheme="system"
|
||||||
disableTransitionOnChange
|
enableSystem
|
||||||
enableColorScheme
|
disableTransitionOnChange
|
||||||
>
|
enableColorScheme
|
||||||
{children}
|
>
|
||||||
</NextThemesProvider>
|
{children}
|
||||||
|
</NextThemesProvider>
|
||||||
|
</QueryProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
services:
|
services:
|
||||||
minio:
|
minio:
|
||||||
image: minio/minio:${MINIO_VERSION:-RELEASE.2024-04-22T22-12-26Z}
|
image: minio/minio:${MINIO_VERSION:-RELEASE.2024-04-18T19-09-19Z}
|
||||||
container_name: minio
|
container_name: minio
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "9000:9000"
|
- '9000:9000'
|
||||||
- "9001:9001"
|
- '9001:9001'
|
||||||
networks:
|
networks:
|
||||||
- nice-net
|
- nice-net
|
||||||
environment:
|
environment:
|
||||||
|
@ -17,7 +17,7 @@ services:
|
||||||
target: /data
|
target: /data
|
||||||
command: server /data --console-address ":9001"
|
command: server /data --console-address ":9001"
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
test: ['CMD', 'curl', '-f', 'http://localhost:9000/minio/health/live']
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 20s
|
timeout: 20s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { api } from '../trpc';
|
|
||||||
|
|
||||||
export function useHello() {
|
export function useHello() {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue