aboutsummaryrefslogtreecommitdiffstats
path: root/pages/api
diff options
context:
space:
mode:
Diffstat (limited to 'pages/api')
-rw-r--r--pages/api/login.js4
-rw-r--r--pages/api/logout.js2
-rw-r--r--pages/api/note/[id].js4
-rw-r--r--pages/api/notes.js4
-rw-r--r--pages/api/register.js9
-rw-r--r--pages/api/settings.js4
-rw-r--r--pages/api/user.js4
-rw-r--r--pages/api/verify.js11
8 files changed, 20 insertions, 22 deletions
diff --git a/pages/api/login.js b/pages/api/login.js
index db39bda..038097c 100644
--- a/pages/api/login.js
+++ b/pages/api/login.js
@@ -1,5 +1,5 @@
-import withSession from 'lib/withSession'
-import dbConnect from 'lib/dbConnect'
+import withSession from 'hocs/withSession'
+import dbConnect from 'configs/dbConnect'
import User from 'models/User'
export default withSession(async (req, res) => {
diff --git a/pages/api/logout.js b/pages/api/logout.js
index 8c7a766..04e5160 100644
--- a/pages/api/logout.js
+++ b/pages/api/logout.js
@@ -1,4 +1,4 @@
-import withSession from 'lib/withSession'
+import withSession from 'hocs/withSession'
export default withSession(async (req, res) => {
req.session.destroy()
diff --git a/pages/api/note/[id].js b/pages/api/note/[id].js
index 46278c8..1781210 100644
--- a/pages/api/note/[id].js
+++ b/pages/api/note/[id].js
@@ -1,5 +1,5 @@
-import dbConnect from 'lib/dbConnect'
-import withSession from 'lib/withSession'
+import dbConnect from 'configs/dbConnect'
+import withSession from 'hocs/withSession'
import Note from 'models/Note'
export default withSession(async (req, res) => {
diff --git a/pages/api/notes.js b/pages/api/notes.js
index 79ab281..0439a7a 100644
--- a/pages/api/notes.js
+++ b/pages/api/notes.js
@@ -1,5 +1,5 @@
-import dbConnect from 'lib/dbConnect'
-import withSession from 'lib/withSession'
+import dbConnect from 'configs/dbConnect'
+import withSession from 'hocs/withSession'
import NoteList from 'models/NoteList'
import Note from 'models/Note'
diff --git a/pages/api/register.js b/pages/api/register.js
index 1407146..e14044e 100644
--- a/pages/api/register.js
+++ b/pages/api/register.js
@@ -1,6 +1,6 @@
-import dbConnect from 'lib/dbConnect'
-import withSession from 'lib/withSession'
-import sendMail from 'lib/sendMail'
+import dbConnect from 'configs/dbConnect'
+import sendMail from 'configs/sendMail'
+import withSession from 'hocs/withSession'
import {subject, text, html} from 'helpers/email'
import User from 'models/User'
import NoteList from 'models/NoteList'
@@ -16,14 +16,13 @@ export default withSession(async (req, res) => {
const {_id, email, verificationKey: key, theme, language} = await User.create({...req.body, noteList})
if (!email) { throw new Error('Something went wrong') }
- sendMail(req.body.email, subject, text(key), html(key))
+ sendMail(req.body.email, subject(language), text(language, key), html(language, key))
const user = {_id, email, noteList, theme, language, isVerified: false, isLoggedIn: true}
req.session.set('user', user)
await req.session.save()
res.status(201).json(user)
} catch (error) {
- console.log(error)
res.status(400).json({isLoggedIn: false})
}
break
diff --git a/pages/api/settings.js b/pages/api/settings.js
index e70868e..0de5e73 100644
--- a/pages/api/settings.js
+++ b/pages/api/settings.js
@@ -1,6 +1,6 @@
-import withSession from 'lib/withSession'
+import dbConnect from 'configs/dbConnect'
+import withSession from 'hocs/withSession'
import User from 'models/User'
-import dbConnect from 'lib/dbConnect'
export default withSession(async (req, res) => {
await dbConnect()
diff --git a/pages/api/user.js b/pages/api/user.js
index 59db3b6..44c7fc3 100644
--- a/pages/api/user.js
+++ b/pages/api/user.js
@@ -1,5 +1,5 @@
-import dbConnect from 'lib/dbConnect'
-import withSession from 'lib/withSession'
+import dbConnect from 'configs/dbConnect'
+import withSession from 'hocs/withSession'
import User from 'models/User'
export default withSession(async (req, res) => {
diff --git a/pages/api/verify.js b/pages/api/verify.js
index 1606dbc..bdad434 100644
--- a/pages/api/verify.js
+++ b/pages/api/verify.js
@@ -1,7 +1,7 @@
-import withSession from 'lib/withSession'
-import dbConnect from 'lib/dbConnect'
-import sendMail from 'lib/sendMail'
+import dbConnect from 'configs/dbConnect'
+import sendMail from 'configs/sendMail'
import User from 'models/User'
+import withSession from 'hocs/withSession'
import {subject, text, html} from 'helpers/email'
export default withSession(async (req, res) => {
@@ -10,13 +10,13 @@ export default withSession(async (req, res) => {
switch (req.method) {
case 'GET':
try {
- const {email} = req.session.get('user')
+ const {email, language: l} = req.session.get('user')
if (!email) { throw new Error('Something went wrong') }
const key = await User.getVerificationKey(email)
if (!key) { throw new Error('Something went wrong') }
- const response = await sendMail(email, subject, text(key), html(key))
+ const response = await sendMail(email, subject(l), text(l, key), html(l, key))
if (!response?.accepted?.length) { throw new Error('Something went wrong') }
res.status(204).send()
@@ -33,7 +33,6 @@ export default withSession(async (req, res) => {
res.status(200).json(user)
}
} catch (error) {
- console.log(error)
res.status(400).send()
}
break