forked from Northern-Moose/newsaggregator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
37 lines (28 loc) · 870 Bytes
/
server.js
File metadata and controls
37 lines (28 loc) · 870 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
32
33
34
35
36
37
var express = require('express');
var path = require('path');
var cors = require('cors');
var Q = require('q');
var dbRequest = require('./db/dbRequestHandler.js');
var app = express();
app.use(cors());
app.use(express.static(path.join(__dirname, './client')));
// This could, and should, become a cron job or other
// external daemon
setInterval(function() {
dbRequest.automaticApiAggregation();
}, 5000);
// This handles requests to our users table
app.post('/api/users', function(req, res) {
});
// This handles database calls to our aggregated content table
app.get('/api/content', function(req, res) {
dbRequest.deliverContent().then(function(data) {
res.status(200).send(data);
});
});
// This will redirect to our Angular client
app.get('/', function(req, res) {
res.render('index');
});
var port = process.env.PORT || 8080;
app.listen(port);