var express = require('express') var router = express.Router() let QuickNote = require('@models/QuickNote'); let userId = null let masterKey = null // middleware that is specific to this router router.use(function setUserId (req, res, next) { if(userId = req.headers.userId){ userId = req.headers.userId masterKey = req.headers.masterKey } next() }) //Get quick note text router.post('/get', function (req, res) { QuickNote.get(userId, masterKey) .then( data => res.send(data) ) }) //Push text to quick note router.post('/update', function (req, res) { QuickNote.update(userId, req.body.pushText, masterKey) .then( data => res.send(data) ) }) //Push text to quick note router.post('/new', function (req, res) { QuickNote.newNote(userId) .then( data => res.send(data) ) }) module.exports = router