experience update

This commit is contained in:
Alessandro Ferro
2025-04-18 15:24:40 +02:00
parent 597a9c1dae
commit ade6a05408
6 changed files with 34 additions and 968 deletions

View File

@ -7,7 +7,7 @@ meta {
patch {
url: http://localhost:3000/api/people/me
body: json
auth: none
auth: inherit
}
headers {

View File

@ -1,957 +0,0 @@
{
"name": "BlinkApiCollection",
"version": "1",
"items": [
{
"type": "http",
"name": "ActivatePerson",
"filename": "ActivatePerson.bru",
"seq": 26,
"request": {
"url": "http://localhost:3000/api/people/me/activation?q=3ac9c204de1676b54163ed8015c7af00",
"method": "GET",
"headers": [
{
"name": "Content-Type",
"value": "application/json",
"enabled": true
},
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [
{
"name": "q",
"value": "3ac9c204de1676b54163ed8015c7af00",
"type": "query",
"enabled": true
}
],
"body": {
"mode": "json",
"json": "",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "AddOrganizationAdmin",
"filename": "AddOrganizationAdmin.bru",
"seq": 12,
"request": {
"url": "http://localhost:3000/api/organizations/1/admins",
"method": "POST",
"headers": [
{
"name": "Content-Type",
"value": "application/json",
"enabled": true
},
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [],
"body": {
"mode": "json",
"json": "{\n \"personId\" : \"2\"\n}",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "ChangeApplicationStatus",
"filename": "ChangeApplicationStatus.bru",
"seq": 7,
"request": {
"url": "http://localhost:3000/api/organizations/joboffers/applications/5",
"method": "PATCH",
"headers": [],
"params": [],
"body": {
"mode": "json",
"json": "{\n \"status\": \"ACCEPTED\"\n}",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "CreateApplication",
"filename": "CreateApplication.bru",
"seq": 10,
"request": {
"url": "http://localhost:3000/api/organizations/joboffers/1/applications",
"method": "POST",
"headers": [],
"params": [],
"body": {
"mode": "none",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "CreateJobOffer",
"filename": "CreateJobOffer.bru",
"seq": 6,
"request": {
"url": "http://localhost:3000/api/organizations/1/joboffers",
"method": "POST",
"headers": [
{
"name": "Content-Type",
"value": "application/json",
"enabled": true
},
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [],
"body": {
"mode": "json",
"json": "{\n \"title\" : \"NodeJS developer\",\n \"description\" : \"We are looking for NodeJS developers which can help us build Blink\",\n \"salaryFrequency\": \"YEARLY\",\n \"salary\": [20000, 23000],\n \"salaryCurrency\": \"EUR\",\n \"location\" : \"Rome\",\n \"remote\": \"PARTIALLY\",\n \"contractType\": \"PART-TIME\",\n \"tags\" : [\"javascript\"]\n}",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "CreateOrganization",
"filename": "CreateOrganization.bru",
"seq": 16,
"request": {
"url": "http://localhost:3000/api/organizations",
"method": "POST",
"headers": [
{
"name": "Content-Type",
"value": "application/json",
"enabled": true
},
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [],
"body": {
"mode": "json",
"json": "{\n \"name\" : \"Blink Inc.\",\n \"location\" : \"Napoli, Italy\",\n \"description\" : \"Blink is a privacy-respecting business-oriented social media platform focused on fostering connections between businesses and individuals, propelling careers and sparking innovation in the professional world.\"\n}",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "inherit"
}
}
},
{
"type": "http",
"name": "DeleteApplication",
"filename": "DeleteApplication.bru",
"seq": 9,
"request": {
"url": "http://localhost:3000/api/organizations/joboffers/applications/6",
"method": "DELETE",
"headers": [],
"params": [],
"body": {
"mode": "json",
"json": "{\n \"jobApplicationId\": 1\n}",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "DeleteContactInfo",
"filename": "DeleteContactInfo.bru",
"seq": 18,
"request": {
"url": "http://localhost:3000/api/people/contactinfos/2",
"method": "DELETE",
"headers": [],
"params": [],
"body": {
"mode": "none",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "DeleteJobOffer",
"filename": "DeleteJobOffer.bru",
"seq": 5,
"request": {
"url": "http://localhost:3000/api/organizations/joboffers/3",
"method": "DELETE",
"headers": [
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [],
"body": {
"mode": "none",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "DeleteOrganization",
"filename": "DeleteOrganization.bru",
"seq": 13,
"request": {
"url": "http://localhost:3000/api/organizations/1",
"method": "DELETE",
"headers": [
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [],
"body": {
"mode": "none",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "DeletePerson",
"filename": "DeletePerson.bru",
"seq": 20,
"request": {
"url": "http://localhost:3000/api/people/me",
"method": "DELETE",
"headers": [
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [],
"body": {
"mode": "none",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "FilterOrganizationByPrefix",
"filename": "FilterOrganizationByPrefix.bru",
"seq": 1,
"request": {
"url": "http://localhost:3000/api/organizations/filter",
"method": "POST",
"headers": [
{
"name": "Content-Type",
"value": "application/json",
"enabled": true
},
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [],
"body": {
"mode": "json",
"json": "{\n \"name\" : \"bli\"\n}",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "GetApplicantsByJobOffer",
"filename": "GetApplicantsByJobOffer.bru",
"seq": 2,
"request": {
"url": "http://localhost:3000/api/organizations/joboffers/1/applications",
"method": "GET",
"headers": [],
"params": [],
"body": {
"mode": "json",
"json": "",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "GetApplicantsByOrganization",
"filename": "GetApplicantsByOrganization.bru",
"seq": 3,
"request": {
"url": "http://localhost:3000/api/organizations/1/joboffers/applications",
"method": "GET",
"headers": [],
"params": [],
"body": {
"mode": "json",
"json": "",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "GetContactInfosByPerson",
"filename": "GetContactInfosByPerson.bru",
"seq": 17,
"request": {
"url": "http://localhost:3000/api/people/1/contactinfos",
"method": "GET",
"headers": [],
"params": [],
"body": {
"mode": "none",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "GetJobOffers",
"filename": "GetJobOffers.bru",
"seq": 4,
"request": {
"url": "http://localhost:3000/api/organizations/1/joboffers/",
"method": "GET",
"headers": [
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [],
"body": {
"mode": "none",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "GetMyApplications",
"filename": "GetMyApplications.bru",
"seq": 8,
"request": {
"url": "http://localhost:3000/api/organizations/joboffers/applications/mine",
"method": "GET",
"headers": [],
"params": [],
"body": {
"mode": "none",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "GetMyself",
"filename": "GetMyself.bru",
"seq": 21,
"request": {
"url": "http://localhost:3000/api/people/me",
"method": "GET",
"headers": [
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [],
"body": {
"mode": "none",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "inherit"
}
}
},
{
"type": "http",
"name": "GetOrganization",
"filename": "GetOrganization.bru",
"seq": 15,
"request": {
"url": "http://localhost:3000/api/organizations/1",
"method": "GET",
"headers": [
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [],
"body": {
"mode": "none",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "GetPerson",
"filename": "GetPerson.bru",
"seq": 22,
"request": {
"url": "http://localhost:3000/api/people/1/details",
"method": "GET",
"headers": [
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [],
"body": {
"mode": "none",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "InsertContactInfo",
"filename": "InsertContactInfo.bru",
"seq": 19,
"request": {
"url": "http://localhost:3000/api/people/myself/contactinfos",
"method": "POST",
"headers": [],
"params": [],
"body": {
"mode": "json",
"json": "{\n \"content\": \"www.john.com\",\n \"info_type\": \"WEBSITE\"\n}",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "inherit"
}
}
},
{
"type": "http",
"name": "Login",
"filename": "Login.bru",
"seq": 27,
"request": {
"url": "http://localhost:3000/api/people/me/token",
"method": "POST",
"headers": [
{
"name": "Content-Type",
"value": "application/json",
"enabled": true
},
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [],
"body": {
"mode": "json",
"json": "{\n \"email\": \"john@mail.org\",\n \"password\": \"password\"\n}",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "Register",
"filename": "Register.bru",
"seq": 28,
"request": {
"url": "http://localhost:3000/api/people",
"method": "POST",
"headers": [
{
"name": "Content-Type",
"value": "application/json",
"enabled": true
},
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [],
"body": {
"mode": "json",
"json": "{\n \"email\" : \"john@mail.org\",\n \"password\" : \"password\",\n \"displayName\" : \"John Doe\",\n \"aboutMe\" : \"I am a passionate software engineer\",\n \"qualification\" : \"Software Engineer\"\n}",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "RemoveOrganizationAdmin",
"filename": "RemoveOrganizationAdmin.bru",
"seq": 11,
"request": {
"url": "http://localhost:3000/api/organizations/1/admins/me",
"method": "DELETE",
"headers": [
{
"name": "Content-Type",
"value": "application/json",
"enabled": true
},
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [],
"body": {
"mode": "json",
"json": "",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "RequestNewPassword",
"filename": "RequestNewPassword.bru",
"seq": 24,
"request": {
"url": "http://localhost:3000/api/resetpassword/request",
"method": "POST",
"headers": [
{
"name": "Content-Type",
"value": "application/json",
"enabled": true
},
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [],
"body": {
"mode": "json",
"json": "{\n \"email\": \"john@mail.org\"\n}",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "ResetNewPassword",
"filename": "ResetNewPassword.bru",
"seq": 23,
"request": {
"url": "http://localhost:3000/api/resetpassword/reset",
"method": "POST",
"headers": [
{
"name": "Content-Type",
"value": "application/json",
"enabled": true
},
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [],
"body": {
"mode": "json",
"json": "{\n \"secret\": \"360837853e2d3cf799c709b44720b4e3\",\n \"password\": \"password\"\n}",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "UpdateOrganization",
"filename": "UpdateOrganization.bru",
"seq": 14,
"request": {
"url": "http://localhost:3000/api/organizations/1",
"method": "PATCH",
"headers": [
{
"name": "Content-Type",
"value": "application/json",
"enabled": true
},
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [],
"body": {
"mode": "json",
"json": "{\n \"name\": \"Blink Inc.\",\n \"location\": \"Naples (Campania), Italy\",\n \"description\": \"Blink is a privacy-respecting business-oriented social media platform focused on fostering connections between businesses and individuals, propelling careers and sparking innovation in the professional world. Think of it as an open-source alternative to LinkedIn.\"\n}",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "http",
"name": "UpdatePerson",
"filename": "UpdatePerson.bru",
"seq": 25,
"request": {
"url": "http://localhost:3000/api/people/me",
"method": "PATCH",
"headers": [
{
"name": "Content-Type",
"value": "application/json",
"enabled": true
},
{
"name": "User-Agent",
"value": "insomnia/2023.5.8",
"enabled": true
}
],
"params": [],
"body": {
"mode": "json",
"json": "{\n \"displayName\": \"John Junior Doe III\",\n \"dateOfBirth\": \"1970-01-01\",\n \"openToWork\": \"false\",\n \"placeOfLiving\": \"Oslo, Norway\",\n \"aboutMe\": \"I am a passionate software engineer, but I also love art and music\",\n \"new_password\": \"password\",\n \"old_password\": \"password\",\n \"qualification\" : \"Software Engineer at Blink Inc. & Google LLC\",\n \"visibility\": \"EVERYONE\",\n \"oldPassword\": \"password\",\n \"newPassword\": \"password\"\n}",
"formUrlEncoded": [],
"multipartForm": [],
"file": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"docs": "",
"auth": {
"mode": "none"
}
}
},
{
"type": "folder",
"name": "bruno",
"filename": "bruno"
}
],
"environments": [],
"root": {
"request": {
"auth": {
"mode": "bearer",
"bearer": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjMsImlhdCI6MTc0Mjg0Nzc2OCwiZXhwIjoxNzQyODc2NTY4fQ.XsjVJtU0nPhJBdnsepkLgCj-OCny9pMLl2CmDnotB2c"
}
}
}
},
"brunoConfig": {
"version": "1",
"name": "Blink",
"type": "collection",
"ignore": [
"node_modules",
".git"
]
}
}

View File

@ -17,8 +17,8 @@ function createExperience(title, description, organizationId, organizationName,
const experience = {
title,
description,
organization_id: organizationId,
organization_name: organizationName,
organization_id: organizationId, // Either OrganizationId or OrganizationName should be set, not both (TODO in validator)
organization_name: organizationName, // Either OrganizationId or OrganizationName should be set, not both (TODO in validator)
date,
person_id,
type
@ -33,10 +33,33 @@ async function insert(experience){
return insertedExperience[0];
}
async function findById(experienceId) {
return await knex('Experience').where({
id: experienceId
}).select().first();
}
async function remove(experienceId) {
await knex('Experience')
.where({
id: experienceId
})
.del();
}
async function update(experience) {
await knex('Experience')
.where('id', experience.id)
.update(experience);
}
// Exporting a function
// means making a JavaScript function defined in one
// module available for use in another module.
module.exports = {
createExperience,
insert
insert,
findById,
remove,
update
};

View File

@ -120,9 +120,9 @@ async function authenticate(email, password) {
* @param {*} person The Person to update
* @param {*} person_id The database id of the Person to update
*/
async function update(person, person_id) {
async function update(person) {
await knex('Person')
.where('id', person_id)
.where('id', person.id)
.update(person);
}

View File

@ -278,7 +278,8 @@ async function updatePerson(req, res) {
});
}
await Person.update(updatePerson, req.jwt.person_id);
updatePerson.id = req.jwt.person_id;
await Person.update(updatePerson);
return res.status(204).send();
} catch (error) {
console.error(`Error in function ${updatePerson.name}: ${error}`);

View File

@ -55,7 +55,6 @@ function extractToken(req, res, next) {
error: 'No token provided'
});
}
}
module.exports = {