aboutsummaryrefslogtreecommitdiffstats
path: root/pages
diff options
context:
space:
mode:
authorGravatar piotrruss <mail@pruss.it> 2021-08-12 19:00:50 +0200
committerGravatar piotrruss <mail@pruss.it> 2021-08-12 19:00:50 +0200
commit74abb7052d3af3c305cfe3c525aea311ccc446e1 (patch)
tree752f6da94ea8b554906774d878ecebfbfe8d724e /pages
parent0660d3f5d3028ab3084c77f14a350d74c567bbd7 (diff)
downloadmy_apps-74abb7052d3af3c305cfe3c525aea311ccc446e1.tar.gz
my_apps-74abb7052d3af3c305cfe3c525aea311ccc446e1.tar.bz2
my_apps-74abb7052d3af3c305cfe3c525aea311ccc446e1.zip
crypt notes content
Diffstat (limited to 'pages')
-rw-r--r--pages/api/note/[id].js5
-rw-r--r--pages/api/notes.js2
2 files changed, 4 insertions, 3 deletions
diff --git a/pages/api/note/[id].js b/pages/api/note/[id].js
index 8ba3b70..46278c8 100644
--- a/pages/api/note/[id].js
+++ b/pages/api/note/[id].js
@@ -3,7 +3,7 @@ import withSession from 'lib/withSession'
import Note from 'models/Note'
export default withSession(async (req, res) => {
- const { id } = req.query
+ const {id} = req.query
await dbConnect()
switch (req.method) {
@@ -15,7 +15,7 @@ export default withSession(async (req, res) => {
throw new Error('Something went wrong')
}
- const note = await Note.findById(id)
+ const note = await Note.getNote(id)
if (!note) {
throw new Error('Something went wrong')
@@ -23,6 +23,7 @@ export default withSession(async (req, res) => {
res.status(200).json(note)
} catch (error) {
+ console.log(error)
res.status(400).json({error: true})
}
break
diff --git a/pages/api/notes.js b/pages/api/notes.js
index 73a7217..dd31c6f 100644
--- a/pages/api/notes.js
+++ b/pages/api/notes.js
@@ -78,7 +78,7 @@ export default withSession(async (req, res) => {
throw new Error('Something went wrong')
}
- await Note.findByIdAndUpdate(noteId, {content}, {new: true})
+ await Note.updateNote(noteId, content)
const notes = await NoteList.findOneAndUpdate(
{ _id: user.noteList, "notes.noteId": noteId },