Spaces:
Runtime error
Runtime error
Commit
·
16e4326
1
Parent(s):
2cb5570
add a model field
Browse files- src/index.mts +8 -1
- src/types.mts +1 -0
src/index.mts
CHANGED
@@ -45,6 +45,7 @@ app.post("/posts/:appId", async (req, res) => {
|
|
45 |
|
46 |
const postId = `${req.body.postId || uuidv4()}`
|
47 |
const prompt = `${req.body.prompt || ""}`
|
|
|
48 |
const assetUrl = `${req.body.assetUrl || ""}`
|
49 |
const previewUrl = `${req.body.previewUrl || assetUrl}`
|
50 |
const createdAt = `${req.body.createdAt || new Date().toISOString()}`
|
@@ -88,6 +89,7 @@ app.post("/posts/:appId", async (req, res) => {
|
|
88 |
postId,
|
89 |
appId,
|
90 |
prompt,
|
|
|
91 |
previewUrl,
|
92 |
assetUrl,
|
93 |
createdAt,
|
@@ -102,7 +104,12 @@ app.post("/posts/:appId", async (req, res) => {
|
|
102 |
} catch (err) {
|
103 |
console.error(`failed to save the post: ${err}`)
|
104 |
res.status(400)
|
105 |
-
res.write(JSON.stringify({
|
|
|
|
|
|
|
|
|
|
|
106 |
res.end()
|
107 |
return
|
108 |
}
|
|
|
45 |
|
46 |
const postId = `${req.body.postId || uuidv4()}`
|
47 |
const prompt = `${req.body.prompt || ""}`
|
48 |
+
const model = `${req.body.model || ""}`
|
49 |
const assetUrl = `${req.body.assetUrl || ""}`
|
50 |
const previewUrl = `${req.body.previewUrl || assetUrl}`
|
51 |
const createdAt = `${req.body.createdAt || new Date().toISOString()}`
|
|
|
89 |
postId,
|
90 |
appId,
|
91 |
prompt,
|
92 |
+
model,
|
93 |
previewUrl,
|
94 |
assetUrl,
|
95 |
createdAt,
|
|
|
104 |
} catch (err) {
|
105 |
console.error(`failed to save the post: ${err}`)
|
106 |
res.status(400)
|
107 |
+
res.write(JSON.stringify({
|
108 |
+
success: false,
|
109 |
+
error: `failed to save the post: ${err}`,
|
110 |
+
post: undefined
|
111 |
+
} as unknown as CreatePostResponse
|
112 |
+
))
|
113 |
res.end()
|
114 |
return
|
115 |
}
|
src/types.mts
CHANGED
@@ -8,6 +8,7 @@ export type Post = {
|
|
8 |
postId: string
|
9 |
appId: string
|
10 |
prompt: string
|
|
|
11 |
previewUrl: string
|
12 |
assetUrl: string
|
13 |
createdAt: string
|
|
|
8 |
postId: string
|
9 |
appId: string
|
10 |
prompt: string
|
11 |
+
model: string
|
12 |
previewUrl: string
|
13 |
assetUrl: string
|
14 |
createdAt: string
|