Compare commits

...

3 Commits

Author SHA1 Message Date
xfarrow 7f45379ebc Add API usage 2024-10-30 15:36:50 +01:00
xfarrow 0d1195f913 JobApplication completed 2024-10-30 15:32:32 +01:00
xfarrow aa06d64341 update 2024-10-30 15:17:30 +01:00
6 changed files with 639 additions and 310 deletions

View File

@ -5,7 +5,7 @@
{ {
"type": "http", "type": "http",
"name": "ActivatePerson", "name": "ActivatePerson",
"seq": 22, "seq": 23,
"request": { "request": {
"url": "http://localhost:3000/api/persons/me/activation?q=3ac9c204de1676b54163ed8015c7af00", "url": "http://localhost:3000/api/persons/me/activation?q=3ac9c204de1676b54163ed8015c7af00",
"method": "GET", "method": "GET",
@ -33,14 +33,14 @@
"assertions": [], "assertions": [],
"tests": "", "tests": "",
"auth": { "auth": {
"mode": "none" "mode": "inherit"
} }
} }
}, },
{ {
"type": "http", "type": "http",
"name": "AddOrganizationAdmin", "name": "AddOrganizationAdmin",
"seq": 10, "seq": 11,
"request": { "request": {
"url": "http://localhost:3000/api/organizations/1/admins", "url": "http://localhost:3000/api/organizations/1/admins",
"method": "POST", "method": "POST",
@ -68,10 +68,7 @@
"assertions": [], "assertions": [],
"tests": "", "tests": "",
"auth": { "auth": {
"mode": "bearer", "mode": "inherit"
"bearer": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEsImlhdCI6MTcyOTUxNjAzMCwiZXhwIjoxNzI5NTQ0ODMwfQ.jWVfSL_D4pabdihXDfoZ1dPLy4Nn6C3aePHIommiHqw"
}
} }
} }
}, },
@ -80,7 +77,7 @@
"name": "ChangeApplicationStatus", "name": "ChangeApplicationStatus",
"seq": 1, "seq": 1,
"request": { "request": {
"url": "http://localhost:3000/api/organizations/joboffers/applications/2", "url": "http://localhost:3000/api/organizations/joboffers/applications/5",
"method": "PATCH", "method": "PATCH",
"headers": [], "headers": [],
"params": [], "params": [],
@ -95,19 +92,16 @@
"assertions": [], "assertions": [],
"tests": "", "tests": "",
"auth": { "auth": {
"mode": "bearer", "mode": "inherit"
"bearer": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEsImlhdCI6MTczMDEyNTUzNywiZXhwIjoxNzMwMTU0MzM3fQ.X216UkLuDL6-Qs6EUbIRL_YKQKKcxyzQFmAKzJNWEzI"
}
} }
} }
}, },
{ {
"type": "http", "type": "http",
"name": "CreateApplication", "name": "CreateApplication",
"seq": 4, "seq": 6,
"request": { "request": {
"url": "http://localhost:3000/api/organizations/joboffers/1", "url": "http://localhost:3000/api/organizations/joboffers/1/applications",
"method": "POST", "method": "POST",
"headers": [], "headers": [],
"params": [], "params": [],
@ -121,17 +115,14 @@
"assertions": [], "assertions": [],
"tests": "", "tests": "",
"auth": { "auth": {
"mode": "bearer", "mode": "inherit"
"bearer": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEsImlhdCI6MTczMDEyNTUzNywiZXhwIjoxNzMwMTU0MzM3fQ.X216UkLuDL6-Qs6EUbIRL_YKQKKcxyzQFmAKzJNWEzI"
}
} }
} }
}, },
{ {
"type": "http", "type": "http",
"name": "CreateJobOffer", "name": "CreateJobOffer",
"seq": 8, "seq": 9,
"request": { "request": {
"url": "http://localhost:3000/api/organizations/1/joboffers", "url": "http://localhost:3000/api/organizations/1/joboffers",
"method": "POST", "method": "POST",
@ -159,17 +150,14 @@
"assertions": [], "assertions": [],
"tests": "", "tests": "",
"auth": { "auth": {
"mode": "bearer", "mode": "inherit"
"bearer": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEsImlhdCI6MTcyOTc3NDc4NywiZXhwIjoxNzI5ODAzNTg3fQ.Li0NeQH6e4ykQ8tpY3KYkS_bQhv7cIFmjz96U-E9S0c"
}
} }
} }
}, },
{ {
"type": "http", "type": "http",
"name": "CreateOrganization", "name": "CreateOrganization",
"seq": 15, "seq": 16,
"request": { "request": {
"url": "http://localhost:3000/api/organizations", "url": "http://localhost:3000/api/organizations",
"method": "POST", "method": "POST",
@ -197,10 +185,7 @@
"assertions": [], "assertions": [],
"tests": "", "tests": "",
"auth": { "auth": {
"mode": "bearer", "mode": "inherit"
"bearer": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEsImlhdCI6MTcyOTc3NDc4NywiZXhwIjoxNzI5ODAzNTg3fQ.Li0NeQH6e4ykQ8tpY3KYkS_bQhv7cIFmjz96U-E9S0c"
}
} }
} }
}, },
@ -209,7 +194,7 @@
"name": "DeleteApplication", "name": "DeleteApplication",
"seq": 2, "seq": 2,
"request": { "request": {
"url": "http://localhost:3000/api/organizations/joboffers/applications/2", "url": "http://localhost:3000/api/organizations/joboffers/applications/6",
"method": "DELETE", "method": "DELETE",
"headers": [], "headers": [],
"params": [], "params": [],
@ -224,17 +209,14 @@
"assertions": [], "assertions": [],
"tests": "", "tests": "",
"auth": { "auth": {
"mode": "bearer", "mode": "inherit"
"bearer": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEsImlhdCI6MTczMDEyODc2NSwiZXhwIjoxNzMwMTU3NTY1fQ.puQ4gw9K_fL4FhXs7UlvyZwq98XZEIuXwnZ0JBIXzaw"
}
} }
} }
}, },
{ {
"type": "http", "type": "http",
"name": "DeleteJobOffer", "name": "DeleteJobOffer",
"seq": 6, "seq": 7,
"request": { "request": {
"url": "http://localhost:3000/api/organizations/joboffers/3", "url": "http://localhost:3000/api/organizations/joboffers/3",
"method": "DELETE", "method": "DELETE",
@ -256,17 +238,14 @@
"assertions": [], "assertions": [],
"tests": "", "tests": "",
"auth": { "auth": {
"mode": "bearer", "mode": "inherit"
"bearer": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEsImlhdCI6MTcyOTc2NDI0NiwiZXhwIjoxNzI5NzkzMDQ2fQ.TOZMas9WujFp_hP7bqFzbSqWighmT7NmfkohEmpWr5A"
}
} }
} }
}, },
{ {
"type": "http", "type": "http",
"name": "DeleteOrganization", "name": "DeleteOrganization",
"seq": 12, "seq": 13,
"request": { "request": {
"url": "http://localhost:3000/api/organizations/1", "url": "http://localhost:3000/api/organizations/1",
"method": "DELETE", "method": "DELETE",
@ -288,17 +267,14 @@
"assertions": [], "assertions": [],
"tests": "", "tests": "",
"auth": { "auth": {
"mode": "bearer", "mode": "inherit"
"bearer": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIsImlhdCI6MTcxMTAzMjk1NCwiZXhwIjoxNzExMDYxNzU0fQ.5el1ymu9qZQpoJpWfM4ZPfNcs34GGFc6WVfCBitlyEk"
}
} }
} }
}, },
{ {
"type": "http", "type": "http",
"name": "DeletePerson", "name": "DeletePerson",
"seq": 18, "seq": 19,
"request": { "request": {
"url": "http://localhost:3000/api/persons/me", "url": "http://localhost:3000/api/persons/me",
"method": "DELETE", "method": "DELETE",
@ -320,17 +296,14 @@
"assertions": [], "assertions": [],
"tests": "", "tests": "",
"auth": { "auth": {
"mode": "bearer", "mode": "inherit"
"bearer": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIsImlhdCI6MTcxMTAzMjk1NCwiZXhwIjoxNzExMDYxNzU0fQ.5el1ymu9qZQpoJpWfM4ZPfNcs34GGFc6WVfCBitlyEk"
}
} }
} }
}, },
{ {
"type": "http", "type": "http",
"name": "FilterOrganizationByPrefix", "name": "FilterOrganizationByPrefix",
"seq": 11, "seq": 12,
"request": { "request": {
"url": "http://localhost:3000/api/organizations/filter", "url": "http://localhost:3000/api/organizations/filter",
"method": "POST", "method": "POST",
@ -365,15 +338,15 @@
{ {
"type": "http", "type": "http",
"name": "GetApplicantsByOrganization", "name": "GetApplicantsByOrganization",
"seq": 3, "seq": 4,
"request": { "request": {
"url": "http://localhost:3000/api/organizations/1", "url": "http://localhost:3000/api/organizations/1/joboffers/applications",
"method": "GET", "method": "GET",
"headers": [], "headers": [],
"params": [], "params": [],
"body": { "body": {
"mode": "json", "mode": "json",
"json": "{\n \"organizationId\": 1\n}", "json": "",
"formUrlEncoded": [], "formUrlEncoded": [],
"multipartForm": [] "multipartForm": []
}, },
@ -382,17 +355,14 @@
"assertions": [], "assertions": [],
"tests": "", "tests": "",
"auth": { "auth": {
"mode": "bearer", "mode": "inherit"
"bearer": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEsImlhdCI6MTczMDEyNTUzNywiZXhwIjoxNzMwMTU0MzM3fQ.X216UkLuDL6-Qs6EUbIRL_YKQKKcxyzQFmAKzJNWEzI"
}
} }
} }
}, },
{ {
"type": "http", "type": "http",
"name": "GetJobOffers", "name": "GetJobOffers",
"seq": 7, "seq": 8,
"request": { "request": {
"url": "http://localhost:3000/api/organizations/1/joboffers/", "url": "http://localhost:3000/api/organizations/1/joboffers/",
"method": "GET", "method": "GET",
@ -423,7 +393,7 @@
"name": "GetMyApplications", "name": "GetMyApplications",
"seq": 5, "seq": 5,
"request": { "request": {
"url": "http://localhost:3000/api/organizations/applications/mine", "url": "http://localhost:3000/api/organizations/joboffers/applications/mine",
"method": "GET", "method": "GET",
"headers": [], "headers": [],
"params": [], "params": [],
@ -437,17 +407,14 @@
"assertions": [], "assertions": [],
"tests": "", "tests": "",
"auth": { "auth": {
"mode": "bearer", "mode": "inherit"
"bearer": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEsImlhdCI6MTczMDEyNTUzNywiZXhwIjoxNzMwMTU0MzM3fQ.X216UkLuDL6-Qs6EUbIRL_YKQKKcxyzQFmAKzJNWEzI"
}
} }
} }
}, },
{ {
"type": "http", "type": "http",
"name": "GetMyself", "name": "GetMyself",
"seq": 20, "seq": 21,
"request": { "request": {
"url": "http://localhost:3000/api/persons/me", "url": "http://localhost:3000/api/persons/me",
"method": "GET", "method": "GET",
@ -469,17 +436,14 @@
"assertions": [], "assertions": [],
"tests": "", "tests": "",
"auth": { "auth": {
"mode": "bearer", "mode": "inherit"
"bearer": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEsImlhdCI6MTcyOTUxNTY3NywiZXhwIjoxNzI5NTQ0NDc3fQ.OxlOKzzZpl2H8cxjPP_8vsD5LRBi-ZxDplvQf63jMkk"
}
} }
} }
}, },
{ {
"type": "http", "type": "http",
"name": "GetOrganization", "name": "GetOrganization",
"seq": 14, "seq": 15,
"request": { "request": {
"url": "http://localhost:3000/api/organizations/1", "url": "http://localhost:3000/api/organizations/1",
"method": "GET", "method": "GET",
@ -508,7 +472,7 @@
{ {
"type": "http", "type": "http",
"name": "GetPerson", "name": "GetPerson",
"seq": 21, "seq": 22,
"request": { "request": {
"url": "http://localhost:3000/api/persons/1/details", "url": "http://localhost:3000/api/persons/1/details",
"method": "GET", "method": "GET",
@ -537,7 +501,7 @@
{ {
"type": "http", "type": "http",
"name": "Login", "name": "Login",
"seq": 23, "seq": 24,
"request": { "request": {
"url": "http://localhost:3000/api/persons/me/token", "url": "http://localhost:3000/api/persons/me/token",
"method": "POST", "method": "POST",
@ -565,52 +529,14 @@
"assertions": [], "assertions": [],
"tests": "", "tests": "",
"auth": { "auth": {
"mode": "none" "mode": "inherit"
}
}
},
{
"type": "http",
"name": "RemoveOrganizationAdmin",
"seq": 9,
"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": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"auth": {
"mode": "bearer",
"bearer": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIsImlhdCI6MTcyOTUxNjM0NywiZXhwIjoxNzI5NTQ1MTQ3fQ.W09-xjGYSVI2EftoI9lSJAkzlo3V1NADcv4RbhE414I"
}
} }
} }
}, },
{ {
"type": "http", "type": "http",
"name": "Register", "name": "Register",
"seq": 24, "seq": 25,
"request": { "request": {
"url": "http://localhost:3000/api/persons", "url": "http://localhost:3000/api/persons",
"method": "POST", "method": "POST",
@ -638,17 +564,49 @@
"assertions": [], "assertions": [],
"tests": "", "tests": "",
"auth": { "auth": {
"mode": "bearer", "mode": "none"
"bearer": { }
"token": "" }
},
{
"type": "http",
"name": "RemoveOrganizationAdmin",
"seq": 10,
"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": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"auth": {
"mode": "inherit"
} }
} }
}, },
{ {
"type": "http", "type": "http",
"name": "RequestNewPassword", "name": "RequestNewPassword",
"seq": 17, "seq": 18,
"request": { "request": {
"url": "http://localhost:3000/api/resetpassword/request", "url": "http://localhost:3000/api/resetpassword/request",
"method": "POST", "method": "POST",
@ -680,48 +638,10 @@
} }
} }
}, },
{
"type": "http",
"name": "UpdateOrganization",
"seq": 13,
"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": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"auth": {
"mode": "bearer",
"bearer": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEsImlhdCI6MTcyOTUxNjAzMCwiZXhwIjoxNzI5NTQ0ODMwfQ.jWVfSL_D4pabdihXDfoZ1dPLy4Nn6C3aePHIommiHqw"
}
}
}
},
{ {
"type": "http", "type": "http",
"name": "ResetNewPassword", "name": "ResetNewPassword",
"seq": 16, "seq": 17,
"request": { "request": {
"url": "http://localhost:3000/api/resetpassword/reset", "url": "http://localhost:3000/api/resetpassword/reset",
"method": "POST", "method": "POST",
@ -753,10 +673,45 @@
} }
} }
}, },
{
"type": "http",
"name": "UpdateOrganization",
"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": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"auth": {
"mode": "inherit"
}
}
},
{ {
"type": "http", "type": "http",
"name": "UpdatePerson", "name": "UpdatePerson",
"seq": 19, "seq": 20,
"request": { "request": {
"url": "http://localhost:3000/api/persons/me", "url": "http://localhost:3000/api/persons/me",
"method": "PATCH", "method": "PATCH",
@ -784,15 +739,46 @@
"assertions": [], "assertions": [],
"tests": "", "tests": "",
"auth": { "auth": {
"mode": "bearer", "mode": "inherit"
"bearer": { }
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEsImlhdCI6MTcyOTUxNTY3NywiZXhwIjoxNzI5NTQ0NDc3fQ.OxlOKzzZpl2H8cxjPP_8vsD5LRBi-ZxDplvQf63jMkk" }
} },
{
"type": "http",
"name": "GetApplicantsByJobOffer",
"seq": 3,
"request": {
"url": "http://localhost:3000/api/organizations/joboffers/1/applications",
"method": "GET",
"headers": [],
"params": [],
"body": {
"mode": "json",
"json": "",
"formUrlEncoded": [],
"multipartForm": []
},
"script": {},
"vars": {},
"assertions": [],
"tests": "",
"auth": {
"mode": "inherit"
} }
} }
} }
], ],
"environments": [], "environments": [],
"root": {
"request": {
"auth": {
"mode": "bearer",
"bearer": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEsImlhdCI6MTczMDI5ODY0NywiZXhwIjoxNzMwMzI3NDQ3fQ.Quqwib7DasUSmWwLPpaCLQscBna_jNs-P0u2QW12lgA"
}
}
}
},
"brunoConfig": { "brunoConfig": {
"version": "1", "version": "1",
"name": "Blink", "name": "Blink",

View File

@ -24,13 +24,20 @@
"type": "default" "type": "default"
} }
], ],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/persons/me/activation?q=3ac9c204de1676b54163ed8015c7af00", "raw": "http://localhost:3000/api/persons/me/activation?q=3ac9c204de1676b54163ed8015c7af00",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"persons",
"me",
"activation"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
}, },
@ -63,13 +70,20 @@
"type": "default" "type": "default"
} }
], ],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/organizations/1/admins", "raw": "http://localhost:3000/api/organizations/1/admins",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"organizations",
"1",
"admins"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
}, },
@ -94,13 +108,21 @@
"request": { "request": {
"method": "PATCH", "method": "PATCH",
"header": [], "header": [],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/organizations/joboffers/applications/2", "raw": "http://localhost:3000/api/organizations/joboffers/applications/5",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"organizations",
"joboffers",
"applications",
"5"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
}, },
@ -121,13 +143,21 @@
"request": { "request": {
"method": "POST", "method": "POST",
"header": [], "header": [],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/organizations/joboffers/1", "raw": "http://localhost:3000/api/organizations/joboffers/1/applications",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"organizations",
"joboffers",
"1",
"applications"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
} }
@ -152,13 +182,20 @@
"type": "default" "type": "default"
} }
], ],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/organizations/1/joboffers", "raw": "http://localhost:3000/api/organizations/1/joboffers",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"organizations",
"1",
"joboffers"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
}, },
@ -192,13 +229,18 @@
"type": "default" "type": "default"
} }
], ],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/organizations", "raw": "http://localhost:3000/api/organizations",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"organizations"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
}, },
@ -219,13 +261,21 @@
"request": { "request": {
"method": "DELETE", "method": "DELETE",
"header": [], "header": [],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/organizations/joboffers/applications/2", "raw": "http://localhost:3000/api/organizations/joboffers/applications/6",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"organizations",
"joboffers",
"applications",
"6"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
}, },
@ -253,13 +303,20 @@
"type": "default" "type": "default"
} }
], ],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/organizations/joboffers/3", "raw": "http://localhost:3000/api/organizations/joboffers/3",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"organizations",
"joboffers",
"3"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
} }
@ -278,13 +335,19 @@
"type": "default" "type": "default"
} }
], ],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/organizations/1", "raw": "http://localhost:3000/api/organizations/1",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"organizations",
"1"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
} }
@ -303,13 +366,19 @@
"type": "default" "type": "default"
} }
], ],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/persons/me", "raw": "http://localhost:3000/api/persons/me",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"persons",
"me"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
} }
@ -334,13 +403,19 @@
"type": "default" "type": "default"
} }
], ],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/organizations/filter", "raw": "http://localhost:3000/api/organizations/filter",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"organizations",
"filter"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
}, },
@ -361,19 +436,26 @@
"request": { "request": {
"method": "GET", "method": "GET",
"header": [], "header": [],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/organizations/1", "raw": "http://localhost:3000/api/organizations/1/joboffers/applications",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"organizations",
"1",
"joboffers",
"applications"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
}, },
"body": { "body": {
"mode": "raw", "mode": "raw",
"raw": "{\n \"organizationId\": 1\n}",
"options": { "options": {
"raw": { "raw": {
"language": "json" "language": "json"
@ -395,13 +477,21 @@
"type": "default" "type": "default"
} }
], ],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/organizations/1/joboffers/", "raw": "http://localhost:3000/api/organizations/1/joboffers/",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"organizations",
"1",
"joboffers",
""
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
} }
@ -413,13 +503,21 @@
"request": { "request": {
"method": "GET", "method": "GET",
"header": [], "header": [],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/organizations/applications/mine", "raw": "http://localhost:3000/api/organizations/joboffers/applications/mine",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"organizations",
"joboffers",
"applications",
"mine"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
} }
@ -438,13 +536,19 @@
"type": "default" "type": "default"
} }
], ],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/persons/me", "raw": "http://localhost:3000/api/persons/me",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"persons",
"me"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
} }
@ -463,13 +567,19 @@
"type": "default" "type": "default"
} }
], ],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/organizations/1", "raw": "http://localhost:3000/api/organizations/1",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"organizations",
"1"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
} }
@ -488,13 +598,20 @@
"type": "default" "type": "default"
} }
], ],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/persons/1/details", "raw": "http://localhost:3000/api/persons/1/details",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"persons",
"1",
"details"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
} }
@ -519,13 +636,20 @@
"type": "default" "type": "default"
} }
], ],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/persons/me/token", "raw": "http://localhost:3000/api/persons/me/token",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"persons",
"me",
"token"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
}, },
@ -540,45 +664,6 @@
} }
} }
}, },
{
"name": "RemoveOrganizationAdmin",
"event": [],
"request": {
"method": "DELETE",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"disabled": false,
"type": "default"
},
{
"key": "User-Agent",
"value": "insomnia/2023.5.8",
"disabled": false,
"type": "default"
}
],
"description": "",
"url": {
"raw": "http://localhost:3000/api/organizations/1/admins/me",
"host": [
"localhost"
],
"path": [],
"query": [],
"variable": []
},
"body": {
"mode": "raw",
"options": {
"raw": {
"language": "json"
}
}
}
}
},
{ {
"name": "Register", "name": "Register",
"event": [], "event": [],
@ -598,13 +683,18 @@
"type": "default" "type": "default"
} }
], ],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/persons", "raw": "http://localhost:3000/api/persons",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"persons"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
}, },
@ -619,6 +709,53 @@
} }
} }
}, },
{
"name": "RemoveOrganizationAdmin",
"event": [],
"request": {
"method": "DELETE",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"disabled": false,
"type": "default"
},
{
"key": "User-Agent",
"value": "insomnia/2023.5.8",
"disabled": false,
"type": "default"
}
],
"auth": null,
"description": "",
"url": {
"raw": "http://localhost:3000/api/organizations/1/admins/me",
"protocol": "http",
"host": [
"localhost:3000"
],
"path": [
"api",
"organizations",
"1",
"admins",
"me"
],
"query": [],
"variable": []
},
"body": {
"mode": "raw",
"options": {
"raw": {
"language": "json"
}
}
}
}
},
{ {
"name": "RequestNewPassword", "name": "RequestNewPassword",
"event": [], "event": [],
@ -638,59 +775,25 @@
"type": "default" "type": "default"
} }
], ],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/resetpassword/request", "raw": "http://localhost:3000/api/resetpassword/request",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"resetpassword",
"request"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
}, },
"body": { "body": {
"mode": "raw", "mode": "raw",
"raw": "{\n\t\"email\": \"john@mail.org\"\n}", "raw": "{\n \"email\": \"john@mail.org\"\n}",
"options": {
"raw": {
"language": "json"
}
}
}
}
},
{
"name": "UpdateOrganization",
"event": [],
"request": {
"method": "PATCH",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"disabled": false,
"type": "default"
},
{
"key": "User-Agent",
"value": "insomnia/2023.5.8",
"disabled": false,
"type": "default"
}
],
"description": "",
"url": {
"raw": "http://localhost:3000/api/organizations/1",
"host": [
"localhost"
],
"path": [],
"query": [],
"variable": []
},
"body": {
"mode": "raw",
"raw": "{\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}",
"options": { "options": {
"raw": { "raw": {
"language": "json" "language": "json"
@ -718,13 +821,19 @@
"type": "default" "type": "default"
} }
], ],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/resetpassword/reset", "raw": "http://localhost:3000/api/resetpassword/reset",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"resetpassword",
"reset"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
}, },
@ -739,6 +848,52 @@
} }
} }
}, },
{
"name": "UpdateOrganization",
"event": [],
"request": {
"method": "PATCH",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"disabled": false,
"type": "default"
},
{
"key": "User-Agent",
"value": "insomnia/2023.5.8",
"disabled": false,
"type": "default"
}
],
"auth": null,
"description": "",
"url": {
"raw": "http://localhost:3000/api/organizations/1",
"protocol": "http",
"host": [
"localhost:3000"
],
"path": [
"api",
"organizations",
"1"
],
"query": [],
"variable": []
},
"body": {
"mode": "raw",
"raw": "{\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}",
"options": {
"raw": {
"language": "json"
}
}
}
}
},
{ {
"name": "UpdatePerson", "name": "UpdatePerson",
"event": [], "event": [],
@ -758,13 +913,19 @@
"type": "default" "type": "default"
} }
], ],
"auth": null,
"description": "", "description": "",
"url": { "url": {
"raw": "http://localhost:3000/api/persons/me", "raw": "http://localhost:3000/api/persons/me",
"protocol": "http",
"host": [ "host": [
"localhost" "localhost:3000"
],
"path": [
"api",
"persons",
"me"
], ],
"path": [],
"query": [], "query": [],
"variable": [] "variable": []
}, },
@ -778,6 +939,40 @@
} }
} }
} }
},
{
"name": "GetApplicantsByJobOffer",
"event": [],
"request": {
"method": "GET",
"header": [],
"auth": null,
"description": "",
"url": {
"raw": "http://localhost:3000/api/organizations/joboffers/1/applications",
"protocol": "http",
"host": [
"localhost:3000"
],
"path": [
"api",
"organizations",
"joboffers",
"1",
"applications"
],
"query": [],
"variable": []
},
"body": {
"mode": "raw",
"options": {
"raw": {
"language": "json"
}
}
}
}
} }
], ],
"variable": [] "variable": []

View File

@ -55,13 +55,25 @@ async function getMyApplications(personId, organizationId) {
.where('person_id', personId) .where('person_id', personId)
.join('JobOffer', 'JobOffer.id', 'JobApplication.job_offer_id') .join('JobOffer', 'JobOffer.id', 'JobApplication.job_offer_id')
.join('Organization', 'Organization.id', 'JobOffer.organization_id') .join('Organization', 'Organization.id', 'JobOffer.organization_id')
.select('JobApplication.id', 'JobOffer.title', 'JobOffer.description', 'Organization.name', 'Organization.location'); .select('JobApplication.id', 'JobOffer.id AS JobOfferId', 'JobOffer.title', 'JobOffer.description', 'Organization.id AS OrganizationId', 'Organization.name', 'Organization.location');
if (organizationId != null) { if (organizationId != null) {
query.where('Organization.id', organizationId); query.where('Organization.id', organizationId);
} }
return await query; return (await query).map(myApplication => ({
id: myApplication.id,
JobOffer: {
id: myApplication.JobOfferId,
title: myApplication.title,
description: myApplication.description
},
Organization: {
id: myApplication.OrganizationId,
name: myApplication.name,
location: myApplication.location
}
}));
} }
/** /**
@ -85,7 +97,7 @@ async function getApplicantsByJobOffer(jobOfferId) {
* @param {*} organizationId * @param {*} organizationId
* @returns An array of Person and JobOffer objects. Throws an exception if an error occurs * @returns An array of Person and JobOffer objects. Throws an exception if an error occurs
*/ */
async function getApplicansByOrganization(organizationId) { async function getApplicantsByOrganization(organizationId) {
const applicants = await knex('JobApplication') const applicants = await knex('JobApplication')
.join('Person', 'Person.id', 'JobApplication.person_id') .join('Person', 'Person.id', 'JobApplication.person_id')
.join('JobOffer', 'JobOffer.id', 'JobApplication.job_offer_id') .join('JobOffer', 'JobOffer.id', 'JobApplication.job_offer_id')
@ -127,11 +139,12 @@ async function setStatus(jobApplicationId, status) {
} }
/** /**
* Only Organization Administrators can change the status of a JobApplication * Determines whether the submitted personId represents an administrator
* of the company which created the joboffer of the current application
* @param {*} jobApplicationId * @param {*} jobApplicationId
* @param {*} personId * @param {*} personId
*/ */
async function canPersonSetStatus(jobApplicationId, personId) { async function isPersonJobApplicationAdministrator(jobApplicationId, personId) {
const organization = await knex('JobApplication') const organization = await knex('JobApplication')
.where('JobApplication.id', jobApplicationId) .where('JobApplication.id', jobApplicationId)
.join('JobOffer', 'JobOffer.id', 'JobApplication.job_offer_id') .join('JobOffer', 'JobOffer.id', 'JobApplication.job_offer_id')
@ -150,9 +163,9 @@ module.exports = {
userAlreadyApplicated, userAlreadyApplicated,
getMyApplications, getMyApplications,
getApplicantsByJobOffer, getApplicantsByJobOffer,
getApplicansByOrganization, getApplicantsByOrganization,
find, find,
remove, remove,
setStatus, setStatus,
canPersonSetStatus isPersonJobApplicationAdministrator
} }

View File

@ -97,6 +97,19 @@ async function findByOrganizationId(organizationId) {
return result; return result;
} }
async function isPersonJobOfferAdministrator(personId, jobOfferId) {
const organization = await knex('JobOffer')
.where('JobOffer.id', jobOfferId)
.join('Organization', 'Organization.id', 'JobOffer.organization_id')
.first()
.select('Organization.id');
if (organization == null) {
return false;
}
const isAdmin = await OrganizationAdmin.isAdmin(personId, organization.id);
return isAdmin;
}
// test // test
async function filter(title, description, requirements, salary, salaryOperator, salaryFrequency, location, tags) { async function filter(title, description, requirements, salary, salaryOperator, salaryFrequency, location, tags) {
let query = knex('JobOffer'); let query = knex('JobOffer');
@ -132,5 +145,6 @@ module.exports = {
insert, insert,
remove, remove,
findByOrganizationId, findByOrganizationId,
findById findById,
isPersonJobOfferAdministrator
} }

View File

@ -1,4 +1,3 @@
// TODO: Create a validator
/* /*
This code is part of Blink This code is part of Blink
licensed under GPLv3 licensed under GPLv3
@ -17,6 +16,7 @@ const JobOffer = require('../models/job_offer_model');
const OrganizationAdmin = require('../models/organization_admin_model'); const OrganizationAdmin = require('../models/organization_admin_model');
const express = require('express'); const express = require('express');
const jwtUtils = require('../utils/jwt_utils'); const jwtUtils = require('../utils/jwt_utils');
const jobApplicationValidator = require('../utils/validators/job_application_validator');
/** /**
* **POST** Request * **POST** Request
@ -25,6 +25,13 @@ const jwtUtils = require('../utils/jwt_utils');
*/ */
async function insert(req, res) { async function insert(req, res) {
try { try {
const errors = jobApplicationValidator.validationResult(req);
if (!errors.isEmpty()) {
return res.status(400).json({
errors: errors.array()
});
}
// Check if the job offer exists // Check if the job offer exists
if (await JobOffer.findById(req.params.idJobOffer) == null) { if (await JobOffer.findById(req.params.idJobOffer) == null) {
return res.status(404).json({ return res.status(404).json({
@ -50,7 +57,6 @@ async function insert(req, res) {
} }
} }
// TODO
/** /**
* **GET** Request * **GET** Request
* *
@ -60,13 +66,32 @@ async function insert(req, res) {
* @param {*} req * @param {*} req
* @param {*} res * @param {*} res
*/ */
async function find(req, res){ async function find(req, res) {
try { try {
const errors = jobApplicationValidator.validationResult(req);
if (!errors.isEmpty()) {
return res.status(400).json({
errors: errors.array()
});
}
const jobApplication = await Application.find(req.params.idApplication); const jobApplication = await Application.find(req.params.idApplication);
if (jobApplication == null) { if (jobApplication == null) {
return res.status(404).send(); return res.status(404).send();
} }
// Case in which the user themselves requested it
if (jobApplication.person_id == req.jwt.person_id) {
return res.status(200).json(jobApplication)
} else {
const isPersonOrganizationAdmin = await Application.isPersonJobApplicationAdministrator(jobApplication.id, req.jwt.person_id);
if (isPersonOrganizationAdmin === true) {
return res.status(200).json(jobApplication)
} else {
return res.status(401).json({
error: 'Forbidden'
});
}
}
} catch (error) { } catch (error) {
console.error(`Error in function ${find.name}: ${error}`); console.error(`Error in function ${find.name}: ${error}`);
res.status(500).json({ res.status(500).json({
@ -82,6 +107,13 @@ async function find(req, res){
*/ */
async function myApplications(req, res) { async function myApplications(req, res) {
try { try {
const errors = jobApplicationValidator.validationResult(req);
if (!errors.isEmpty()) {
return res.status(400).json({
errors: errors.array()
});
}
const applications = await Application.getMyApplications(req.jwt.person_id, req.body.organizationId); const applications = await Application.getMyApplications(req.jwt.person_id, req.body.organizationId);
return res.status(200).json(applications); return res.status(200).json(applications);
} catch (error) { } catch (error) {
@ -100,7 +132,14 @@ async function myApplications(req, res) {
*/ */
async function getApplicationsByJobOffer(req, res) { async function getApplicationsByJobOffer(req, res) {
try { try {
const isAdmin = await OrganizationAdmin.isAdmin(req.jwt.person_id, req.params.idJobOffer); //todo error! It's not idJobOffer const errors = jobApplicationValidator.validationResult(req);
if (!errors.isEmpty()) {
return res.status(400).json({
errors: errors.array()
});
}
const isAdmin = await JobOffer.isPersonJobOfferAdministrator(req.jwt.person_id, req.params.idJobOffer);
if (!isAdmin) { if (!isAdmin) {
return res.status(401).json({ return res.status(401).json({
error: 'Forbidden' error: 'Forbidden'
@ -125,13 +164,20 @@ async function getApplicationsByJobOffer(req, res) {
*/ */
async function getApplicationsByOrganization(req, res) { async function getApplicationsByOrganization(req, res) {
try { try {
const errors = jobApplicationValidator.validationResult(req);
if (!errors.isEmpty()) {
return res.status(400).json({
errors: errors.array()
});
}
const isAdmin = await OrganizationAdmin.isAdmin(req.jwt.person_id, req.params.idOrganization); const isAdmin = await OrganizationAdmin.isAdmin(req.jwt.person_id, req.params.idOrganization);
if (!isAdmin) { if (!isAdmin) {
return res.status(401).json({ return res.status(401).json({
error: 'Forbidden' error: 'Forbidden'
}); });
} }
const applicants = await Application.getApplicansByOrganization(req.params.idOrganization); const applicants = await Application.getApplicantsByOrganization(req.params.idOrganization);
return res.status(200).json(applicants); return res.status(200).json(applicants);
} catch (error) { } catch (error) {
console.error(`Error in function ${getApplicationsByOrganization.name}: ${error}`); console.error(`Error in function ${getApplicationsByOrganization.name}: ${error}`);
@ -148,6 +194,13 @@ async function getApplicationsByOrganization(req, res) {
*/ */
async function remove(req, res) { async function remove(req, res) {
try { try {
const errors = jobApplicationValidator.validationResult(req);
if (!errors.isEmpty()) {
return res.status(400).json({
errors: errors.array()
});
}
const jobApplication = await Application.find(req.params.idApplication); const jobApplication = await Application.find(req.params.idApplication);
if (jobApplication == null) { if (jobApplication == null) {
return res.status(404).send(); return res.status(404).send();
@ -175,7 +228,14 @@ async function remove(req, res) {
*/ */
async function setStatus(req, res) { async function setStatus(req, res) {
try { try {
const canPersonSetStatus = await Application.canPersonSetStatus(req.params.idApplication, req.jwt.person_id); const errors = jobApplicationValidator.validationResult(req);
if (!errors.isEmpty()) {
return res.status(400).json({
errors: errors.array()
});
}
const canPersonSetStatus = await Application.isPersonJobApplicationAdministrator(req.params.idApplication, req.jwt.person_id);
if (!canPersonSetStatus) { if (!canPersonSetStatus) {
return res.status(401).json({ return res.status(401).json({
error: 'Forbidden' error: 'Forbidden'
@ -192,13 +252,13 @@ async function setStatus(req, res) {
} }
const routes = express.Router(); const routes = express.Router();
routes.post('/joboffers/:idJobOffer/applications', jwtUtils.extractToken, insert); routes.post('/joboffers/:idJobOffer/applications', jwtUtils.extractToken, jobApplicationValidator.insertValidator, insert);
routes.get('/joboffers/:idJobOffer/applications/:idApplication', jwtUtils.extractToken, find); routes.get('/joboffers/:idJobOffer/applications/:idApplication', jwtUtils.extractToken, jobApplicationValidator.findValidator, find);
routes.get('/joboffers/applications/mine', jwtUtils.extractToken, myApplications); routes.get('/joboffers/applications/mine', jwtUtils.extractToken, jobApplicationValidator.myApplicationsValidator, myApplications);
routes.get('/joboffers/:idJobOffer/applications', jwtUtils.extractToken, getApplicationsByJobOffer); routes.get('/joboffers/:idJobOffer/applications', jwtUtils.extractToken, jobApplicationValidator.getApplicationsByJobOfferValidator, getApplicationsByJobOffer);
routes.get('/:idOrganization/joboffers/applications', jwtUtils.extractToken, getApplicationsByOrganization); routes.get('/:idOrganization/joboffers/applications', jwtUtils.extractToken, jobApplicationValidator.getApplicationsByOrganizationValidator, getApplicationsByOrganization);
routes.delete('/joboffers/applications/:idApplication', jwtUtils.extractToken, remove); routes.delete('/joboffers/applications/:idApplication', jwtUtils.extractToken, jobApplicationValidator.removeValidator, remove);
routes.patch('/joboffers/applications/:idApplication', jwtUtils.extractToken, setStatus); routes.patch('/joboffers/applications/:idApplication', jwtUtils.extractToken, jobApplicationValidator.setStatusValidator, setStatus);
module.exports = { module.exports = {
routes routes

View File

@ -0,0 +1,61 @@
/*
This code is part of Blink
licensed under GPLv3
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
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 {
check,
validationResult
} = require("express-validator"); // This is the destructuring part. It specifies which properties of the imported object (express-validator) you want to extract.
const {
escape
} = require('validator');
const insertValidator = [
check('idJobOffer').trim().escape().isInt()
];
const findValidator = [
check('idApplication').trim().escape().isInt()
];
const myApplicationsValidator = [
check('organizationId').optional().trim().escape().isInt()
];
const getApplicationsByJobOfferValidator = [
check('idJobOffer').trim().escape().isInt()
];
const getApplicationsByOrganizationValidator = [
check('idOrganization').trim().escape().isInt()
];
const removeValidator = [
check('idApplication').trim().escape().isInt()
];
const setStatusValidator = [
check('idApplication').trim().escape().isInt(),
check('status').trim().escape().isIn(['ACCEPTED', 'REJECTED']).withMessage('Invalid status. Status must be ACCEPTED or REJECTED')
];
module.exports = {
insertValidator,
findValidator,
myApplicationsValidator,
getApplicationsByJobOfferValidator,
getApplicationsByOrganizationValidator,
removeValidator,
setStatusValidator,
validationResult
}