Create experience endpoint (beta)

This commit is contained in:
Alessandro Ferro
2025-04-18 11:40:52 +02:00
parent 92e4997ccb
commit 597a9c1dae
36 changed files with 603 additions and 7 deletions

View File

@ -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
}

View File

@ -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"
}
}

View File

@ -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"
}
}

View File

@ -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
}

View File

@ -0,0 +1,11 @@
meta {
name: CreateExperience
type: http
seq: 1
}
post {
url: http://localhost:3000/api/experiences
body: none
auth: inherit
}

View File

@ -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"]
}
}

View File

@ -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."
}
}

View File

@ -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
}
}

View File

@ -0,0 +1,11 @@
meta {
name: DeleteContactInfo
type: http
seq: 19
}
delete {
url: http://localhost:3000/api/people/contactinfos/2
body: none
auth: none
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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"
}
}

View File

@ -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
}

View File

@ -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
}

View File

@ -0,0 +1,11 @@
meta {
name: GetContactInfosByPerson
type: http
seq: 18
}
get {
url: http://localhost:3000/api/people/1/contactinfos
body: none
auth: none
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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"
}
}

View File

@ -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"
}
}

View File

@ -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"
}
}

View File

@ -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
}

View File

@ -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"
}
}

View File

@ -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"
}
}

View File

@ -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."
}
}

View File

@ -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"
}
}

View File

@ -0,0 +1,9 @@
{
"version": "1",
"name": "Blink",
"type": "collection",
"ignore": [
"node_modules",
".git"
]
}

View File

@ -0,0 +1,7 @@
auth {
mode: bearer
}
auth:bearer {
token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEsImlhdCI6MTc0NDk2OTAxNCwiZXhwIjoxNzQ0OTk3ODE0fQ.eAzcwzTPnNnqmmX9TCUroFLiJxQlQ49fGMVs1bXxXQM
}

View File

@ -1,5 +1,5 @@
{
"name": "Blink",
"name": "BlinkApiCollection",
"version": "1",
"items": [
{

View File

@ -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 =====
*/

View File

@ -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.
*/
*/
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
};

View File

@ -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.
*/
*/
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
};

View File

@ -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
)
);