-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6185c4
commit 88171ca
Showing
15 changed files
with
220 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
server/Mental Health api/adapters/controllers/userController.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const fetchmoodData = require("../../application/usecases/getmoodData"); | ||
class UserController{ | ||
|
||
static async usernames(req,res){ | ||
try{ | ||
const { username }= req.params; | ||
const moodData = new fetchmoodData(); | ||
const moodata = await moodData.execute(username); | ||
|
||
return res.json(moodata); | ||
} | ||
|
||
catch(err){ | ||
res.status(500).json({error: err.message}); | ||
} | ||
} | ||
} | ||
|
||
module.exports = UserController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const UserController = require('../../adapters/controllers/userController'); | ||
|
||
const router = require('express').Router(); | ||
|
||
router.get('/:username',UserController.usernames); | ||
|
||
module.exports = router; |
24 changes: 24 additions & 0 deletions
24
server/Mental Health api/application/usecases/getmoodData.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const UserName = require("../../domain/entities/user"); | ||
const { mooddatainfo } = require("../../infrastructure/db-fast/queries/userQueries"); | ||
const UseCaseInt = require("../interfaces/UseCaseInt"); | ||
|
||
class MoodData extends UseCaseInt{ | ||
|
||
async execute(username) { | ||
|
||
const moodData = await mooddatainfo(username); | ||
return moodData; | ||
// return moodData.map((data) => new UserName ( | ||
// { | ||
// happy: data.happy, | ||
// sad: data.sad, | ||
// neutral: data.neutral, | ||
// calm: data.calm, | ||
// relax: data.relax, | ||
// focus: data.focus, | ||
|
||
// })); | ||
} | ||
} | ||
|
||
module.exports = MoodData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class UserName{ | ||
constructor(happy,sad,neutral,calm,relax,focus){ | ||
|
||
this.happy = happy; | ||
this.sad = sad; | ||
this.neutral = neutral; | ||
this.calm = calm; | ||
this.relax = relax; | ||
this.focus = focus; | ||
|
||
} | ||
} | ||
|
||
module.exports = UserName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const Redis = require('redis'); | ||
|
||
const redis = Redis.createClient({ | ||
socket: { | ||
host: 'redis-15193.c309.us-east-2-1.ec2.redns.redis-cloud.com', | ||
port: 15193, | ||
}, | ||
password: 'qJ3EEzX4aQ0LwiPCeP5sMAUZycRiNOK1' | ||
}); | ||
|
||
redis.on('connect', () => { | ||
console.log('Connected to Redis successfully!'); | ||
}); | ||
|
||
redis.on('error', (err) => { | ||
console.error('Redis connection error:', err); | ||
}); | ||
|
||
(async () => { | ||
await redis.connect(); | ||
})(); | ||
|
||
module.exports = redis; |
13 changes: 13 additions & 0 deletions
13
server/Mental Health api/infrastructure/db-fast/queries/userQueries.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const redis = require('..'); | ||
|
||
const mooddatainfo = async (username) => { | ||
try { | ||
const mooddatas = await redis.get(username); | ||
console.log('Raw value:', mooddatas); | ||
return value; | ||
} catch (err) { | ||
console.error('Error fetching the value:', err); | ||
} | ||
} | ||
|
||
module.exports = {mooddatainfo}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters