This repository was archived by the owner on May 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
47 lines (37 loc) · 1.27 KB
/
Copy pathmain.js
File metadata and controls
47 lines (37 loc) · 1.27 KB
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
/**
* Detector IOT
* @author RapidWorkers
* @license MIT License
* @copyright Copyright RapidWorkers 2018 All right reserved.
*/
/** ################### INIT ################### **/
var fs = require('fs'),
config = require('./config/config'),
mongoose = require('./config/mongoose'),
express = require('./config/express_config'),
passport = require('./config/passport'),
nodemailer = require('./config/nodemailer');
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
/** ############################################ **/
console.log("=========================================");
console.log("IOT for Arduino, API Server");
console.log("by SOOHYUN KIM @ Kwangwoon Univ.");
console.log("=========================================");
/** ############################################ **/
var db = mongoose();
var app = express();
var passport = passport();
var transporter = nodemailer();
app.use(errorHandler); //DEBUG
module.exports = app;
app.listen(config.webConfig.port, function () {
console.log("HTTP PORT OPENED %d", config.webConfig.port);
});
app.use(function (req, res) {
res.status(404);
res.type('html').send('Page not found.');
});
function errorHandler(err, req, res, next) {
res.status(500);
res.render('error', {error: err})
}