From eee6ceae4c018bec8f9c9131b1d51a2479ddd288 Mon Sep 17 00:00:00 2001 From: xAlpharax <42233094+xAlpharax@users.noreply.github.com> Date: Sun, 10 Dec 2023 10:39:10 +0200 Subject: Made the backend to point to the frontend after google authentication. Changes to be committed: modified: backend/index.js new file: backend/prisma/migrations/20231210070441_mig1/migration.sql new file: backend/prisma/migrations/migration_lock.toml --- backend/index.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'backend/index.js') diff --git a/backend/index.js b/backend/index.js index 769a692..51c9f9d 100644 --- a/backend/index.js +++ b/backend/index.js @@ -19,7 +19,7 @@ app.use(passport.session()); app.set('view engine', 'ejs'); -app.get('/success', (req, res) => res.redirect("")); +app.get('/success', (req, res) => res.redirect("http://localhost:3000/")); app.get('/error', (req, res) => res.send("error logging in")); passport.serializeUser(function(user, cb) { @@ -102,6 +102,33 @@ app.post('/courses', async (req, res) => { } }) +app.get('/user_data/:param', async (req, res) => { + var request_parameter = req.params.param ; + try { + switch (request_parameter) { + case 'all': + var response = await prisma.course.findMany(); + res.send(response); + break; + default: + var response = await prisma.user.findMany({ + where:{ + id: { + equals: parseInt(request_parameter) + }, + include: { + user_data: true + } + } + }); + res.send(response); + break; + } + } catch (error) { + res.status(500); + res.send({"error" : "Nu au fost gasite rezultate"}); + } +}) app.listen(port, () => { console.log(`Example app listening on port ${port}`) -- cgit v1.2.3