-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
31 lines (21 loc) · 808 Bytes
/
Copy pathserver.js
File metadata and controls
31 lines (21 loc) · 808 Bytes
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
const express = require('express');
const app = express();
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const expressValidator = require('express-validator');
global.config=require('./modules/config');
// Connect to DB
mongoose.connect('mongodb://127.0.0.1:27017/mtgapi');
mongoose.Promise = global.Promise;
//middleware
app.use(bodyParser.urlencoded({ extended : false }));
app.use(bodyParser.json({ type : 'application/json' }));
app.use(expressValidator());
app.use('/public' , express.static('public'))
const apiRouter = require('./modules/routes/api');
//const webRouter = require('./modules/routes/web');
app.use('/api' , apiRouter)
// app.use('/' , webRouter);
app.listen(config.port , () => {
console.log(`Server running at Port ${config.port}`)
});