Skip to content

Commit 2ed85d0

Browse files
committed
feat: add unit tests, integration tests, ESLint, Dependabot config, improve CI
1 parent 8237d8a commit 2ed85d0

File tree

7 files changed

+5762
-597
lines changed

7 files changed

+5762
-597
lines changed

backend/controllers/userController.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const jwt = require('jsonwebtoken');
22
const User = require('../models/User');
3+
const { validateEmail } = require('../utils/validate');
34

45
const generateToken = (id) => {
56
return jwt.sign({ id }, process.env.JWT_SECRET, {
@@ -28,9 +29,7 @@ const authUser = async (req, res) => {
2829
const registerUser = async (req, res) => {
2930
const { name, email, password } = req.body;
3031

31-
const atIndex = email.indexOf('@');
32-
const dotIndex = email.lastIndexOf('.');
33-
if (atIndex < 1 || dotIndex < atIndex + 2 || dotIndex === email.length - 1) {
32+
if (!validateEmail(email)) {
3433
return res.status(400).json({ message: 'Please enter a valid email' });
3534
}
3635

backend/eslint.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const js = require('@eslint/js');
2+
3+
module.exports = [
4+
js.configs.recommended,
5+
{
6+
rules: {
7+
'no-unused-vars': 'warn',
8+
'no-console': 'off',
9+
},
10+
},
11+
];

0 commit comments

Comments
 (0)