1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { webMentionHandler } from "https://esm.town/v/byjp/webMentionHandler";
export const recordWebmention = async (
req: express.Request,
res: express.Response,
) => {
try {
// Pass the source and target of the request to the handler.
// No need to run validation on it as this will be validated by the handler.
const recomendedResponse = await webMentionHandler
.addPendingMention(req.body.source, req.body.target);
// The response code is dictated by the specification but not enforced by the handler
// in case you need to action your own out-of-spec actions. response body should be human-readable
res.status(recomendedResponse.code).send("accepted");
}
catch (e) {
res.status(400).send(e.message);
}
};
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023