diff --git a/backend/apis/BlinkApiCollection/ActivatePerson.bru b/backend/apis/BlinkApiCollection/ActivatePerson.bru new file mode 100644 index 0000000..6f49a69 --- /dev/null +++ b/backend/apis/BlinkApiCollection/ActivatePerson.bru @@ -0,0 +1,20 @@ +meta { + name: ActivatePerson + type: http + seq: 27 +} + +get { + url: http://localhost:3000/api/people/me/activation?q=3ac9c204de1676b54163ed8015c7af00 + body: json + auth: none +} + +params:query { + q: 3ac9c204de1676b54163ed8015c7af00 +} + +headers { + Content-Type: application/json + User-Agent: insomnia/2023.5.8 +} diff --git a/backend/apis/BlinkApiCollection/AddOrganizationAdmin.bru b/backend/apis/BlinkApiCollection/AddOrganizationAdmin.bru new file mode 100644 index 0000000..32902ba --- /dev/null +++ b/backend/apis/BlinkApiCollection/AddOrganizationAdmin.bru @@ -0,0 +1,22 @@ +meta { + name: AddOrganizationAdmin + type: http + seq: 13 +} + +post { + url: http://localhost:3000/api/organizations/1/admins + body: json + auth: none +} + +headers { + Content-Type: application/json + User-Agent: insomnia/2023.5.8 +} + +body:json { + { + "personId" : "2" + } +} diff --git a/backend/apis/BlinkApiCollection/ChangeApplicationStatus.bru b/backend/apis/BlinkApiCollection/ChangeApplicationStatus.bru new file mode 100644 index 0000000..b5e927f --- /dev/null +++ b/backend/apis/BlinkApiCollection/ChangeApplicationStatus.bru @@ -0,0 +1,17 @@ +meta { + name: ChangeApplicationStatus + type: http + seq: 8 +} + +patch { + url: http://localhost:3000/api/organizations/joboffers/applications/5 + body: json + auth: none +} + +body:json { + { + "status": "ACCEPTED" + } +} diff --git a/backend/apis/BlinkApiCollection/CreateApplication.bru b/backend/apis/BlinkApiCollection/CreateApplication.bru new file mode 100644 index 0000000..6ef519b --- /dev/null +++ b/backend/apis/BlinkApiCollection/CreateApplication.bru @@ -0,0 +1,11 @@ +meta { + name: CreateApplication + type: http + seq: 11 +} + +post { + url: http://localhost:3000/api/organizations/joboffers/1/applications + body: none + auth: none +} diff --git a/backend/apis/BlinkApiCollection/CreateExperience.bru b/backend/apis/BlinkApiCollection/CreateExperience.bru new file mode 100644 index 0000000..cd6a21a --- /dev/null +++ b/backend/apis/BlinkApiCollection/CreateExperience.bru @@ -0,0 +1,11 @@ +meta { + name: CreateExperience + type: http + seq: 1 +} + +post { + url: http://localhost:3000/api/experiences + body: none + auth: inherit +} diff --git a/backend/apis/BlinkApiCollection/CreateJobOffer.bru b/backend/apis/BlinkApiCollection/CreateJobOffer.bru new file mode 100644 index 0000000..619fa38 --- /dev/null +++ b/backend/apis/BlinkApiCollection/CreateJobOffer.bru @@ -0,0 +1,30 @@ +meta { + name: CreateJobOffer + type: http + seq: 7 +} + +post { + url: http://localhost:3000/api/organizations/1/joboffers + body: json + auth: none +} + +headers { + Content-Type: application/json + User-Agent: insomnia/2023.5.8 +} + +body:json { + { + "title" : "NodeJS developer", + "description" : "We are looking for NodeJS developers which can help us build Blink", + "salaryFrequency": "YEARLY", + "salary": [20000, 23000], + "salaryCurrency": "EUR", + "location" : "Rome", + "remote": "PARTIALLY", + "contractType": "PART-TIME", + "tags" : ["javascript"] + } +} diff --git a/backend/apis/BlinkApiCollection/CreateOrganization.bru b/backend/apis/BlinkApiCollection/CreateOrganization.bru new file mode 100644 index 0000000..f8ba317 --- /dev/null +++ b/backend/apis/BlinkApiCollection/CreateOrganization.bru @@ -0,0 +1,24 @@ +meta { + name: CreateOrganization + type: http + seq: 17 +} + +post { + url: http://localhost:3000/api/organizations + body: json + auth: inherit +} + +headers { + Content-Type: application/json + User-Agent: insomnia/2023.5.8 +} + +body:json { + { + "name" : "Blink Inc.", + "location" : "Napoli, Italy", + "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." + } +} diff --git a/backend/apis/BlinkApiCollection/DeleteApplication.bru b/backend/apis/BlinkApiCollection/DeleteApplication.bru new file mode 100644 index 0000000..0a620ae --- /dev/null +++ b/backend/apis/BlinkApiCollection/DeleteApplication.bru @@ -0,0 +1,17 @@ +meta { + name: DeleteApplication + type: http + seq: 10 +} + +delete { + url: http://localhost:3000/api/organizations/joboffers/applications/6 + body: json + auth: none +} + +body:json { + { + "jobApplicationId": 1 + } +} diff --git a/backend/apis/BlinkApiCollection/DeleteContactInfo.bru b/backend/apis/BlinkApiCollection/DeleteContactInfo.bru new file mode 100644 index 0000000..feb004d --- /dev/null +++ b/backend/apis/BlinkApiCollection/DeleteContactInfo.bru @@ -0,0 +1,11 @@ +meta { + name: DeleteContactInfo + type: http + seq: 19 +} + +delete { + url: http://localhost:3000/api/people/contactinfos/2 + body: none + auth: none +} diff --git a/backend/apis/BlinkApiCollection/DeleteJobOffer.bru b/backend/apis/BlinkApiCollection/DeleteJobOffer.bru new file mode 100644 index 0000000..29c8903 --- /dev/null +++ b/backend/apis/BlinkApiCollection/DeleteJobOffer.bru @@ -0,0 +1,15 @@ +meta { + name: DeleteJobOffer + type: http + seq: 6 +} + +delete { + url: http://localhost:3000/api/organizations/joboffers/3 + body: none + auth: none +} + +headers { + User-Agent: insomnia/2023.5.8 +} diff --git a/backend/apis/BlinkApiCollection/DeleteOrganization.bru b/backend/apis/BlinkApiCollection/DeleteOrganization.bru new file mode 100644 index 0000000..89fef00 --- /dev/null +++ b/backend/apis/BlinkApiCollection/DeleteOrganization.bru @@ -0,0 +1,15 @@ +meta { + name: DeleteOrganization + type: http + seq: 14 +} + +delete { + url: http://localhost:3000/api/organizations/1 + body: none + auth: none +} + +headers { + User-Agent: insomnia/2023.5.8 +} diff --git a/backend/apis/BlinkApiCollection/DeletePerson.bru b/backend/apis/BlinkApiCollection/DeletePerson.bru new file mode 100644 index 0000000..890aa20 --- /dev/null +++ b/backend/apis/BlinkApiCollection/DeletePerson.bru @@ -0,0 +1,15 @@ +meta { + name: DeletePerson + type: http + seq: 21 +} + +delete { + url: http://localhost:3000/api/people/me + body: none + auth: none +} + +headers { + User-Agent: insomnia/2023.5.8 +} diff --git a/backend/apis/BlinkApiCollection/FilterOrganizationByPrefix.bru b/backend/apis/BlinkApiCollection/FilterOrganizationByPrefix.bru new file mode 100644 index 0000000..8e61ab3 --- /dev/null +++ b/backend/apis/BlinkApiCollection/FilterOrganizationByPrefix.bru @@ -0,0 +1,22 @@ +meta { + name: FilterOrganizationByPrefix + type: http + seq: 2 +} + +post { + url: http://localhost:3000/api/organizations/filter + body: json + auth: none +} + +headers { + Content-Type: application/json + User-Agent: insomnia/2023.5.8 +} + +body:json { + { + "name" : "bli" + } +} diff --git a/backend/apis/BlinkApiCollection/GetApplicantsByJobOffer.bru b/backend/apis/BlinkApiCollection/GetApplicantsByJobOffer.bru new file mode 100644 index 0000000..ccd21f3 --- /dev/null +++ b/backend/apis/BlinkApiCollection/GetApplicantsByJobOffer.bru @@ -0,0 +1,11 @@ +meta { + name: GetApplicantsByJobOffer + type: http + seq: 3 +} + +get { + url: http://localhost:3000/api/organizations/joboffers/1/applications + body: json + auth: none +} diff --git a/backend/apis/BlinkApiCollection/GetApplicantsByOrganization.bru b/backend/apis/BlinkApiCollection/GetApplicantsByOrganization.bru new file mode 100644 index 0000000..04dafb7 --- /dev/null +++ b/backend/apis/BlinkApiCollection/GetApplicantsByOrganization.bru @@ -0,0 +1,11 @@ +meta { + name: GetApplicantsByOrganization + type: http + seq: 4 +} + +get { + url: http://localhost:3000/api/organizations/1/joboffers/applications + body: json + auth: none +} diff --git a/backend/apis/BlinkApiCollection/GetContactInfosByPerson.bru b/backend/apis/BlinkApiCollection/GetContactInfosByPerson.bru new file mode 100644 index 0000000..fbf0039 --- /dev/null +++ b/backend/apis/BlinkApiCollection/GetContactInfosByPerson.bru @@ -0,0 +1,11 @@ +meta { + name: GetContactInfosByPerson + type: http + seq: 18 +} + +get { + url: http://localhost:3000/api/people/1/contactinfos + body: none + auth: none +} diff --git a/backend/apis/BlinkApiCollection/GetJobOffers.bru b/backend/apis/BlinkApiCollection/GetJobOffers.bru new file mode 100644 index 0000000..63070e2 --- /dev/null +++ b/backend/apis/BlinkApiCollection/GetJobOffers.bru @@ -0,0 +1,15 @@ +meta { + name: GetJobOffers + type: http + seq: 5 +} + +get { + url: http://localhost:3000/api/organizations/1/joboffers/ + body: none + auth: none +} + +headers { + User-Agent: insomnia/2023.5.8 +} diff --git a/backend/apis/BlinkApiCollection/GetMyApplications.bru b/backend/apis/BlinkApiCollection/GetMyApplications.bru new file mode 100644 index 0000000..e2ad4d6 --- /dev/null +++ b/backend/apis/BlinkApiCollection/GetMyApplications.bru @@ -0,0 +1,11 @@ +meta { + name: GetMyApplications + type: http + seq: 9 +} + +get { + url: http://localhost:3000/api/organizations/joboffers/applications/mine + body: none + auth: none +} diff --git a/backend/apis/BlinkApiCollection/GetMyself.bru b/backend/apis/BlinkApiCollection/GetMyself.bru new file mode 100644 index 0000000..e3239cb --- /dev/null +++ b/backend/apis/BlinkApiCollection/GetMyself.bru @@ -0,0 +1,15 @@ +meta { + name: GetMyself + type: http + seq: 22 +} + +get { + url: http://localhost:3000/api/people/me + body: none + auth: inherit +} + +headers { + User-Agent: insomnia/2023.5.8 +} diff --git a/backend/apis/BlinkApiCollection/GetOrganization.bru b/backend/apis/BlinkApiCollection/GetOrganization.bru new file mode 100644 index 0000000..050bb33 --- /dev/null +++ b/backend/apis/BlinkApiCollection/GetOrganization.bru @@ -0,0 +1,15 @@ +meta { + name: GetOrganization + type: http + seq: 16 +} + +get { + url: http://localhost:3000/api/organizations/1 + body: none + auth: none +} + +headers { + User-Agent: insomnia/2023.5.8 +} diff --git a/backend/apis/BlinkApiCollection/GetPerson.bru b/backend/apis/BlinkApiCollection/GetPerson.bru new file mode 100644 index 0000000..842d33d --- /dev/null +++ b/backend/apis/BlinkApiCollection/GetPerson.bru @@ -0,0 +1,15 @@ +meta { + name: GetPerson + type: http + seq: 23 +} + +get { + url: http://localhost:3000/api/people/1/details + body: none + auth: none +} + +headers { + User-Agent: insomnia/2023.5.8 +} diff --git a/backend/apis/BlinkApiCollection/InsertContactInfo.bru b/backend/apis/BlinkApiCollection/InsertContactInfo.bru new file mode 100644 index 0000000..12d9da4 --- /dev/null +++ b/backend/apis/BlinkApiCollection/InsertContactInfo.bru @@ -0,0 +1,18 @@ +meta { + name: InsertContactInfo + type: http + seq: 20 +} + +post { + url: http://localhost:3000/api/people/myself/contactinfos + body: json + auth: inherit +} + +body:json { + { + "content": "www.john.com", + "info_type": "WEBSITE" + } +} diff --git a/backend/apis/BlinkApiCollection/Login.bru b/backend/apis/BlinkApiCollection/Login.bru new file mode 100644 index 0000000..a01cba5 --- /dev/null +++ b/backend/apis/BlinkApiCollection/Login.bru @@ -0,0 +1,23 @@ +meta { + name: Login + type: http + seq: 28 +} + +post { + url: http://localhost:3000/api/people/me/token + body: json + auth: none +} + +headers { + Content-Type: application/json + User-Agent: insomnia/2023.5.8 +} + +body:json { + { + "email": "john@mail.org", + "password": "password" + } +} diff --git a/backend/apis/BlinkApiCollection/Register.bru b/backend/apis/BlinkApiCollection/Register.bru new file mode 100644 index 0000000..902d589 --- /dev/null +++ b/backend/apis/BlinkApiCollection/Register.bru @@ -0,0 +1,26 @@ +meta { + name: Register + type: http + seq: 29 +} + +post { + url: http://localhost:3000/api/people + body: json + auth: none +} + +headers { + Content-Type: application/json + User-Agent: insomnia/2023.5.8 +} + +body:json { + { + "email" : "john@mail.org", + "password" : "password", + "displayName" : "John Doe", + "aboutMe" : "I am a passionate software engineer", + "qualification" : "Software Engineer" + } +} diff --git a/backend/apis/BlinkApiCollection/RemoveOrganizationAdmin.bru b/backend/apis/BlinkApiCollection/RemoveOrganizationAdmin.bru new file mode 100644 index 0000000..4753152 --- /dev/null +++ b/backend/apis/BlinkApiCollection/RemoveOrganizationAdmin.bru @@ -0,0 +1,16 @@ +meta { + name: RemoveOrganizationAdmin + type: http + seq: 12 +} + +delete { + url: http://localhost:3000/api/organizations/1/admins/me + body: json + auth: none +} + +headers { + Content-Type: application/json + User-Agent: insomnia/2023.5.8 +} diff --git a/backend/apis/BlinkApiCollection/RequestNewPassword.bru b/backend/apis/BlinkApiCollection/RequestNewPassword.bru new file mode 100644 index 0000000..cf3d38d --- /dev/null +++ b/backend/apis/BlinkApiCollection/RequestNewPassword.bru @@ -0,0 +1,22 @@ +meta { + name: RequestNewPassword + type: http + seq: 25 +} + +post { + url: http://localhost:3000/api/resetpassword/request + body: json + auth: none +} + +headers { + Content-Type: application/json + User-Agent: insomnia/2023.5.8 +} + +body:json { + { + "email": "john@mail.org" + } +} diff --git a/backend/apis/BlinkApiCollection/ResetNewPassword.bru b/backend/apis/BlinkApiCollection/ResetNewPassword.bru new file mode 100644 index 0000000..9be3aad --- /dev/null +++ b/backend/apis/BlinkApiCollection/ResetNewPassword.bru @@ -0,0 +1,23 @@ +meta { + name: ResetNewPassword + type: http + seq: 24 +} + +post { + url: http://localhost:3000/api/resetpassword/reset + body: json + auth: none +} + +headers { + Content-Type: application/json + User-Agent: insomnia/2023.5.8 +} + +body:json { + { + "secret": "360837853e2d3cf799c709b44720b4e3", + "password": "password" + } +} diff --git a/backend/apis/BlinkApiCollection/UpdateOrganization.bru b/backend/apis/BlinkApiCollection/UpdateOrganization.bru new file mode 100644 index 0000000..91aa4b3 --- /dev/null +++ b/backend/apis/BlinkApiCollection/UpdateOrganization.bru @@ -0,0 +1,24 @@ +meta { + name: UpdateOrganization + type: http + seq: 15 +} + +patch { + url: http://localhost:3000/api/organizations/1 + body: json + auth: none +} + +headers { + Content-Type: application/json + User-Agent: insomnia/2023.5.8 +} + +body:json { + { + "name": "Blink Inc.", + "location": "Naples (Campania), Italy", + "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." + } +} diff --git a/backend/apis/BlinkApiCollection/UpdatePerson.bru b/backend/apis/BlinkApiCollection/UpdatePerson.bru new file mode 100644 index 0000000..3597edc --- /dev/null +++ b/backend/apis/BlinkApiCollection/UpdatePerson.bru @@ -0,0 +1,32 @@ +meta { + name: UpdatePerson + type: http + seq: 26 +} + +patch { + url: http://localhost:3000/api/people/me + body: json + auth: none +} + +headers { + Content-Type: application/json + User-Agent: insomnia/2023.5.8 +} + +body:json { + { + "displayName": "John Junior Doe III", + "dateOfBirth": "1970-01-01", + "openToWork": "false", + "placeOfLiving": "Oslo, Norway", + "aboutMe": "I am a passionate software engineer, but I also love art and music", + "new_password": "password", + "old_password": "password", + "qualification" : "Software Engineer at Blink Inc. & Google LLC", + "visibility": "EVERYONE", + "oldPassword": "password", + "newPassword": "password" + } +} diff --git a/backend/apis/BlinkApiCollection/bruno.json b/backend/apis/BlinkApiCollection/bruno.json new file mode 100644 index 0000000..4afbe67 --- /dev/null +++ b/backend/apis/BlinkApiCollection/bruno.json @@ -0,0 +1,9 @@ +{ + "version": "1", + "name": "Blink", + "type": "collection", + "ignore": [ + "node_modules", + ".git" + ] +} \ No newline at end of file diff --git a/backend/apis/BlinkApiCollection/collection.bru b/backend/apis/BlinkApiCollection/collection.bru new file mode 100644 index 0000000..3aefe4e --- /dev/null +++ b/backend/apis/BlinkApiCollection/collection.bru @@ -0,0 +1,7 @@ +auth { + mode: bearer +} + +auth:bearer { + token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEsImlhdCI6MTc0NDk2OTAxNCwiZXhwIjoxNzQ0OTk3ODE0fQ.eAzcwzTPnNnqmmX9TCUroFLiJxQlQ49fGMVs1bXxXQM +} diff --git a/backend/apis/BlinkApiUsageExampleBRUNO.json b/backend/apis/BlinkApiUsageExampleBRUNO.json index 81693ee..701bb6e 100644 --- a/backend/apis/BlinkApiUsageExampleBRUNO.json +++ b/backend/apis/BlinkApiUsageExampleBRUNO.json @@ -1,5 +1,5 @@ { - "name": "Blink", + "name": "BlinkApiCollection", "version": "1", "items": [ { diff --git a/backend/apis/nodejs/src/app.js b/backend/apis/nodejs/src/app.js index 05bb1d9..d7b0024 100644 --- a/backend/apis/nodejs/src/app.js +++ b/backend/apis/nodejs/src/app.js @@ -28,7 +28,7 @@ const serverRoutes = require('./routes/server_routes.js'); const resetPasswordRoutes = require('./routes/reset_password_routes.js'); const applicationRoutes = require('./routes/job_application_routes.js'); const personContactInfosRoutes = require('./routes/person_contact_info_routes.js'); - +const experienceRoutes = require('./routes/experience_routes.js'); /* ===== END IMPORTING MODULES ===== */ @@ -59,7 +59,7 @@ app.use('/api/organizations', organizationAdminRoutes.routes); app.use('/api/resetpassword', resetPasswordRoutes.routes); app.use('/api/organizations', applicationRoutes.routes); app.use('/api/people', personContactInfosRoutes.routes); - +app.use('/api/experiences', experienceRoutes.routes); /* ===== END ROUTE HANDLING ===== */ diff --git a/backend/apis/nodejs/src/models/experience_model.js b/backend/apis/nodejs/src/models/experience_model.js index ab1126a..b7daa38 100644 --- a/backend/apis/nodejs/src/models/experience_model.js +++ b/backend/apis/nodejs/src/models/experience_model.js @@ -9,4 +9,34 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ \ No newline at end of file +*/ + +const knex = require('../utils/knex_config'); + +function createExperience(title, description, organizationId, organizationName, date, person_id, type) { + const experience = { + title, + description, + organization_id: organizationId, + organization_name: organizationName, + date, + person_id, + type + }; + return experience; +} + +async function insert(experience){ + const insertedExperience = await knex('Experience') + .insert(experience) + .returning('*'); + return insertedExperience[0]; +} + +// Exporting a function +// means making a JavaScript function defined in one +// module available for use in another module. +module.exports = { + createExperience, + insert +}; \ No newline at end of file diff --git a/backend/apis/nodejs/src/routes/experience_routes.js b/backend/apis/nodejs/src/routes/experience_routes.js index ab1126a..2b10014 100644 --- a/backend/apis/nodejs/src/routes/experience_routes.js +++ b/backend/apis/nodejs/src/routes/experience_routes.js @@ -9,4 +9,36 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ \ No newline at end of file +*/ + +const Experience = require('../models/experience_model'); +const express = require('express'); +const jwtUtils = require('../utils/jwt_utils'); + +async function addExperience(req, res) { + try { + const experienceToInsert = Experience.createExperience( + req.body.title, + req.body.description, + req.body.organizationId, + req.body.organizationName, + req.body.date, + req.jwt.person_id, + req.body.type + ) + const insertedExperience = await Experience.insert(experienceToInsert); + return res.status(201).json(insertedExperience); + } catch (error) { + console.error(`Error in function ${addExperience.name}: ${error}`); + return res.status(500).json({ + error: 'Internal server error' + }); + } +} + +const routes = express.Router(); +routes.post('/', jwtUtils.extractToken, addExperience); + +module.exports = { + routes +}; \ No newline at end of file diff --git a/backend/sql/1-create_tables.sql b/backend/sql/1-create_tables.sql index 8254ca2..33b117b 100644 --- a/backend/sql/1-create_tables.sql +++ b/backend/sql/1-create_tables.sql @@ -110,7 +110,7 @@ CREATE TABLE IF NOT EXISTS "Experience" ( id SERIAL PRIMARY KEY, title CHARACTER VARYING(128) NOT NULL, description TEXT NOT NULL, - organization CHARACTER VARYING(128) NOT NULL, + organization_name CHARACTER VARYING(128), organization_id INTEGER, date daterange NOT NULL, person_id INTEGER NOT NULL, @@ -150,4 +150,4 @@ CREATE TABLE IF NOT EXISTS "OrganizationContactInfo" ( info CHARACTER VARYING(128) NOT NULL, info_type InfoType NOT NULL, CONSTRAINT "OrganizationFK" FOREIGN KEY (organization_id) REFERENCES "Organization" (id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE -) +);