I need to get back into using git. The hell is wrong with me!?
This commit is contained in:
53
server/routes/attachmentController.js
Normal file
53
server/routes/attachmentController.js
Normal 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
|
@@ -29,7 +29,7 @@ router.post('/create', function (req, res) {
|
||||
})
|
||||
|
||||
router.post('/update', function (req, res) {
|
||||
Notes.update(userId, req.body.noteId, req.body.text, req.body.fancyInput, req.body.color, req.body.pinned, req.body.archived)
|
||||
Notes.update(userId, req.body.noteId, req.body.text, req.body.color, req.body.pinned, req.body.archived)
|
||||
.then( id => res.send({id}) )
|
||||
})
|
||||
|
||||
@@ -38,6 +38,13 @@ router.post('/search', function (req, res) {
|
||||
.then( notesAndTags => res.send(notesAndTags))
|
||||
})
|
||||
|
||||
//Reindex all notes. Not a very good function, not public
|
||||
router.get('/reindex5yu43prchuj903mrc', function (req, res) {
|
||||
|
||||
// Notes.stressTest().then( i => {
|
||||
// // Notes.reindexAll().then( result => res.send('Welcome to reindex...oh god'))
|
||||
// })
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
15
server/routes/publicController.js
Normal file
15
server/routes/publicController.js
Normal file
@@ -0,0 +1,15 @@
|
||||
var express = require('express')
|
||||
var router = express.Router()
|
||||
|
||||
let Notes = require('@models/Note')
|
||||
|
||||
router.post('/note', function (req, res) {
|
||||
|
||||
Notes.getShared(req.body.noteId)
|
||||
.then( data => res.send(data) )
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = router
|
35
server/routes/quicknoteController.js
Normal file
35
server/routes/quicknoteController.js
Normal file
@@ -0,0 +1,35 @@
|
||||
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
|
Reference in New Issue
Block a user