diff options
author | Akshay <[email protected]> | 2024-11-08 22:40:41 +0000 |
---|---|---|
committer | Akshay" (aider) <[email protected]> | 2024-11-08 22:40:41 +0000 |
commit | 105b68e6a2df38cd47d7f9a5f07248e56bc2dc8a (patch) | |
tree | 31a5daf416894d393b4741bcbba58b17503e7ead | |
parent | ab92c3f6c19e80fe554cfe8d7b109b1196de1fdb (diff) |
fix: log error details on user registration failure
-rw-r--r-- | src/routes/index.js | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/routes/index.js b/src/routes/index.js index 01101f5..c29933e 100644 --- a/src/routes/index.js +++ b/src/routes/index.js | |||
@@ -87,6 +87,7 @@ router.post("/register", async (req, res) => { | |||
87 | ]); | 87 | ]); |
88 | res.status(201).send("User registered successfully"); | 88 | res.status(201).send("User registered successfully"); |
89 | } catch (err) { | 89 | } catch (err) { |
90 | console.log(err); | ||
90 | res.status(400).send("Error registering user"); | 91 | res.status(400).send("Error registering user"); |
91 | } | 92 | } |
92 | }); | 93 | }); |
@@ -115,10 +116,10 @@ router.post("/subscribe", async (req, res) => { | |||
115 | .get(); | 116 | .get(); |
116 | if (user) { | 117 | if (user) { |
117 | const existingSubscription = db | 118 | const existingSubscription = db |
118 | .query("SELECT * FROM subscriptions WHERE user_id = ? AND subreddit = ?", [ | 119 | .query( |
119 | user.id, | 120 | "SELECT * FROM subscriptions WHERE user_id = ? AND subreddit = ?", |
120 | subreddit, | 121 | [user.id, subreddit], |
121 | ]) | 122 | ) |
122 | .get(); | 123 | .get(); |
123 | if (existingSubscription) { | 124 | if (existingSubscription) { |
124 | res.status(400).send("Already subscribed to this subreddit"); | 125 | res.status(400).send("Already subscribed to this subreddit"); |
@@ -141,10 +142,10 @@ router.post("/unsubscribe", async (req, res) => { | |||
141 | .get(); | 142 | .get(); |
142 | if (user) { | 143 | if (user) { |
143 | const existingSubscription = db | 144 | const existingSubscription = db |
144 | .query("SELECT * FROM subscriptions WHERE user_id = ? AND subreddit = ?", [ | 145 | .query( |
145 | user.id, | 146 | "SELECT * FROM subscriptions WHERE user_id = ? AND subreddit = ?", |
146 | subreddit, | 147 | [user.id, subreddit], |
147 | ]) | 148 | ) |
148 | .get(); | 149 | .get(); |
149 | if (existingSubscription) { | 150 | if (existingSubscription) { |
150 | db.run("DELETE FROM subscriptions WHERE user_id = ? AND subreddit = ?", [ | 151 | db.run("DELETE FROM subscriptions WHERE user_id = ? AND subreddit = ?", [ |