import { WebhookClient } from "@webuildbots/webuildbots-sdk/lib/util/webhook-client"; import bodyParser from "body-parser"; import express, { Request, Response } from "express"; import { sendSMS } from "./sms"; const app: express.Application = express(); app.use(express.text()); app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); export enum handlerNames { SMS_CONFIRMATION = "send-sms", } //Init WebhookClient, get token and fire handler const client: WebhookClient = new WebhookClient().addHandler( handlerNames.SMS_CONFIRMATION, sendSMS ); app.post("/", async (req: Request, res: Response) => { // handleRequest returns a JSON object and a statusCode const { status, body: respBody } = await client.handleRequest( req.body || "", null ); res.status(status).send(respBody); }); //Manages init and firing of handler export const handler = app;