extract out post URLs
Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
parent
f950a2e0ff
commit
a1779cbbda
14
src/index.ts
14
src/index.ts
|
@ -31,7 +31,7 @@ app.get("/", async (_req, resp) => {
|
|||
resp.send("Yasomi online.");
|
||||
});
|
||||
|
||||
app.post("/create", express.json(), async (req, resp) => {
|
||||
app.post("/create", express.json(), async (req, resp, next) => {
|
||||
if (!valid.CreatePostRequest(req.body)) {
|
||||
resp.status(400);
|
||||
resp.json({
|
||||
|
@ -58,9 +58,17 @@ app.post("/create", express.json(), async (req, resp) => {
|
|||
facets: rt.facets,
|
||||
createdAt: new Date().toISOString(),
|
||||
};
|
||||
const postData = await agent.post(postRecord);
|
||||
|
||||
resp.json({ atProto: postData });
|
||||
try {
|
||||
const postData = await agent.post(postRecord);
|
||||
const [_, did, __, postID] = postData.uri.split(
|
||||
/^at:\/\/(.+)\/(.+)\/(.+)$/
|
||||
);
|
||||
const url = `https://staging.bsky.app/profile/${did}/post/${postID}`;
|
||||
resp.json({ atProto: postData, input: cpr, url });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(port, () => {
|
||||
|
|
Loading…
Reference in New Issue