diff --git a/backend/apis/BlinkApiUsageExample.json b/backend/apis/BlinkApiUsageExample.json index f04a862..106891a 100644 --- a/backend/apis/BlinkApiUsageExample.json +++ b/backend/apis/BlinkApiUsageExample.json @@ -1 +1 @@ -{"_type":"export","__export_format":4,"__export_date":"2024-03-06T09:19:24.844Z","__export_source":"insomnia.desktop.app:v2023.5.8","resources":[{"_id":"req_669e832796b74afea190895704e22bcf","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709716751803,"created":1698054725162,"url":"http://localhost:3000/api/organizations/1/admins/me","name":"RemoveOrganizationAdmin","description":"","method":"DELETE","body":{"mimeType":"application/json","text":""},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_96dd7956eedd4029a62a8953d48384fd"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_5b4b316379204e8a9f34ad6b8520cf02"},{"id":"pair_0f33ba2fe5aa4a9c9610531991a08fff","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjYsImlhdCI6MTcwOTcxMzg5MCwiZXhwIjoxNzA5NzQyNjkwfQ.vIZVqYkIDbwhdNbjD0YWlQ62yVHl28vUMdxHxxFEKNg","description":""}],"authentication":{},"metaSortKey":-1698054725162,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"wrk_b556db78148e4b629915a6d75477c798","parentId":null,"modified":1709111680485,"created":1709111680485,"name":"Blink","description":"","scope":"collection","_type":"workspace"},{"_id":"req_26de24ee47a34b0a8365fde07b12f6d1","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709716745972,"created":1697612039148,"url":"http://localhost:3000/api/organizations/1/admins","name":"AddOrganizationAdmin","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"person_id\" : \"2\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_7f6436f6c14046f881b4325c0401f678"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_17a5c397cc2d44d58a70ad0f3ef13d5b"},{"id":"pair_56656674434c4b5f9eb6616c7b662fc1","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjYsImlhdCI6MTcwOTcxMzg5MCwiZXhwIjoxNzA5NzQyNjkwfQ.vIZVqYkIDbwhdNbjD0YWlQ62yVHl28vUMdxHxxFEKNg","description":""}],"authentication":{},"metaSortKey":-1697612039148,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_afbde66ccaa9438da0c5bb30735693a0","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709716738908,"created":1697439750530,"url":"http://localhost:3000/api/organizations/posts/1","name":"DeleteOrganizationPost","description":"","method":"DELETE","body":{"mimeType":"application/json","text":""},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_1cf0a9865fc54eb28b06b007dcfb87b6"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_e116a62c90714a2fa936db757b86345a"},{"id":"pair_af07de8a9e584d74bf22de772a1a5116","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjYsImlhdCI6MTcwOTcxMzg5MCwiZXhwIjoxNzA5NzQyNjkwfQ.vIZVqYkIDbwhdNbjD0YWlQ62yVHl28vUMdxHxxFEKNg","description":""}],"authentication":{},"metaSortKey":-1697439750530,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_3ac98a862c7241f48d7e82fc714965e8","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709714773151,"created":1697443352055,"url":"http://localhost:3000/api/organizations/1/posts/","name":"CreateOrganizationPost","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"content\" : \"Reach to us on Blink!\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_6e74726d8b9d4be883fb296363f27e4c"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_e355a0ac56664aaa95d1fba431f09a9c"},{"id":"pair_639ce915c16a4e36b23c5eec89acb7c2","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjYsImlhdCI6MTcwOTcxMzg5MCwiZXhwIjoxNzA5NzQyNjkwfQ.vIZVqYkIDbwhdNbjD0YWlQ62yVHl28vUMdxHxxFEKNg","description":""}],"authentication":{},"metaSortKey":-1697439606468.5,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_38c899c967c84a619b34b8c7818a051a","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709714106217,"created":1697536019056,"url":"http://localhost:3000/api/organizations/1","name":"DeleteOrganization","description":"","method":"DELETE","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_b65bf581b26e4d73b696c173b04c04a2"},{"id":"pair_5b4068cf97244ee8b89f977adaec08a1","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjQsImlhdCI6MTcwOTU2NjE5OCwiZXhwIjoxNzA5NTk0OTk4fQ.4JqQa8jTbiyPx_DMRtLgJXgsrTrcxerLjW-by9KuCAM","description":""}],"authentication":{},"metaSortKey":-1697439534437.75,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_ffe156a5773249fab1e6a4c05bc7a7b2","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709714081474,"created":1697722213218,"url":"http://localhost:3000/api/organizations/1","name":"UpdateOrganization","description":"","method":"PUT","body":{"mimeType":"application/json","text":"{\n\t\"name\" : \"Blink Inc.\",\n\t\"location\" : \"Naples, Italy\",\n\t\"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\"is_hiring\": true\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_fc5a2e2b439942a6ae18401fd037d0b9"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_164bb1219a27446fa2f897510640bb94"},{"id":"pair_e998ceb2025440638d70aa62f0cba85b","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjQsImlhdCI6MTcwOTU2NjE5OCwiZXhwIjoxNzA5NTk0OTk4fQ.4JqQa8jTbiyPx_DMRtLgJXgsrTrcxerLjW-by9KuCAM","description":""}],"authentication":{},"metaSortKey":-1697439516430.0625,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_968318ce61344e6793e96dec1f22aae8","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709714078663,"created":1697614353582,"url":"http://localhost:3000/api/organizations/1","name":"GetOrganization","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_bf5a8e159b4440ad92054d78cf787432"}],"authentication":{},"metaSortKey":-1697439498422.375,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_f8ec3d6839fe4947845671f7fd55fdbf","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709714368365,"created":1697439462407,"url":"http://localhost:3000/api/organizations","name":"CreateOrganization","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"name\" : \"Blink Inc.\",\n\t\"location\" : \"Napoli, Italy\",\n\t\"description\" : \"Blink is a privacy-respecting business-oriented social media platform focused on fostering connections between businesses and individuals, propelling careers and sparking innovation in the professional world.\",\n\t\"is_hiring\" : true\n}"},"parameters":[{"id":"pair_fbb851a173414199aabb5612a4afbe79","name":"","value":"","description":""}],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_e97d33e8311c469d9930459e52897eea"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_d25e174d5f1f4268a348f03b3df16cb7"},{"id":"pair_1718cff2285c40649a4f026ffd5f66aa","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjYsImlhdCI6MTcwOTcxMzg5MCwiZXhwIjoxNzA5NzQyNjkwfQ.vIZVqYkIDbwhdNbjD0YWlQ62yVHl28vUMdxHxxFEKNg","description":""}],"authentication":{},"metaSortKey":-1697439462407,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_6f76fbcacefd48c59071f97601437691","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709714050822,"created":1697535452268,"url":"http://localhost:3000/api/persons/me","name":"DeletePerson","description":"","method":"DELETE","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_f6ccd1a246fd4f468bc67d1d93aaeba9"},{"id":"pair_3c52bb529c5641758476066fbf9420a2","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjMsImlhdCI6MTY5NzUzNTQyNywiZXhwIjoxNjk3NTY0MjI3fQ.rF8xIQElw45fkmOdXaGFiVqMXQvINc1uPkde6-As8-I","description":""}],"authentication":{},"metaSortKey":-1697235183758.625,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_de3a25c274fd44319bd9ef6a6e4353c2","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709714046852,"created":1697719914121,"url":"http://localhost:3000/api/persons/me","name":"UpdatePerson","description":"","method":"PUT","body":{"mimeType":"application/json","text":"{\n\t\"display_name\": \"John J. Doe\",\n\t\"date_of_birth\": \"1970-01-01\",\n\t\"available\": \"false\",\n\t\"place_of_living\": \"New York City, NY\",\n\t\"new_password\": \"password\",\n\t\"old_password\": \"password\",\n\t\"about_me\" : \"I am a VERY passionate software engineer\",\n\t\"qualification\" : \"Software Engineer at Blink Inc.\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_48550a7ad35b41778139f1efea6d6d52"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_050cd5497a3247779057ebfa8df9f7af"},{"id":"pair_009590274cc1470b9265940e398e8c40","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjUsImlhdCI6MTcwOTU2Nzc4OCwiZXhwIjoxNzA5NTk2NTg4fQ.t2pS23aRAvEzMMRZfRaf7n_GAyn29ZolC3TPX7o5LNc","description":""}],"authentication":{},"metaSortKey":-1697133044434.4375,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_42a99668d8b54875b30d262fd2c879cd","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709713904852,"created":1708354567080,"url":"http://localhost:3000/api/persons/me","name":"GetMyself","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_fbdfeef3bb9b45b0aaa4d137cd9cd56c"},{"id":"pair_2d3b8d4c6a48459789363053fc3a5c3e","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjYsImlhdCI6MTcwOTcxMzg5MCwiZXhwIjoxNzA5NzQyNjkwfQ.vIZVqYkIDbwhdNbjD0YWlQ62yVHl28vUMdxHxxFEKNg","description":""}],"authentication":{},"metaSortKey":-1697081974772.3438,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_dae96bd469c843f598826a48a84cc163","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709712984533,"created":1697452790733,"url":"http://localhost:3000/api/persons/1/details","name":"GetPerson","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_f979eeb78d5d484b87bb2142931bfe88"}],"authentication":{},"metaSortKey":-1697030905110.25,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_60a0e5c9013f4f5e9dcbc7ec3aac5970","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709714012418,"created":1709544547074,"url":"http://localhost:3000/api/persons/me/activation?q=3ac9c204de1676b54163ed8015c7af00","name":"ActivatePerson","description":"","method":"GET","body":{"mimeType":"application/json","text":""},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"},{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1696826626461.875,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_d8ac8e10c0024e26a9eb1aaafaffb243","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709713701007,"created":1697439499759,"url":"http://localhost:3000/api/persons/me/token","name":"Login","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"email\": \"john@mail.org\",\n\t\"password\": \"password\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"},{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1696622347813.5,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_00e6ecfd87ef4f3a8b3b026b7e8d515b","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709713686195,"created":1695805233220,"url":"http://localhost:3000/api/persons","name":"Register","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"email\" : \"john@mail.org\",\n\t\"password\" : \"password\",\n\t\"display_name\" : \"John Doe\",\n\t\"about_me\" : \"I am a passionate software engineer\",\n\t\"qualification\" : \"Software Engineer\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_4995c469a16542358ad1b61eb49793f1"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_85a8fc0b1f9540cf9b89da7b801ec746"}],"authentication":{"type":"bearer"},"metaSortKey":-1695805233220,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"env_1bad359b6b8146de8a5d9a444aa06428","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1695805230956,"created":1695805230956,"name":"Base Environment","data":{},"dataPropertyOrder":null,"color":null,"isPrivate":false,"metaSortKey":1695805230956,"_type":"environment"},{"_id":"jar_a60b179878784b6d87f4472cd274e0c0","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1695805230957,"created":1695805230957,"name":"Default Jar","cookies":[],"_type":"cookie_jar"}]} \ No newline at end of file +{"_type":"export","__export_format":4,"__export_date":"2024-03-12T10:59:12.257Z","__export_source":"insomnia.desktop.app:v2023.5.8","resources":[{"_id":"req_353c00d003d849938033eea0deb34e81","parentId":"wrk_03c6f304b2d74c2887a53176ac5513d0","modified":1709716751803,"created":1698054725162,"url":"http://localhost:3000/api/organizations/1/admins/me","name":"RemoveOrganizationAdmin","description":"","method":"DELETE","body":{"mimeType":"application/json","text":""},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_96dd7956eedd4029a62a8953d48384fd"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_5b4b316379204e8a9f34ad6b8520cf02"},{"id":"pair_0f33ba2fe5aa4a9c9610531991a08fff","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjYsImlhdCI6MTcwOTcxMzg5MCwiZXhwIjoxNzA5NzQyNjkwfQ.vIZVqYkIDbwhdNbjD0YWlQ62yVHl28vUMdxHxxFEKNg","description":""}],"authentication":{},"metaSortKey":-1698054725162,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"wrk_03c6f304b2d74c2887a53176ac5513d0","parentId":null,"modified":1710240059108,"created":1710240059108,"name":"Blink","description":"","scope":"collection","_type":"workspace"},{"_id":"req_e5824544aa0a4204b7ab237a0c48ddee","parentId":"wrk_03c6f304b2d74c2887a53176ac5513d0","modified":1709716745972,"created":1697612039148,"url":"http://localhost:3000/api/organizations/1/admins","name":"AddOrganizationAdmin","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"person_id\" : \"2\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_7f6436f6c14046f881b4325c0401f678"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_17a5c397cc2d44d58a70ad0f3ef13d5b"},{"id":"pair_56656674434c4b5f9eb6616c7b662fc1","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjYsImlhdCI6MTcwOTcxMzg5MCwiZXhwIjoxNzA5NzQyNjkwfQ.vIZVqYkIDbwhdNbjD0YWlQ62yVHl28vUMdxHxxFEKNg","description":""}],"authentication":{},"metaSortKey":-1697612039148,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_f1030317f3984cd6a923f48dd9520749","parentId":"wrk_03c6f304b2d74c2887a53176ac5513d0","modified":1709716738908,"created":1697439750530,"url":"http://localhost:3000/api/organizations/posts/1","name":"DeleteOrganizationPost","description":"","method":"DELETE","body":{"mimeType":"application/json","text":""},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_1cf0a9865fc54eb28b06b007dcfb87b6"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_e116a62c90714a2fa936db757b86345a"},{"id":"pair_af07de8a9e584d74bf22de772a1a5116","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjYsImlhdCI6MTcwOTcxMzg5MCwiZXhwIjoxNzA5NzQyNjkwfQ.vIZVqYkIDbwhdNbjD0YWlQ62yVHl28vUMdxHxxFEKNg","description":""}],"authentication":{},"metaSortKey":-1697439750530,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_53b1b5cda7e64ce186df83c656fe08af","parentId":"wrk_03c6f304b2d74c2887a53176ac5513d0","modified":1709714773151,"created":1697443352055,"url":"http://localhost:3000/api/organizations/1/posts/","name":"CreateOrganizationPost","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"content\" : \"Reach to us on Blink!\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_6e74726d8b9d4be883fb296363f27e4c"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_e355a0ac56664aaa95d1fba431f09a9c"},{"id":"pair_639ce915c16a4e36b23c5eec89acb7c2","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjYsImlhdCI6MTcwOTcxMzg5MCwiZXhwIjoxNzA5NzQyNjkwfQ.vIZVqYkIDbwhdNbjD0YWlQ62yVHl28vUMdxHxxFEKNg","description":""}],"authentication":{},"metaSortKey":-1697439606468.5,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_36b31cd2cfa54e0c8ced3e7aadfeb11a","parentId":"wrk_03c6f304b2d74c2887a53176ac5513d0","modified":1709714106217,"created":1697536019056,"url":"http://localhost:3000/api/organizations/1","name":"DeleteOrganization","description":"","method":"DELETE","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_b65bf581b26e4d73b696c173b04c04a2"},{"id":"pair_5b4068cf97244ee8b89f977adaec08a1","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjQsImlhdCI6MTcwOTU2NjE5OCwiZXhwIjoxNzA5NTk0OTk4fQ.4JqQa8jTbiyPx_DMRtLgJXgsrTrcxerLjW-by9KuCAM","description":""}],"authentication":{},"metaSortKey":-1697439534437.75,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_dce63f1d04cb4eb08e84b9ab100af1a5","parentId":"wrk_03c6f304b2d74c2887a53176ac5513d0","modified":1710240072291,"created":1697722213218,"url":"http://localhost:3000/api/organizations/1","name":"UpdateOrganization","description":"","method":"PATCH","body":{"mimeType":"application/json","text":"{\n\t\"name\" : \"Blink Inc.\",\n\t\"location\" : \"Naples, Italy\",\n\t\"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\"is_hiring\": true\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_fc5a2e2b439942a6ae18401fd037d0b9"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_164bb1219a27446fa2f897510640bb94"},{"id":"pair_e998ceb2025440638d70aa62f0cba85b","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjQsImlhdCI6MTcwOTU2NjE5OCwiZXhwIjoxNzA5NTk0OTk4fQ.4JqQa8jTbiyPx_DMRtLgJXgsrTrcxerLjW-by9KuCAM","description":""}],"authentication":{},"metaSortKey":-1697439516430.0625,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_e4f87f48029c4661a3564a3b7dfc4253","parentId":"wrk_03c6f304b2d74c2887a53176ac5513d0","modified":1709714078663,"created":1697614353582,"url":"http://localhost:3000/api/organizations/1","name":"GetOrganization","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_bf5a8e159b4440ad92054d78cf787432"}],"authentication":{},"metaSortKey":-1697439498422.375,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_de1fd73e9ba94a71b1c81b7f827dc629","parentId":"wrk_03c6f304b2d74c2887a53176ac5513d0","modified":1709714368365,"created":1697439462407,"url":"http://localhost:3000/api/organizations","name":"CreateOrganization","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"name\" : \"Blink Inc.\",\n\t\"location\" : \"Napoli, Italy\",\n\t\"description\" : \"Blink is a privacy-respecting business-oriented social media platform focused on fostering connections between businesses and individuals, propelling careers and sparking innovation in the professional world.\",\n\t\"is_hiring\" : true\n}"},"parameters":[{"id":"pair_fbb851a173414199aabb5612a4afbe79","name":"","value":"","description":""}],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_e97d33e8311c469d9930459e52897eea"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_d25e174d5f1f4268a348f03b3df16cb7"},{"id":"pair_1718cff2285c40649a4f026ffd5f66aa","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjYsImlhdCI6MTcwOTcxMzg5MCwiZXhwIjoxNzA5NzQyNjkwfQ.vIZVqYkIDbwhdNbjD0YWlQ62yVHl28vUMdxHxxFEKNg","description":""}],"authentication":{},"metaSortKey":-1697439462407,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_50bf12f3b7fd4a9d96637b36545c1b71","parentId":"wrk_03c6f304b2d74c2887a53176ac5513d0","modified":1709714050822,"created":1697535452268,"url":"http://localhost:3000/api/persons/me","name":"DeletePerson","description":"","method":"DELETE","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_f6ccd1a246fd4f468bc67d1d93aaeba9"},{"id":"pair_3c52bb529c5641758476066fbf9420a2","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjMsImlhdCI6MTY5NzUzNTQyNywiZXhwIjoxNjk3NTY0MjI3fQ.rF8xIQElw45fkmOdXaGFiVqMXQvINc1uPkde6-As8-I","description":""}],"authentication":{},"metaSortKey":-1697235183758.625,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_ab2dc581ed5f42ea8e5abe4d24d596c5","parentId":"wrk_03c6f304b2d74c2887a53176ac5513d0","modified":1710240067434,"created":1697719914121,"url":"http://localhost:3000/api/persons/me","name":"UpdatePerson","description":"","method":"PATCH","body":{"mimeType":"application/json","text":"{\n\t\"display_name\": \"John J. Doe\",\n\t\"date_of_birth\": \"1970-01-01\",\n\t\"available\": \"false\",\n\t\"place_of_living\": \"New York City, NY\",\n\t\"new_password\": \"password\",\n\t\"old_password\": \"password\",\n\t\"about_me\" : \"I am a VERY passionate software engineer\",\n\t\"qualification\" : \"Software Engineer at Blink Inc.\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_48550a7ad35b41778139f1efea6d6d52"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_050cd5497a3247779057ebfa8df9f7af"},{"id":"pair_009590274cc1470b9265940e398e8c40","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjUsImlhdCI6MTcwOTU2Nzc4OCwiZXhwIjoxNzA5NTk2NTg4fQ.t2pS23aRAvEzMMRZfRaf7n_GAyn29ZolC3TPX7o5LNc","description":""}],"authentication":{},"metaSortKey":-1697133044434.4375,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_8f1e5a6d88f04a17bad5a926769c8ec4","parentId":"wrk_03c6f304b2d74c2887a53176ac5513d0","modified":1709713904852,"created":1708354567080,"url":"http://localhost:3000/api/persons/me","name":"GetMyself","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_fbdfeef3bb9b45b0aaa4d137cd9cd56c"},{"id":"pair_2d3b8d4c6a48459789363053fc3a5c3e","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjYsImlhdCI6MTcwOTcxMzg5MCwiZXhwIjoxNzA5NzQyNjkwfQ.vIZVqYkIDbwhdNbjD0YWlQ62yVHl28vUMdxHxxFEKNg","description":""}],"authentication":{},"metaSortKey":-1697081974772.3438,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_2ba97796b8d54085ba811e2bb34b6e03","parentId":"wrk_03c6f304b2d74c2887a53176ac5513d0","modified":1709712984533,"created":1697452790733,"url":"http://localhost:3000/api/persons/1/details","name":"GetPerson","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_f979eeb78d5d484b87bb2142931bfe88"}],"authentication":{},"metaSortKey":-1697030905110.25,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_0846ba56d088479fb68530d6b0a9e864","parentId":"wrk_03c6f304b2d74c2887a53176ac5513d0","modified":1709714012418,"created":1709544547074,"url":"http://localhost:3000/api/persons/me/activation?q=3ac9c204de1676b54163ed8015c7af00","name":"ActivatePerson","description":"","method":"GET","body":{"mimeType":"application/json","text":""},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"},{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1696826626461.875,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_3ed26d21d343456cb4ead32c69cacf63","parentId":"wrk_03c6f304b2d74c2887a53176ac5513d0","modified":1709713701007,"created":1697439499759,"url":"http://localhost:3000/api/persons/me/token","name":"Login","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"email\": \"john@mail.org\",\n\t\"password\": \"password\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"},{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1696622347813.5,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_b5a503b420af40c78c39d73ea57e81c8","parentId":"wrk_03c6f304b2d74c2887a53176ac5513d0","modified":1709713686195,"created":1695805233220,"url":"http://localhost:3000/api/persons","name":"Register","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"email\" : \"john@mail.org\",\n\t\"password\" : \"password\",\n\t\"display_name\" : \"John Doe\",\n\t\"about_me\" : \"I am a passionate software engineer\",\n\t\"qualification\" : \"Software Engineer\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_4995c469a16542358ad1b61eb49793f1"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_85a8fc0b1f9540cf9b89da7b801ec746"}],"authentication":{"type":"bearer"},"metaSortKey":-1695805233220,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"env_2530ad743f3a4263b907635ef8fe5abd","parentId":"wrk_03c6f304b2d74c2887a53176ac5513d0","modified":1695805230956,"created":1695805230956,"name":"Base Environment","data":{},"dataPropertyOrder":null,"color":null,"isPrivate":false,"metaSortKey":1695805230956,"_type":"environment"},{"_id":"jar_449b57fa666d406bbfd072040f42d603","parentId":"wrk_03c6f304b2d74c2887a53176ac5513d0","modified":1695805230957,"created":1695805230957,"name":"Default Jar","cookies":[],"_type":"cookie_jar"}]} \ No newline at end of file diff --git a/backend/apis/nodejs/src/routes/organization_routes.js b/backend/apis/nodejs/src/routes/organization_routes.js index 5b4bc52..bd1793f 100644 --- a/backend/apis/nodejs/src/routes/organization_routes.js +++ b/backend/apis/nodejs/src/routes/organization_routes.js @@ -14,6 +14,7 @@ const organizationModel = require('../models/organization_model'); const express = require('express'); const jwtUtils = require('../utils/middleware_utils'); +const organizationValidator = require('../utils/validators/organization_validator'); /** * POST Request @@ -25,17 +26,18 @@ const jwtUtils = require('../utils/middleware_utils'); * @returns the inserted organization */ async function createOrganization(req, res) { - // Ensure that the required fields are present before proceeding - if (!req.body.name) { - return res.status(400).json({ - error: 'Invalid request' - }); - } try { + const errors = organizationValidator.createOrganizationValidator(req); + if (!errors.isEmpty()) { + return res.status(400).json({ + errors: errors.array() + }); + } const organization = organizationModel.createOrganization(req.body.name, req.body.location, req.body.description, req.body.is_hiring); const insertedOrganization = await organizationModel.insertOrganization(organization, req.jwt.person_id); - return res.status(200).json(insertedOrganization); + res.set('Location', `/api/organizations/${insertedOrganization.id}`); + return res.status(201).json(insertedOrganization); } catch (error) { console.error(`Error in function ${createOrganization.name}: ${error}`); res.status(500).json({ @@ -45,27 +47,34 @@ async function createOrganization(req, res) { } /** - * PUT Request + * PATCH Request * Updates an Organization's details * * Required field(s): none. */ async function updateOrganization(req, res) { + const errors = organizationValidator.createOrganizationValidator(req); + if (!errors.isEmpty()) { + return res.status(400).json({ + errors: errors.array() + }); + } + const updateOrganization = {}; - if (req.body.name) { + if (req.body.name != undefined) { updateOrganization.name = req.body.name; } - if (req.body.location) { + if (req.body.location != undefined) { updateOrganization.location = req.body.location; } - if (req.body.description) { + if (req.body.description != undefined) { updateOrganization.description = req.body.description; } - if (req.body.is_hiring) { + if (req.body.is_hiring != undefined) { updateOrganization.is_hiring = req.body.is_hiring; } @@ -78,9 +87,7 @@ async function updateOrganization(req, res) { try { const isUpdateSuccessful = organizationModel.updateOrganization(updateOrganization, req.params.id, req.jwt.person_id); if (isUpdateSuccessful) { - return res.status(200).json({ - success: 'true' - }); + return res.status(204).send(); } else { return res.status(404).json({ error: 'Organization either not found or insufficient permissions' @@ -102,11 +109,15 @@ async function updateOrganization(req, res) { */ async function deleteOrganization(req, res) { try { + const errors = organizationValidator.createOrganizationValidator(req); + if (!errors.isEmpty()) { + return res.status(400).json({ + errors: errors.array() + }); + } const isDeleteSuccessful = await organizationModel.deleteOrganization(req.params.id, req.jwt.person_id); if (isDeleteSuccessful) { - return res.status(200).json({ - success: true - }); + return res.status(204).send(); } return res.status(403).json({ error: 'Forbidden' @@ -130,6 +141,12 @@ async function deleteOrganization(req, res) { */ async function getOrganization(req, res) { try { + const errors = organizationValidator.createOrganizationValidator(req); + if (!errors.isEmpty()) { + return res.status(400).json({ + errors: errors.array() + }); + } const organization = await organizationModel.getOrganizationById(req.params.id); if (organization) { return res.status(200).json(organization); @@ -147,13 +164,13 @@ async function getOrganization(req, res) { } const publicRoutes = express.Router(); -publicRoutes.get('/organizations/:id', getOrganization); +publicRoutes.get('/organizations/:id', organizationValidator.deleteOrGetOrganizationValidator, getOrganization); const protectedRoutes = express.Router(); protectedRoutes.use(jwtUtils.verifyToken); -protectedRoutes.post('/organizations', createOrganization); -protectedRoutes.put('/organizations/:id', updateOrganization); -protectedRoutes.delete('/organizations/:id', deleteOrganization); +protectedRoutes.post('/organizations', organizationValidator.createOrganizationValidator, createOrganization); +protectedRoutes.patch('/organizations/:id', organizationValidator.updateOrganizationValidator, updateOrganization); +protectedRoutes.delete('/organizations/:id', organizationValidator.deleteOrGetOrganizationValidator, deleteOrganization); module.exports = { publicRoutes, diff --git a/backend/apis/nodejs/src/utils/validators/organization_validator.js b/backend/apis/nodejs/src/utils/validators/organization_validator.js new file mode 100644 index 0000000..fca15d0 --- /dev/null +++ b/backend/apis/nodejs/src/utils/validators/organization_validator.js @@ -0,0 +1,50 @@ +/* + 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"); + +const createOrganizationValidator = [ + check('name').trim().notEmpty().escape().isLength({ + max: 128 + }), + check('location').trim().escape().isLength({ + max: 256 + }), + check('description').trim().escape(), + check('is_hiring').isBoolean() +]; + +const updateOrganizationValidator = [ + check('name').trim().notEmpty().escape().isLength({ + max: 128 + }), + check('location').trim().escape().isLength({ + max: 256 + }), + check('description').trim().escape(), + check('is_hiring').optional().isBoolean() +]; + +const deleteOrGetOrganizationValidator = [ + check('id').notEmpty().escape() +] + +module.exports = { + validationResult, + createOrganizationValidator, + updateOrganizationValidator, + deleteOrGetOrganizationValidator +} \ No newline at end of file