Skip to content
Open
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
187 changes: 184 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@
"mongodb": "^6.5.0",
"mongoose": "^8.10.0",
"morgan": "^1.10.1",
"nodemailer": "^6.9.14",
"passport": "^0.7.0",
"passport-google-oauth20": "^2.0.0",
"redis": "^5.6.1",
"winston": "^3.17.0",
"socket.io": "^4.7.5",
"nodemailer": "^6.9.14"
"sanitize-html": "^2.17.0",
"socket.io": "^4.7.5",
"winston": "^3.17.0"
},
"devDependencies": {
"jest": "^30.0.5",
Expand Down
8 changes: 8 additions & 0 deletions public/css/main.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@

#editor {
min-height: 200px;
background: #fff;
border: 1px solid #ccc;
border-radius: 6px;
}

:root{
--background-color : #EDC7B7;
--bs-primary-rgb: #AC3B61;
Expand Down
33 changes: 28 additions & 5 deletions server/controllers/dashboardController.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const sanitizeHtml = require("sanitize-html");

const noteService = require('../services/noteService');
const Note = require('../models/Notes');
const { asyncHandler } = require('../utils/errors');
Expand Down Expand Up @@ -82,9 +84,18 @@ exports.dashboardViewNote = asyncHandler(async (req, res) => {
* Update specific note
*/
exports.dashboardUpdateNote = asyncHandler(async (req, res) => {
const cleanBody = sanitizeHtml(req.body.body, {
allowedTags: sanitizeHtml.defaults.allowedTags.concat([ 'img', 'h1', 'h2', 'u', 'span' ]),
allowedAttributes: {
...sanitizeHtml.defaults.allowedAttributes,
img: ['src', 'alt', 'width', 'height'],
span: ['class'],
}
});

await noteService.updateNote(req.params.id, req.user.id, {
title: req.body.title,
body: req.body.body
body: cleanBody
});

req.session.successMessage = 'Note updated successfully!';
Expand Down Expand Up @@ -123,10 +134,22 @@ exports.dashboardAddNote = asyncHandler(async (req, res) => {
* Create new note
*/
exports.dashboardAddNotePost = asyncHandler(async (req, res) => {
await noteService.createNote({
title: req.body.title,
body: req.body.body
}, req.user.id);
const cleanBody = sanitizeHtml(req.body.body, {
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'h1', 'h2', 'u', 'span']),
allowedAttributes: {
...sanitizeHtml.defaults.allowedAttributes,
img: ['src', 'alt', 'width', 'height'],
span: ['class'],
},
});

await noteService.createNote(
{
title: req.body.title,
body: cleanBody,
},
req.user.id
);

req.session.successMessage = 'Note created successfully!';
res.redirect('/dashboard');
Expand Down
Loading