Backend update renamed controllers and models to be singular

This commit is contained in:
Max G committed 2019-07-30 19:21:12 +00:00
1 parent 7806a206b2
commit 0d86aa4ff9
11 files changed
+41 -48

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
var express = require('express')
var router = express.Router()
let Tags = require('@models/Tag');
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 the latest notes the user has created
router.post('/suggest', function (req, res) {
Tags.suggest(userId, req.body.noteId, req.body.tagText)
.then( data => res.send(data) )
})
//Get the latest notes the user has created
router.post('/addtonote', function (req, res) {
Tags.addToNote(userId, req.body.noteId, req.body.tagText.toLowerCase())
.then( data => res.send(data) )
})
router.post('/removefromnote', function (req, res) {
Tags.removeTagFromNote(userId, req.body.tagId)
.then( data => res.send(data) )
})
//Get the latest notes the user has created
router.post('/get', function (req, res) {
Tags.get(userId, req.body.noteId)
.then( data => res.send(data) )
})
module.exports = router