-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.js
33 lines (28 loc) · 782 Bytes
/
api.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
const express = require("express");
const utils = require("./utils");
const app = express();
const PORT = process.env.PORT || 3000;
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept"
);
next();
});
app.get("/", (req, res) => {
user_id = 1;
utils.get_activity_table(user_id, result => {
res.send(result);
});
});
app.get("/user/:user_id", (req, res) => {
user_id = 1;
utils.get_activity_table(req.params.user_id, result => {
let date = new Date().toISOString();
console.log(date);
res.send(result);
});
});
app.listen(PORT, () => console.log(`Activity app listening on port ${PORT}!`));
module.exports = app;