-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
98 lines (64 loc) · 2.16 KB
/
server.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
const express = require('express')
const app = express();
const user = require('./routes/userRoute')
const admin = require('./routes/adminRoute')
//const neeew = require('./routes/new')
const georoute = require('./routes/geoRoute')
var unless = require('express-unless');
var mongoose = require('mongoose');
var bodyparser = require('body-parser')
var path = require('path')
const verify = require('./verifytoken')
const dontenv = require('dotenv');
const multer = require('multer');
fs = require('fs-extra')
app.use(bodyparser.urlencoded({ extended: false }));
app.use(bodyparser.json())
app.use('/uploads', express.static('uploads'));
// var storage = multer.diskStorage({
// destination: function (req, file, cb) {
// cb(null, 'uploads')
// },
// filename: function (req, file, cb) {
// cb(null, file.fieldname + '-' + Date.now()+'.jpg')
// }
// })
// var upload = multer({ storage: storage })
mongoose.connect(process.env.dbconnect, {useNewUrlParser: true,useUnifiedTopology: true});
var urlencodedParser = bodyparser.urlencoded({ extended: false })
mongoose.connection.on('connected',()=>{
console.log('connected to databaseat at this port')
})
mongoose.connection.on('error',(err)=>{
if(err)
{
console.log('error in database connection')
}
})
// var swaggerUi = require('swagger-ui-express'),
// swaggerDocument = require('./swagger.json')
// app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
// app.use('/api/v1', authRoute,product,cart,ccat,admin);
// app.use(verify.unless({
// path: [
// '/api/admin',
// { url: '/', methods: ['GET', 'PUT','POST'] }
// ]
// }))
app.use('/api/user',user)
app.use('/api/admin',admin)
app.use('/api',georoute);
// app.use((req, res, next) => {
// const error = new Error();
// error.message = 'Not Found';
// error.status = 404;
// next(error);
// });
// app.use((error, req, res, next) => {
// res.status(error.status || 500).json({
// error: error
// });
// });
//app.use(paginate.middleware(5, 5));
app.listen(3000,() => console.log('server is running on 3000'));
module.exports = app