Add simple test with Mocha
This commit is contained in:
6
index.js
6
index.js
@@ -67,7 +67,7 @@ DB.getDB.then((DB) => {
|
||||
app.get('/', sessionChecker, async (req, res) => {
|
||||
try {
|
||||
const userInfo = req.userInfo;
|
||||
if(!userInfo) {
|
||||
if (!userInfo) {
|
||||
// This should not happend, since the sessionChecker should redirect to login
|
||||
return res.status(401).json({ status: "Unauthorized" });
|
||||
}
|
||||
@@ -146,7 +146,7 @@ DB.getDB.then((DB) => {
|
||||
app.post('/token/', sessionChecker, async (req, res) => {
|
||||
try {
|
||||
const profileid = getProfileId(req);
|
||||
const { token } = req.body;
|
||||
const { token } = req.body;
|
||||
// Validate token presence
|
||||
if (!token) {
|
||||
return res.status(400).json({ status: 'Token is required' });
|
||||
@@ -186,3 +186,5 @@ DB.getDB.then((DB) => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
// Export the app for testing purposes
|
||||
module.exports = { app, mongoDB: DB };
|
||||
Reference in New Issue
Block a user