jbilcke-hf HF staff commited on
Commit
179cbc0
·
1 Parent(s): 5b1e6c8

fix major issue

Browse files
Files changed (1) hide show
  1. src/index.mts +13 -12
src/index.mts CHANGED
@@ -22,7 +22,7 @@ const port = 7860
22
  app.use(express.json({limit: '50mb'}));
23
  app.use(express.urlencoded({limit: '50mb', extended: true}));
24
 
25
- app.post("/post", async (req, res) => {
26
 
27
  if (!hasValidAuthorization(req.headers)) {
28
  console.log("Invalid authorization")
@@ -32,8 +32,17 @@ app.post("/post", async (req, res) => {
32
  return
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}`
@@ -49,15 +58,7 @@ app.post("/post", async (req, res) => {
49
  res.end()
50
  return
51
  }
52
-
53
- if (!uuidValidate(appId)) {
54
- console.error(`invalid appId ${appId}`)
55
- res.status(400)
56
- res.write(JSON.stringify({ error: `invalid appId ${appId}` }))
57
- res.end()
58
- return
59
- }
60
-
61
  if (!prompt.length) {
62
  console.error(`invalid prompt length: cannot be zero`)
63
  res.status(400)
 
22
  app.use(express.json({limit: '50mb'}));
23
  app.use(express.urlencoded({limit: '50mb', extended: true}));
24
 
25
+ app.post("/posts/:appId", async (req, res) => {
26
 
27
  if (!hasValidAuthorization(req.headers)) {
28
  console.log("Invalid authorization")
 
32
  return
33
  }
34
 
35
+ const appId = req.params.appId
36
+
37
+ if (!uuidValidate(appId)) {
38
+ console.error("invalid appId")
39
+ res.status(400)
40
+ res.write(JSON.stringify({ error: `invalid appId` }))
41
+ res.end()
42
+ return
43
+ }
44
+
45
+ const postId = `${req.body.postId || uuidv4()}`
46
  const prompt = `${req.body.prompt || ""}`
47
  const assetUrl = `${req.body.assetUrl || ""}`
48
  const previewUrl = `${req.body.previewUrl || assetUrl}`
 
58
  res.end()
59
  return
60
  }
61
+
 
 
 
 
 
 
 
 
62
  if (!prompt.length) {
63
  console.error(`invalid prompt length: cannot be zero`)
64
  res.status(400)