fcee24a61d
Tweaked a lot of styles and added some cool animations Added a little to the help text Quickly adding a note, saving and closing no longer causes half formed or empty notes to appear Close Editor animation Display cards text show at the bottom of card Added a delete function, and it works Added browser title attributes More debugging and error checking on scraped links Updated not search to display title and text below the title
50 lines
1.1 KiB
JavaScript
50 lines
1.1 KiB
JavaScript
var express = require('express')
|
|
var router = express.Router()
|
|
|
|
let Notes = require('@models/Notes');
|
|
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('/latest', function (req, res) {
|
|
Notes.getLatest(userId)
|
|
.then( data => res.send(data) )
|
|
})
|
|
|
|
router.post('/get', function (req, res) {
|
|
Notes.get(userId, req.body.noteId)
|
|
.then( data => res.send(data) )
|
|
})
|
|
|
|
router.post('/delete', function (req, res) {
|
|
Notes.delete(userId, req.body.noteId)
|
|
.then( data => res.send(data) )
|
|
})
|
|
|
|
router.post('/create', function (req, res) {
|
|
Notes.create(userId, req.body.title)
|
|
.then( id => res.send({id}) )
|
|
})
|
|
|
|
router.post('/update', function (req, res) {
|
|
Notes.update(userId, req.body.noteId, req.body.text, req.body.fancyInput, req.body.color)
|
|
.then( id => res.send({id}) )
|
|
})
|
|
|
|
router.post('/search', function (req, res) {
|
|
Notes.search(userId, req.body.searchQuery, req.body.searchTags)
|
|
.then( notesAndTags => res.send(notesAndTags))
|
|
})
|
|
|
|
|
|
|
|
|
|
module.exports = router |