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

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

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

View File

@@ -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'))
// })
})

View 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

View 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