summaryrefslogtreecommitdiff
path: root/backend/index.js
diff options
context:
space:
mode:
authorxAlpharax <42233094+xAlpharax@users.noreply.github.com>2023-12-10 10:39:10 +0200
committerxAlpharax <42233094+xAlpharax@users.noreply.github.com>2023-12-10 10:39:10 +0200
commiteee6ceae4c018bec8f9c9131b1d51a2479ddd288 (patch)
tree953740d4ad32963f6f83268c883bdd3f3000ee19 /backend/index.js
parent17a5bdc4236eb0d2f2ca31a5fa6d743f9fe46ccc (diff)
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
Diffstat (limited to 'backend/index.js')
-rw-r--r--backend/index.js29
1 files changed, 28 insertions, 1 deletions
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}`)