Scalable IoT solution for real-time body position data
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
850 B

const express = require('express')
const router = express.Router();
const mongoose = require('mongoose');
const {requireAuth} = require('../middlewares/middleware');
4 years ago
const Athlete = mongoose.model('Athlete');
const {influx_bucket} = require('../config/keys')
const {iQuery} = require('../actions/influx_actions')
router.get('/api/data', requireAuth, async (req, res) => {
const query = `from(bucket: "${influx_bucket}") |> range(start: -1h)`;
const data = await iQuery(query);
res.send(data);
});
router.get('/api/data/:id', requireAuth, async (req, res) => {
const athlete = await Athlete.findById(req.params.id);
const query = `from(bucket: "${influx_bucket}") |> range(start: -1h) |> filter(fn: (r) => r.client == "${athlete.id}")`;
const data = await iQuery(query);
res.send(data)
});
4 years ago
module.exports = router;