Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: removing express dependency #999

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,46 @@ To use a custom HTTP client with this helper library, please see the [advanced e

### Use webhook validation

See [example](examples/express.js) for a code sample for incoming Twilio request validation.
Following code sample can be referred for incoming Twilio request validation.
```js
const twilio = require("twilio");
const bodyParser = require("body-parser");
const MessagingResponse = require("twilio").twiml.MessagingResponse;

const authToken = process.env.TWILIO_AUTH_TOKEN;

const express = require("express");
const app = express();
const port = 3000;

app.use(
bodyParser.json({
verify: (req, res, buf) => {
req.rawBody = buf;
},
})
);

app.get("/", (req, res) => {
res.send("Hello World!");
});

app.post("/message", twilio.webhook(authToken), (req, res) => {
// Twilio Messaging URL - receives incoming messages from Twilio
const response = new MessagingResponse();

response.message(`Your text to me was ${req.body.Body}.
Webhooks are neat :)`);

res.set("Content-Type", "text/xml");
res.send(response.toString());
});

app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});

```

## Docker image

Expand Down
36 changes: 0 additions & 36 deletions examples/express.js

This file was deleted.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"@types/url-parse": "^1.4.8",
"babel-plugin-replace-ts-export-assignment": "^0.0.2",
"eslint": "^8.31.0",
"express": "^4.17.1",
"jest": "^29.5.5",
"jshint": "^2.11.0",
"mock-fs": "^5.2.0",
Expand Down
Loading