Spaces:
Runtime error
Runtime error
Commit
·
5b7e1eb
1
Parent(s):
457997e
let's auto add the previewUrl and the uuid
Browse files- src/index.mts +5 -6
src/index.mts
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import { validate as uuidValidate } from "uuid"
|
2 |
import express from "express"
|
|
|
3 |
|
4 |
import { hasValidAuthorization } from "./utils/hasValidAuthorization.mts"
|
5 |
import { initFolders } from "./initFolders.mts"
|
@@ -32,10 +33,10 @@ app.post("/post", async (req, res) => {
|
|
32 |
}
|
33 |
|
34 |
const postId = `${req.body.postId || ""}`
|
35 |
-
const appId = `${req.body.appId ||
|
36 |
const prompt = `${req.body.prompt || ""}`
|
37 |
-
const previewUrl = `${req.body.previewUrl || ""}`
|
38 |
const assetUrl = `${req.body.assetUrl || ""}`
|
|
|
39 |
const createdAt = `${req.body.createdAt || ""}`
|
40 |
const upvotes = getValidNumber(req.body.upvotes, 0, 1e15, 0)
|
41 |
const downvotes = getValidNumber(req.body.upvotes, 0, 1e15, 0)
|
@@ -101,10 +102,8 @@ app.post("/post", async (req, res) => {
|
|
101 |
return
|
102 |
}
|
103 |
|
104 |
-
|
105 |
-
|
106 |
-
res.status(200)
|
107 |
-
res.write(cachedJson)
|
108 |
res.end()
|
109 |
})
|
110 |
|
|
|
1 |
import { validate as uuidValidate } from "uuid"
|
2 |
import express from "express"
|
3 |
+
import { v4 as uuidv4 } from "uuid"
|
4 |
|
5 |
import { hasValidAuthorization } from "./utils/hasValidAuthorization.mts"
|
6 |
import { initFolders } from "./initFolders.mts"
|
|
|
33 |
}
|
34 |
|
35 |
const postId = `${req.body.postId || ""}`
|
36 |
+
const appId = `${req.body.appId || uuidv4()}`
|
37 |
const prompt = `${req.body.prompt || ""}`
|
|
|
38 |
const assetUrl = `${req.body.assetUrl || ""}`
|
39 |
+
const previewUrl = `${req.body.previewUrl || assetUrl}`
|
40 |
const createdAt = `${req.body.createdAt || ""}`
|
41 |
const upvotes = getValidNumber(req.body.upvotes, 0, 1e15, 0)
|
42 |
const downvotes = getValidNumber(req.body.upvotes, 0, 1e15, 0)
|
|
|
102 |
return
|
103 |
}
|
104 |
|
105 |
+
res.status(201)
|
106 |
+
res.write(JSON.stringify({ success: true, error: "", post }))
|
|
|
|
|
107 |
res.end()
|
108 |
})
|
109 |
|