-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathserver.js
More file actions
56 lines (48 loc) · 1.49 KB
/
Copy pathserver.js
File metadata and controls
56 lines (48 loc) · 1.49 KB
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
const {mail,MakeCertificate,verifyDocument} =require("./src/apis/appsScriptApi");
const express=require("express")
const app = express();
const cors = require("cors");
//cors libarary is for handling security messages from browser(while using xhttp requests)
app.use(
cors({
origin: "http://localhost:3000",
methods: ["POST", "GET"],
credentials: true,
})
);
// middleware
app.use(express.json());
app.use(express.urlencoded());
app.post("/MakeCert",async (req,res)=>{
console.log("Making Certificate");
try{
const resps=await MakeCertificate(req.body.data);
console.log("Mailing status from backend ->"+resps)
res.send(resps);
}catch(err){
console.log("\n\nerror ->"+err.data)
res.send("error from backend ->"+err)
}
})
app.post("/sendToVerify",async (req,res)=>{
try{
const resps=await verifyDocument(req.body.data)
console.log("Mailing Status from backend ->"+resps)
res.send(resps)
}catch(err){
console.log("error from backend ->"+err)
res.send("error from backend ->"+err)
}
})
app.post("/declineQuery",async (req,res)=>{
try{
const resps=await mail(req.body.message)
console.log("Mailing Status from backend ->"+resps)
res.send(resps)
}catch(err){
console.log("error from backend ->"+err)
res.send("error from backend ->"+err)
}
})
const PORT = process.env.PORT || 8080;
app.listen(PORT, console.log(`Server started on port ${PORT}`));