I'm having a hard time writing custom HTTP routes on my probot written in Typescript.
The only example in documentation is pure JS but I couldn't figure out how to translate it to TS.
module.exports = (app, { getRouter }) => {
// Get an express router to expose new HTTP endpoints
const router = getRouter("/my-app");
// Use any middleware
router.use(require("express").static("public"));
// Add a new route
router.get("/hello-world", (req, res) => {
res.send("Hello World");
});
};
This should do the trick:
In
ApplicationFunctionOptions
getRouter
is optional. That's why i added a quick check in the beginning of the function.