2019-12-19 21:50:50 -08:00
|
|
|
var express = require('express')
|
|
|
|
var router = express.Router()
|
|
|
|
|
|
|
|
let QuickNote = require('@models/QuickNote');
|
2020-05-15 16:12:09 -07:00
|
|
|
|
2019-12-19 21:50:50 -08:00
|
|
|
let userId = null
|
2020-05-15 16:12:09 -07:00
|
|
|
let masterKey = null
|
2019-12-19 21:50:50 -08:00
|
|
|
|
|
|
|
// middleware that is specific to this router
|
|
|
|
router.use(function setUserId (req, res, next) {
|
|
|
|
if(userId = req.headers.userId){
|
|
|
|
userId = req.headers.userId
|
2020-05-15 16:12:09 -07:00
|
|
|
masterKey = req.headers.masterKey
|
2019-12-19 21:50:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
next()
|
|
|
|
})
|
|
|
|
|
|
|
|
//Get quick note text
|
|
|
|
router.post('/get', function (req, res) {
|
2020-05-15 16:12:09 -07:00
|
|
|
QuickNote.get(userId, masterKey)
|
2019-12-19 21:50:50 -08:00
|
|
|
.then( data => res.send(data) )
|
|
|
|
})
|
|
|
|
|
|
|
|
//Push text to quick note
|
|
|
|
router.post('/update', function (req, res) {
|
2020-05-18 00:45:35 -07:00
|
|
|
QuickNote.update(userId, req.body.pushText, masterKey)
|
2019-12-19 21:50:50 -08:00
|
|
|
.then( data => res.send(data) )
|
|
|
|
})
|
|
|
|
|
2020-05-15 16:12:09 -07:00
|
|
|
//Push text to quick note
|
|
|
|
router.post('/new', function (req, res) {
|
|
|
|
QuickNote.newNote(userId)
|
2019-12-19 21:50:50 -08:00
|
|
|
.then( data => res.send(data) )
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = router
|