SilvrAPI/newapp.js

47 lines
1.2 KiB
JavaScript

var express = require('express'), path = require('path'), http = require('http'),
favicon = require('serve-favicon'),
logger = require('morgan'),
cookieParser = require('cookie-parser'),
bodyParser = require('body-parser'),
routes = require('./routes/index'),
users = require('./routes/users'),
timeroute = require('./routes/time'),
btcroute = require('./routes/btc'),
temproute = require('./routes/temp'),
weightroute = require('./routes/weight')
//train = require('lib/train')
/* ,submit = require('./routes/mongo/submit') */
;
var app = express();
GLOBAL.lastcheck = {"btc": 0, "fx": 0};
app.set('port', process.env.PORT || 8030);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', routes);
//app.use('/users', users);
app.use('/time', timeroute);
app.use('/btc', btcroute);
app.use('/temp',temproute);
app.use('/weight',weightroute);
/**
* create the server
*/
app.listen(app.get('port'), function () {
console.log('APIServer listening on ' + app.get('port'));
});