Spaces:
Runtime error
Runtime error
Commit
·
5b1e6c8
1
Parent(s):
955e8e9
fix for visibility
Browse files- src/index.mts +8 -3
src/index.mts
CHANGED
@@ -122,15 +122,20 @@ app.get("/posts/:appId/:visibility", async (req, res) => {
|
|
122 |
return
|
123 |
}
|
124 |
|
|
|
|
|
125 |
try {
|
126 |
-
const posts = await getAppPosts(
|
|
|
|
|
|
|
127 |
res.status(200)
|
128 |
-
console.log(`returning ${posts.length} community posts for app ${appId}`)
|
129 |
res.write(JSON.stringify({ posts } as GetAppPostsResponse))
|
130 |
res.end()
|
131 |
return
|
132 |
} catch (err) {
|
133 |
-
const error = `failed to load the posts: ${err}`
|
134 |
console.error(error)
|
135 |
res.status(500)
|
136 |
res.write(JSON.stringify({ posts: [], error } as GetAppPostsResponse))
|
|
|
122 |
return
|
123 |
}
|
124 |
|
125 |
+
const visibility = `${req.params.visibility}`
|
126 |
+
|
127 |
try {
|
128 |
+
const posts = await getAppPosts(
|
129 |
+
appId,
|
130 |
+
visibility === "all" ? undefined : visibility as PostVisibility
|
131 |
+
)
|
132 |
res.status(200)
|
133 |
+
console.log(`returning ${posts.length} community posts for app ${appId} (visibility: ${visibility})`)
|
134 |
res.write(JSON.stringify({ posts } as GetAppPostsResponse))
|
135 |
res.end()
|
136 |
return
|
137 |
} catch (err) {
|
138 |
+
const error = `failed to load the posts for app ${appId} and visibility ${visibility}: ${err}`
|
139 |
console.error(error)
|
140 |
res.status(500)
|
141 |
res.write(JSON.stringify({ posts: [], error } as GetAppPostsResponse))
|