SolidScribe/server/routes/metrictrackingController.js
Max 39e153b8e1 Not really sure what is going on, have not done a commit in a while.
I assume this is all the metric tracking changes.
Looks like some script changes as well.
2023-02-12 18:41:55 +00:00

45 lines
966 B
JavaScript

//
// /api/metric-tracking
//
var express = require('express')
var router = express.Router()
let MetricTracking = require('@models/MetricTracking');
let userId = null
let masterKey = null
// middleware that is specific to this router
router.use(function setUserId (req, res, next) {
//Session key is required to continue
if(!req.headers.sessionId){
next('Unauthorized')
}
if(req.headers.userId){
userId = req.headers.userId
masterKey = req.headers.masterKey
next()
}
})
router.post('/get', function (req, res) {
MetricTracking.get(userId, masterKey)
.then( data => res.send(data) )
})
router.post('/create', function (req, res) {
MetricTracking.create(userId, masterKey)
.then( data => res.send(data) )
})
//Push text to quick note
router.post('/save', function (req, res) {
MetricTracking.save(userId, req.body.cycleData, masterKey)
.then( data => res.send(data) )
})
module.exports = router