Skip to content

🎬 火宝短剧 - 基于AI的一站式短剧生成平台 《一句话生成完整短剧,从剧本到成片全自动化》 Huobao Drama - An AI-Powered End-to-End Short Drama Generator "One Sentence to Complete Drama: Fully Automated from Script to Final Video"

TypeScript

fix: normalize all API responses to snake_case

Connore6c1516d337b
diff --git a/backend/src/routes/dramas.ts b/backend/src/routes/dramas.ts
index 6f1488d..fd266c9 100644
--- a/backend/src/routes/dramas.ts
+++ b/backend/src/routes/dramas.ts
@@ -1,7 +1,8 @@
import { Hono } from 'hono'
import { eq, isNull, like, desc } from 'drizzle-orm'
-import { db, schema } from '../db'
-import { success, badRequest, notFound, created, now } from '../utils/response'
+import { db, schema } from '../db/index.js'
+import { success, badRequest, notFound, created, now } from '../utils/response.js'
+import { toSnakeCase, toSnakeCaseArray } from '../utils/transform.js'
const app = new Hono()
@@ -32,12 +33,12 @@ app.get('/', async (c) => {
const scns = await db.select().from(schema.scenes)
.where(eq(schema.scenes.dramaId, drama.id))
return {
- ...drama,
+ ...toSnakeCase(drama),
tags: drama.tags ? JSON.parse(drama.tags) : [],
total_episodes: eps.length,
- episodes: eps,
- characters: chars,
- scenes: scns,
+ episodes: toSnakeCaseArray(eps),
+ characters: toSnakeCaseArray(chars),
+ scenes: toSnakeCaseArray(scns),
}
}))
@@ -79,9 +80,10 @@ app.post('/', async (c) => {
}).run()
}
- return created(c, result)
+ return created(c, toSnakeCase(result))
})
+
// GET /dramas/stats — must be before /:id
app.get('/stats', async (c) => {
const all = db.select().from(schema.dramas).where(isNull(schema.dramas.deletedAt)).all()
@@ -110,12 +112,12 @@ app.get('/:id', async (c) => {
.where(eq(schema.props.dramaId, id))
return success(c, {
- ...drama,
+ ...toSnakeCase(drama),
tags: drama.tags ? JSON.parse(drama.tags) : [],
- episodes: eps,
- characters: chars,
- scenes: scns,
- props: prps,
+ episodes: toSnakeCaseArray(eps),
+ characters: toSnakeCaseArray(chars),
+ scenes: toSnakeCaseArray(scns),
+ props: toSnakeCaseArray(prps),
})
})
diff --git a/backend/src/routes/episodes.ts b/backend/src/routes/episodes.ts
index 853ee8d..bf4e9b8 100644
--- a/backend/src/routes/episodes.ts
+++ b/backend/src/routes/episodes.ts
@@ -1,7 +1,8 @@
import { Hono } from 'hono'
import { eq } from 'drizzle-orm'
-import { db, schema } from '../db'
-import { success, notFound, badRequest, now } from '../utils/response'
+import { db, schema } from '../db/index.js'
+import { success, notFound, badRequest, now } from '../utils/response.js'
+import { toSnakeCaseArray } from '../utils/transform.js'
const app = new Hono()
@@ -35,7 +36,7 @@ app.get('/:episode_id/storyboards', async (c) => {
const rows = await db.select().from(schema.storyboards)
.where(eq(schema.storyboards.episodeId, episodeId))
.orderBy(schema.storyboards.storyboardNumber)
- return success(c, rows)
+ return success(c, toSnakeCaseArray(rows))
})
// GET /episodes/:id/pipeline-status — 流水线进度
diff --git a/backend/src/routes/storyboards.ts b/backend/src/routes/storyboards.ts
index ea3a448..8c94753 100644
--- a/backend/src/routes/storyboards.ts
+++ b/backend/src/routes/storyboards.ts
@@ -2,6 +2,7 @@ import { Hono } from 'hono'
import { eq } from 'drizzle-orm'
import { db, schema } from '../db/index.js'
import { success, created, now } from '../utils/response.js'
+import { toSnakeCase } from '../utils/transform.js'
const app = new Hono()
@@ -23,7 +24,7 @@ app.post('/', async (c) => {
}).run()
const [result] = db.select().from(schema.storyboards)
.where(eq(schema.storyboards.id, Number(res.lastInsertRowid))).all()
- return created(c, result)
+ return created(c, toSnakeCase(result))
})
// PUT /storyboards/:id