SolidScribe/server/routes/quicknoteController.js

35 lines
765 B
JavaScript

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