Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ on:
branches:
- main
- develop
- "feature/**"
- "fix/**"
- "refactor/**"
- 'feature/**'
- 'fix/**'
- 'refactor/**'

pull_request:
branches:
Expand Down Expand Up @@ -48,8 +48,8 @@ jobs:
- name: Install dependencies
run: npm install

- name: Verify package
run: npm --version
- name: Run ESLint
run: npm run lint

- name: Security audit
if: matrix.node-version == '22.x'
Expand Down
10 changes: 10 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
"printWidth": 100,
"bracketSpacing": true,
"arrowParens": "always",
"endOfLine": "lf"
}
54 changes: 54 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import js from '@eslint/js';
import globals from 'globals';
import prettier from 'eslint-config-prettier';

export default [
js.configs.recommended,
prettier,
{
files: ['**/*.js'],
ignores: [
'node_modules/**',
'dist/**',
'coverage/**',
'src/emails/templates/**',
'eslint.config.js',
],
languageOptions: {
ecmaVersion: 2024,
sourceType: 'module',
globals: {
...globals.node,
...globals.jest,
process: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
},
},
rules: {
'no-console': 'off',
'no-unused-vars': 'off',
'no-var': 'off',
'prefer-const': 'off',
'no-duplicate-imports': 'off',
'no-multiple-empty-lines': 'off',
'no-trailing-spaces': 'off',
semi: 'off',
quotes: 'off',
indent: 'off',
'comma-dangle': 'off',
'arrow-spacing': 'off',
'object-curly-spacing': 'off',
'array-bracket-spacing': 'off',
'func-call-spacing': 'off',
'keyword-spacing': 'off',
'space-before-blocks': 'off',
'space-infix-ops': 'off',
'eol-last': 'off',
camelcase: 'off',
'no-undef': 'off',
'preserve-caught-error': 'off',
'no-useless-assignment': 'off',
},
},
];
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
"dev:worker": "nodemon worker.js",
"worker": "node worker.js",
"start": "node server.js",
"seed": "node src/scripts/seed.js"
"seed": "node src/scripts/seed.js",
"lint": "eslint . --config eslint.config.mjs",
"lint:fix": "eslint . --fix",
"format": "prettier --write \"src/**/*.js\" \"tests/**/*.js\" \"server.js\" \"worker.js\""
},
"engines": {
"node": ">=22.0.0",
Expand Down Expand Up @@ -41,7 +44,11 @@
"zod": "^4.5.4"
},
"devDependencies": {
"@eslint/js": "^10.0.1",
"dotenv": "^17.4.2",
"eslint": "^10.10.0",
"eslint-config-prettier": "^10.1.8",
"globals": "^17.12.0",
"nodemon": "^3.1.14",
"pino-pretty": "^13.1.3"
}
Expand Down
7 changes: 1 addition & 6 deletions src/emails/templates/baseLayout.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
export const baseLayout = ({
title,
preheader,
content,
year = new Date().getFullYear(),
}) => {
export const baseLayout = ({ title, preheader, content, year = new Date().getFullYear() }) => {

Check failure on line 1 in src/emails/templates/baseLayout.js

View workflow job for this annotation

GitHub Actions / Code Quality (20.x)

'preheader' is defined but never used

Check failure on line 1 in src/emails/templates/baseLayout.js

View workflow job for this annotation

GitHub Actions / Code Quality (22.x)

'preheader' is defined but never used
return `
<!DOCTYPE html>
<html lang="en">
Expand Down
21 changes: 9 additions & 12 deletions src/middlewares/security.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,21 @@
export const securityHeadersMiddleware = (req, res, next) => {
// Prevent browsers from MIME-sniffing
res.setHeader('X-Content-Type-Options', 'nosniff');

// Strict transport security (in production)
if (env.NODE_ENV === 'production') {
res.setHeader(
'Strict-Transport-Security',
'max-age=31536000; includeSubDomains; preload'
);
res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload');
}

// Prevent clickjacking
res.setHeader('X-Frame-Options', 'DENY');

// Content Security Policy
res.setHeader(
'Content-Security-Policy',
"default-src 'self'; img-src 'self' data: https:; style-src 'self' 'unsafe-inline'; script-src 'self'"
"default-src 'self'; img-src 'self' data: https:; style-src 'self' 'unsafe-inline'; script-src 'self'",
);

next();
};

Expand All @@ -33,21 +30,21 @@
export const sanitizeRequestMiddleware = (req, res, next) => {
const sanitize = (obj) => {
if (!obj || typeof obj !== 'object') return obj;

for (const key in obj) {
if (typeof obj[key] === 'string') {
// Remove null bytes and control characters
obj[key] = obj[key].replace(/[\u0000-\u001F\u007F]/g, '');

Check failure on line 37 in src/middlewares/security.middleware.js

View workflow job for this annotation

GitHub Actions / Code Quality (20.x)

Unexpected control character(s) in regular expression: \x00, \x1f

Check failure on line 37 in src/middlewares/security.middleware.js

View workflow job for this annotation

GitHub Actions / Code Quality (22.x)

Unexpected control character(s) in regular expression: \x00, \x1f
} else if (typeof obj[key] === 'object') {
sanitize(obj[key]);
}
}
return obj;
};

if (req.body) sanitize(req.body);
if (req.query) sanitize(req.query);
if (req.params) sanitize(req.params);

next();
};
Loading