-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
62 lines (46 loc) · 1.46 KB
/
index.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
const express=require('express');
const app = express();
const port = 8000;
const db = require('./config/mongoose');
const bcrypt=require('bcryptjs');
// using passport-jwt
const passportJwt = require('./config/passport-jwt-strategy');
// middleware parser to get the form values as the body object in request
app.use(express.urlencoded());
// uncomment the below code once, run npm start then comment it again (its for manually entering admin)
// const User=require('./models/user');
// bcrypt.genSalt(10, function(err, salt) {
// bcrypt.hash("admin", salt, function(err, hash) {
// if(err){
// console.log(err);
// return;
// }
// else{
// const info={
// email:"admin123",
// phone:9,
// name:"admin",
// password:hash,
// loans:[],
// userType:"admin",
// isApproved:true
// }
// User.create(info,function(err){
// if(err){
// console.log(err);
// }
// return;
// })
// }
// });
// });
// using express router
app.use(express.json());
app.use('/',require('./routes'));
app.listen(port, function(err){
if (err){
console.log(`Error in running the server: ${err}`);
}
console.log(`Server is running on port: ${port}`);
});
module.exports=app;