diff --git a/backend/apis/nodejs/src/app.js b/backend/apis/nodejs/src/app.js index 5557c24..ac56c25 100644 --- a/backend/apis/nodejs/src/app.js +++ b/backend/apis/nodejs/src/app.js @@ -78,12 +78,16 @@ app.use('/api', protectedRoutes); // Routes requiring token ===== END ROUTE HANDLING ===== */ -// Start the server -// Default port is 3000 -const port = process.env.API_SERVER_PORT || 3000; -app.listen(port, () => { - console.log(`Blink API server is running on port ${port}`); -}); +// Do not start the server in testing environment +// It will be started by the test suite +if (process.argv[2] != 'testing') { + // Start the server + // Default port is 3000 + const port = process.env.API_SERVER_PORT || 3000; + app.listen(port, () => { + console.log(`Blink API server is running on port ${port}`); + }); +} // Export the app for testing purposes module.exports = app; diff --git a/backend/apis/nodejs/src/models/person_model.js b/backend/apis/nodejs/src/models/person_model.js index c9558b4..58adb12 100644 --- a/backend/apis/nodejs/src/models/person_model.js +++ b/backend/apis/nodejs/src/models/person_model.js @@ -18,22 +18,23 @@ const bcrypt = require('bcrypt'); * Creates Person object by the specified fields * @param {*} email * @param {*} password - * @param {*} display_name - * @param {*} date_of_birth + * @param {*} displayName + * @param {*} dateOfBirth * @param {*} available * @param {*} enabled - * @param {*} place_of_living + * @param {*} placeOfLiving * @returns */ -function createPerson (email, password, display_name, date_of_birth, available, enabled, place_of_living) { +function createPerson (email, password, displayName, dateOfBirth, available, enabled, placeOfLiving, aboutMe) { const person = { email: email.toLowerCase(), password, - display_name, - date_of_birth, + display_name: displayName, + date_of_birth: dateOfBirth, available, enabled, - place_of_living + place_of_living: placeOfLiving, + about_me: aboutMe }; return person; } @@ -72,15 +73,7 @@ async function registerPerson (person, activationLink) { // and in the "ActivationLink" one, or in neither await knex.transaction(async (tr) => { const personIdResult = await tr('Person') - .insert({ - email: person.email.toLowerCase(), - password: person.password, - display_name: person.display_name, - date_of_birth: person.date_of_birth, - available: person.available, - enabled: person.enabled, - place_of_living: person.place_of_living - }) + .insert(person) .returning('id'); await tr('ActivationLink') .insert({ diff --git a/backend/apis/nodejs/src/routes/organization_routes.js b/backend/apis/nodejs/src/routes/organization_routes.js index 7665146..811380d 100644 --- a/backend/apis/nodejs/src/routes/organization_routes.js +++ b/backend/apis/nodejs/src/routes/organization_routes.js @@ -31,7 +31,7 @@ async function createOrganization (req, res) { try { const organization = organizationModel.createOrganization(req.body.name, req.body.location, req.body.description, req.body.is_hiring); await organizationModel.insertOrganization(organization, req.jwt.person_id); - return res.status(200).json({ Organization: organization }); + return res.status(200).json(organization); } catch (error) { console.error(`Error in function ${createOrganization.name}: ${error}`); res.status(500).json({ error: 'Internal server error' }); diff --git a/backend/apis/nodejs/src/routes/person_routes.js b/backend/apis/nodejs/src/routes/person_routes.js index ef39393..17c7910 100644 --- a/backend/apis/nodejs/src/routes/person_routes.js +++ b/backend/apis/nodejs/src/routes/person_routes.js @@ -56,12 +56,13 @@ async function registerPerson (req, res) { req.body.display_name, req.body.date_of_birth, req.body.available, - true, - req.body.place_of_living); + false, + req.body.place_of_living, + req.body.about_me); await personModel.registerPerson(personToInsert, activationLink); return res.status(200).json({ activationLink }); } catch (error) { - console.error(`Error in function ${console.trace()}: ${error}`); + console.error(`Error in function ${registerPerson.name}: ${error}`); res.status(500).json({ error: 'Internal server error' }); } } @@ -175,6 +176,10 @@ async function updatePerson (req, res) { updatePerson.place_of_living = req.body.place_of_living; } + if(req.body.about_me) { + updatePerson.about_me = req.body.about_me; + } + // If we are tying to change password, the old password must be provided if (req.body.old_password || req.body.new_password) { if(!req.body.old_password){ diff --git a/backend/sql/1-create_person.sql b/backend/sql/1-create_person.sql index 19eab6a..cd79f31 100644 --- a/backend/sql/1-create_person.sql +++ b/backend/sql/1-create_person.sql @@ -11,7 +11,8 @@ CREATE TABLE IF NOT EXISTS public."Person" date_of_birth date, available boolean, enabled boolean NOT NULL DEFAULT false, - place_of_living character varying(128) + place_of_living character varying(128), + about_me character varying(4096) ) TABLESPACE pg_default; diff --git a/frontend/vanilla/html/userprofile.html b/frontend/vanilla/html/userprofile.html index cd90d49..7c29ad0 100644 --- a/frontend/vanilla/html/userprofile.html +++ b/frontend/vanilla/html/userprofile.html @@ -12,11 +12,11 @@
Profile Picture

Name Surname

-

Web Developer

+

Title

About Me

-

I am a passionate web developer with experience in HTML, CSS, and JavaScript. I enjoy creating responsive and user-friendly websites.

+

About me

Experience

@@ -80,11 +80,10 @@ const data = await response.json(); if (response.ok){ - populateFields(data.display_name, data.email); + populateFields(data.display_name, data.email, data.about_me); document.body.style.display = 'block'; // Show page } else if (response.status == 401){ - console.error(data.error); window.location.href = 'login.html'; } else{ @@ -92,10 +91,11 @@ } } - function populateFields (displayName, email) { + function populateFields (displayName, email, aboutMe) { document.getElementById('displayName').textContent = displayName; document.title = `${displayName} - Blink` document.getElementById('email').textContent = email; + document.getElementById('aboutMe').textContent = aboutMe; } function editProfile () {