Skip to content

Commit

Permalink
feat(entry): provides tone for each sentence in the entry
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali-Aftab committed Feb 17, 2021
1 parent 03d8d48 commit bf714c3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
32 changes: 32 additions & 0 deletions server/controllers/entry.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,35 @@ exports.listAllUserEntry = async (req, res) => {
});
}
};

exports.listAllSenForOneEntry = async (req, res) => {
try {
const { userId } = req;
let { entryToneId } = req.params;
const allSentences = await SentenceTone.findAll({
where: {
userId,
entryToneId,
},
});
if (allSentences.length === 0) {
res.json({
message:
"Could not find entry, please check to see if your entryToneId is correct!",
data: allSentences,
});
} else {
res.json({
message:
"You have received your tone analyzer for each sentence of your entry!",
data: allSentences,
});
}
} catch (error) {
console.log(error);
res.json({
error,
message: "Error occured when grabbing the sentences for your entry!",
});
}
};
6 changes: 6 additions & 0 deletions server/routes/entry.route.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const {
postNewEntry,
listAllUserEntry,
listAllSenForOneEntry,
} = require("../controllers/entry.controller");
const { authJwt, sendEntryToIBM } = require("../middleware");

Expand All @@ -21,4 +22,9 @@ module.exports = function (app) {
);

app.get("/api/entry/listAll", [authJwt.verifyToken], listAllUserEntry);
app.get(
"/api/entry/sentencetone/:entryToneId",
[authJwt.verifyToken],
listAllSenForOneEntry
);
};

0 comments on commit bf714c3

Please sign in to comment.