|
@@ -8,6 +8,11 @@ import { AuthContext } from './types/context'
|
|
|
import { AppDataSource } from './data-source'
|
|
import { AppDataSource } from './data-source'
|
|
|
import { Hono } from 'hono'
|
|
import { Hono } from 'hono'
|
|
|
|
|
|
|
|
|
|
+if(!AppDataSource.isInitialized) {
|
|
|
|
|
+ await AppDataSource.initialize();
|
|
|
|
|
+ console.log('数据库初始化完成')
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const app = new Hono();
|
|
const app = new Hono();
|
|
|
const api = new OpenAPIHono<AuthContext>()
|
|
const api = new OpenAPIHono<AuthContext>()
|
|
|
|
|
|
|
@@ -20,13 +25,10 @@ api.use('/api/v1/*', async (c, next) => {
|
|
|
await next()
|
|
await next()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-// 数据库初始化中间件
|
|
|
|
|
-api.use('/api/v1/*', async (c, next) => {
|
|
|
|
|
- if(!AppDataSource.isInitialized) {
|
|
|
|
|
- await AppDataSource.initialize();
|
|
|
|
|
- }
|
|
|
|
|
- await next();
|
|
|
|
|
-})
|
|
|
|
|
|
|
+// // 数据库初始化中间件
|
|
|
|
|
+// api.use('/api/v1/*', async (c, next) => {
|
|
|
|
|
+// await next();
|
|
|
|
|
+// })
|
|
|
|
|
|
|
|
// 注册Bearer认证方案
|
|
// 注册Bearer认证方案
|
|
|
api.openAPIRegistry.registerComponent('securitySchemes','bearerAuth',{
|
|
api.openAPIRegistry.registerComponent('securitySchemes','bearerAuth',{
|