From 32c6d83e9ce8bdb3c2a23e5e3eb967c4cab1d3aa Mon Sep 17 00:00:00 2001 From: smdthiranjaya Date: Mon, 18 Mar 2024 20:37:05 +0530 Subject: [PATCH] New user endpoint added --- index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/index.js b/index.js index 890fe9a..578b32f 100644 --- a/index.js +++ b/index.js @@ -22,6 +22,17 @@ app.post('/login', async (req, res) => { } }); +app.post('/users', async (req, res) => { + const { accessToken } = req.body; + try { + const result = await pool.query('INSERT INTO users(accessToken) VALUES($1) RETURNING *', [accessToken]); + res.json(result.rows[0]); + } catch (err) { + console.error(err); + res.status(500).send('Server error'); + } +}); + const port = process.env.PORT || 3000; app.listen(port, () => { console.log(`Server is running on port ${port}`);