-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
37 lines (24 loc) · 1010 Bytes
/
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
require('./model/model');
require('./main');
var express = require("express");
var mongoose = require("mongoose");
var bodyParser = require("body-parser");
var fs = require('fs');
mongoose.Promise = require('bluebird'); // To remove deprecation warning of mpromise
var morgan = require('morgan');
var path = require('path');
const jwt = require('jsonwebtoken');
mongoose.connect('mongodb://localhost:27017/testDB', { useMongoClient: true });
var app = module.exports = express();
var NODE_ENV = 'development';
app.set('env', process.env.NODE_ENV || 'production');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
// var logFile = fs.createWriteStream('logFile.txt', { flag: 'a' });
// app.use(morgan('combined', { stream: logFile }));
routes = require('./routes/routes');
app.use('/api', routes);
app.use('/logs', express.static(path.join(__dirname + '/logs')));
var port = process.env.PORT || 8888;
app.listen(port);
console.log('Server starts on port ' + port);