增加socketio 路由 支持

This commit is contained in:
yourname
2025-05-15 08:40:09 +00:00
parent b879ad4f7c
commit dea7ec5316
8 changed files with 350 additions and 58 deletions

View File

@@ -2,6 +2,7 @@
import { Hono } from 'hono'
import { corsMiddleware, withAuth, setEnvVariables } from './middlewares.ts'
import type { APIClient } from '@d8d-appcontainer/api'
import { Auth } from '@d8d-appcontainer/auth';
// 导入路由模块
import { createAuthRoutes } from "./routes_auth.ts"
@@ -17,7 +18,7 @@ import { createMessagesRoutes } from "./routes_messages.ts"
import { createMigrationsRoutes } from "./routes_migrations.ts"
import { createHomeRoutes } from "./routes_home.ts"
export function createRouter(apiClient: APIClient, moduleDir: string) {
export function createRouter(apiClient: APIClient, moduleDir: string , auth: Auth) {
const router = new Hono()
// 添加CORS中间件
@@ -27,7 +28,7 @@ export function createRouter(apiClient: APIClient, moduleDir: string) {
const api = new Hono()
// 设置环境变量
api.use('*', setEnvVariables(apiClient, moduleDir))
api.use('*', setEnvVariables(apiClient, moduleDir, auth))
// 注册所有路由
api.route('/auth', createAuthRoutes(withAuth))