feat: 注册认证/笔记/评论路由到 Hono app
This commit is contained in:
parent
2e3517ead5
commit
c3958d7091
@ -5,6 +5,11 @@ import { cors } from 'hono/cors'
|
|||||||
import Anthropic from '@anthropic-ai/sdk'
|
import Anthropic from '@anthropic-ai/sdk'
|
||||||
import fs from 'node:fs'
|
import fs from 'node:fs'
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
|
import { initDb } from './db'
|
||||||
|
import { authRouter } from './routes/auth'
|
||||||
|
import { notesRouter } from './routes/notes'
|
||||||
|
import { foldersRouter } from './routes/folders'
|
||||||
|
import { commentsRouter } from './routes/comments'
|
||||||
|
|
||||||
const app = new Hono()
|
const app = new Hono()
|
||||||
app.use('*', cors())
|
app.use('*', cors())
|
||||||
@ -58,6 +63,11 @@ function getActiveModel(): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ── Model CRUD endpoints ──────────────────────────────────────────────────────
|
// ── Model CRUD endpoints ──────────────────────────────────────────────────────
|
||||||
|
app.route('/api/auth', authRouter)
|
||||||
|
app.route('/api/notes', notesRouter)
|
||||||
|
app.route('/api/folders', foldersRouter)
|
||||||
|
app.route('/api/comments', commentsRouter)
|
||||||
|
|
||||||
app.get('/api/models', (c) => {
|
app.get('/api/models', (c) => {
|
||||||
const models = readModels()
|
const models = readModels()
|
||||||
// strip apiKey from response for security
|
// strip apiKey from response for security
|
||||||
@ -191,6 +201,8 @@ app.post('/api/ai/stream', async (c) => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
initDb()
|
||||||
|
|
||||||
serve({ fetch: app.fetch, port: 3001 }, () => {
|
serve({ fetch: app.fetch, port: 3001 }, () => {
|
||||||
console.log('AI proxy server running on http://localhost:3001')
|
console.log('AI proxy server running on http://localhost:3001')
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user