-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
66 lines (59 loc) · 2.14 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const express = require ("express");
const dotenv = require("dotenv").config();
const app = express();
const userRoute = require("./routes/userRoutes");
const port = process.env.PORT || 5000
const connectDB = require("./config/db");
const User = require("./models/userModel");
const client = require('twilio')(process.env.TWILIO_SID, process.env.TWILIO_AUTH_TOKEN);
connectDB();
const auth = require("./middleware/auth")
app.use(express.json())
app.use(
express.urlencoded({
extended: true,
}))
app.use("/api",userRoute);
app.get("/", (req,res)=>{
// sendTestMessage()
res.send("get method called");
});
app.post("/welcome",auth,(req,res)=>{
res.status(200).send("welcome 🙌")
})
// function sendTestMessage(){
// client.messages
// .create({
// body: 'Hello from twilio-node',
// to: '+919330719639', // Text your number
// from: '+919163177924', // From a valid Twilio number
// })
// .then((message) => console.log(message.sid));
// }
// // Download the helper library from https://www.twilio.com/docs/node/install
// Set environment variables for your credentials
// Read more at http://twil.io/secure
//twilio verification code sending process
// const accountSid = "ACa22b4d8cdbc0f3fb8007541778518f86";
// const authToken = "680404ca511a6c89460bcef8bb614a8c";
// const verifySid = "VA34132cb9205955fb3b2438b6074a17f3";
// const client = require("twilio")(accountSid, authToken);
// function sendTestMessage(){client.verify.v2
// .services(verifySid)
// .verifications.create({ to: "+919330719639", channel: "sms" })
// .then((verification) => console.log(verification.status))
// .then(() => {
// const readline = require("readline").createInterface({
// input: process.stdin,
// output: process.stdout,
// });
// readline.question("Please enter the OTP:", (otpCode) => {
// client.verify.v2
// .services(verifySid)
// .verificationChecks.create({ to: "+919330719639", code: otpCode })
// .then((verification_check) => console.log(verification_check.status))
// .then(() => readline.close());
// });
// });
// }
module.exports = app;