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

View File

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

View File

@ -55,13 +55,25 @@ async function getMyApplications(personId, organizationId) {
.where('person_id', personId)
.join('JobOffer', 'JobOffer.id', 'JobApplication.job_offer_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) {
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
* @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')
.join('Person', 'Person.id', 'JobApplication.person_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 {*} personId
*/
async function canPersonSetStatus(jobApplicationId, personId) {
async function isPersonJobApplicationAdministrator(jobApplicationId, personId) {
const organization = await knex('JobApplication')
.where('JobApplication.id', jobApplicationId)
.join('JobOffer', 'JobOffer.id', 'JobApplication.job_offer_id')
@ -150,9 +163,9 @@ module.exports = {
userAlreadyApplicated,
getMyApplications,
getApplicantsByJobOffer,
getApplicansByOrganization,
getApplicantsByOrganization,
find,
remove,
setStatus,
canPersonSetStatus
isPersonJobApplicationAdministrator
}

View File

@ -97,6 +97,19 @@ async function findByOrganizationId(organizationId) {
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
async function filter(title, description, requirements, salary, salaryOperator, salaryFrequency, location, tags) {
let query = knex('JobOffer');
@ -132,5 +145,6 @@ module.exports = {
insert,
remove,
findByOrganizationId,
findById
findById,
isPersonJobOfferAdministrator
}

View File

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