-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeprecated-server.js
51 lines (46 loc) · 1.26 KB
/
deprecated-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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const express = require('express');
const app = express();
const Model = require('./db');
const equipments = require('./data').equipments;
const tags = require('./data').tags;
app.use(function(req, res, next) {
// Set permissive CORS header - this allows this server to be used only as
// an API server in conjunction with something like webpack-dev-server.
res.setHeader('Access-Control-Allow-Origin', '*');
// Disable caching so we'll always get the latest comments.
res.setHeader('Cache-Control', 'no-cache');
next();
});
app.get('/workouts', function(req, res) {
const model = new Model((error) => {
if (error) {
console.error('error:', error);
}
model.getWorkouts((workouts) => {
res.json(workouts);
});
});
});
app.get('/sync', function(req, res) {
const model = new Model((error) => {
if (error) {
console.error('error:', error);
}
let ret = {
filters: {
tags: tags,
equipments: equipments,
}
};
model.getWorkouts((workouts) => {
ret.workouts = workouts;
model.getMovements((movements) => {
ret.filters.movements = movements;
res.json(ret);
});
});
});
});
app.listen(8800, function () {
console.log('Wodmeup listening on port 8800!');
});