I need to get back into using git. The hell is wrong with me!?

This commit is contained in:
Max G committed 2019-12-20 05:50:50 +00:00
1 parent 7b77bd37f3
commit 6fe39406b7
135 files changed
+53273 -699

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
let express = require('express')
var multer = require('multer')
var upload = multer({ dest: '../staticFiles/' })
let router = express.Router()
let Attachment = require('@models/Attachment');
let Note = require('@models/Note')
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()
})
router.post('/search', function (req, res) {
Attachment.search(userId, req.body.noteId)
.then( data => res.send(data) )
})
router.post('/get', function (req, res) {
Attachment.forNote(userId, req.body.noteId)
.then( data => res.send(data) )
})
router.post('/update', function (req, res) {
Attachment.update(userId, req.body.attachmentId, req.body.updatedText, req.body.noteId)
.then( result => {
Note.reindex(userId, req.body.noteId)
.then( data => res.send(data) )
})
})
router.post('/upload', upload.single('file'), function (req, res, next) {
//Create attachment with file information and node id
const noteId = parseInt(req.body.noteId)
Attachment.processUploadedFile(userId, noteId, req.file)
.then( uploadResults => {
//Reindex note, attachment may have had text
Note.reindex(userId, noteId)
.then( data => res.send(uploadResults) )
})
})
module.exports = router