{"id":20876828,"url":"https://github.com/brawlingthebits/users-crud-adm-permission","last_synced_at":"2025-03-12T16:25:13.152Z","repository":{"id":156620344,"uuid":"491267984","full_name":"brawlingthebits/users-crud-adm-permission","owner":"brawlingthebits","description":"This is an users crud with permission using node.js express ","archived":false,"fork":false,"pushed_at":"2022-05-14T17:38:30.000Z","size":83,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-19T09:30:26.610Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brawlingthebits.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-11T20:48:30.000Z","updated_at":"2022-05-12T16:34:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"679ad333-8ebd-4d99-8efa-f1c19a85068e","html_url":"https://github.com/brawlingthebits/users-crud-adm-permission","commit_stats":null,"previous_names":["brawlingthebits/users-crud-adm-permission"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brawlingthebits%2Fusers-crud-adm-permission","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brawlingthebits%2Fusers-crud-adm-permission/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brawlingthebits%2Fusers-crud-adm-permission/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brawlingthebits%2Fusers-crud-adm-permission/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brawlingthebits","download_url":"https://codeload.github.com/brawlingthebits/users-crud-adm-permission/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243250704,"owners_count":20261070,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T06:55:07.413Z","updated_at":"2025-03-12T16:25:13.131Z","avatar_url":"https://github.com/brawlingthebits.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Users CRUD and ADM permission\n\nThis is an exercise from Kenzie Academy Brasil to train users crud with Node.js Express using JWT and bcrypt libraries.\n\n---\n\n(PT-BR) Este é um exercício da Kenzie Academy Brasil para treinar o crud de usuários com Node.js Express usando as bibliotecas JWT e Bcrypt. \n\n\n## Requests and Responses\n\n### Register\n\nPOST - `http://localhost:3000/users` \n\n```json\n\n{\n\t\"name\": \"John Doe\",\n\t\"email\": \"john@mail.com\",\n\t\"password\": \"987654321\",\n\t\"isAdm\": false\n}\n\n```\nPOST - `http://localhost:3000/users` - 200 OK\n\n\n```json\n{\n\t\"id\": \"20afbd3d-1f5c-4fb6-aa55-0b87d689e669\",\n\t\"name\": \"John Doe\",\n\t\"email\": \"john@mail.com\",\n\t\"isAdm\": false,\n\t\"password\": \"$2a$10$rijV.3mCoMmvMw51dXgfWusvud4ZThUJqMFrd2VE1x30EPDCrjoLG\",\n\t\"createdOn\": \"Sat May 14 2022 13:45:04 GMT-0300 (Brasilia Standard Time)\",\n\t\"updatedOn\": \"Sat May 14 2022 13:45:04 GMT-0300 (Brasilia Standard Time)\"\n}\n```\n\nPOST - `http://localhost:3000/users` - 400 Bad Request\n\nIf I try to register the same email again:\n\n```json\n{\n\t\"message\": \"This email is already taken\"\n}\n```\n### Login\n\nPOST - `http://localhost:3000/login`\n\n```json\n{\n\t\"email\": \"john@mail.com\",\n\t\t\"password\": \"987654321\"\n}\n```\n\nIf everything is right:\n\nPOST - `http://localhost:3000/login` - 200 OK\n\n```json\n{\n\t\"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImpvaG5AbWFpbC5jb20iLCJpYXQiOjE2NTI1NDY5NTksImV4cCI6MTY1MjU1MDU1OX0.uTLtlxLzCoRw-y3zUZ43RmqXXg8Lfd5eg2vmnilThuQ\"\n}\n```\n\nHowever, if your email or password is wrong:\n\nPOST - `http://localhost:3000/login` - 400 Bad Request\n\n```json\n{\n\t\"message\": \"Wrong email or password\"\n}\n```\n### User Profile\n\nIt is necessary to insert the token from login to have access. \n\nGET - `http://localhost:3000/users/profile` - 200 OK\n\n```json\n{\n\t\"id\": \"47000dd2-1e85-49b2-9c6d-e097454bef97\",\n\t\"name\": \"John Doe\",\n\t\"email\": \"john@mail.com\",\n\t\"isAdm\": false,\n\t\"password\": \"$2a$10$WlMupMuA060zJzOUSvAvTev9jVjDKR0uvld3ISLfHokY8sgodxlUq\",\n\t\"createdOn\": \"Sat May 14 2022 14:11:30 GMT-0300 (Brasilia Standard Time)\",\n\t\"updatedOn\": \"Sat May 14 2022 14:11:30 GMT-0300 (Brasilia Standard Time)\"\n}\n```\n\n### All users\n\nIt is necessary to be a administrator to access this route and insert its token.\n\nGET - `http://localhost:3000/users/profile` - 200 OK\n\n```json\n\n[\n\t{\n\t\t\"id\": \"86cb86ed-bcc1-408c-a1e8-d703ae1092fd\",\n\t\t\"name\": \"Billie Doe\",\n\t\t\"email\": \"billie@mail.com\",\n\t\t\"isAdm\": true,\n\t\t\"password\": \"$2a$10$BMJYDWrQNmF79o.3JOjnBOnhj7AzOUbY61vOHTU7f3Kkg4BvHCpMO\",\n\t\t\"createdOn\": \"Sat May 14 2022 14:26:05 GMT-0300 (Brasilia Standard Time)\",\n\t\t\"updatedOn\": \"Sat May 14 2022 14:26:05 GMT-0300 (Brasilia Standard Time)\"\n\t},\n\t{\n\t\t\"id\": \"a2fb5a2c-115c-4bd2-9796-98bc3eea7b8b\",\n\t\t\"name\": \"Jogn Doe\",\n\t\t\"email\": \"John@mail.com\",\n\t\t\"isAdm\": true,\n\t\t\"password\": \"$2a$10$1fos0VMXDlNLyavdUZQRN.CNe8wWNq3.bQjSD.3dh3ci2Z/Vhyg6C\",\n\t\t\"createdOn\": \"Sat May 14 2022 14:26:35 GMT-0300 (Brasilia Standard Time)\",\n\t\t\"updatedOn\": \"Sat May 14 2022 14:26:35 GMT-0300 (Brasilia Standard Time)\"\n\t}\n]\n\n```\n\nGET - `http://localhost:3000/users/profile` - 401 Unauthorized\n\n```json\n{\n\t\"message\": \"You should be an adm to see this route\"\n}\n```\n\n### Update \n\nIt is necessary to be the owner to update or the administrador to insert a token.\n\nPATCH - `http://localhost:3000/users/:userid`\n\n```\n{\n\t\"name\": \"Billy\",\n\t\"email\": \"bill@mail.com\"\n}\n```\n\nPATCH - `http://localhost:3000/users/86cb86ed-bcc1-408c-a1e8-d703ae1092fd``- 200 OK\n\n```json\n{\n\t\"id\": \"86cb86ed-bcc1-408c-a1e8-d703ae1092fd\",\n\t\"isAdm\": true,\n\t\"password\": \"$2a$10$BMJYDWrQNmF79o.3JOjnBOnhj7AzOUbY61vOHTU7f3Kkg4BvHCpMO\",\n\t\"createdOn\": \"Sat May 14 2022 14:26:05 GMT-0300 (Brasilia Standard Time)\",\n\t\"updatedOn\": \"Sat May 14 2022 14:28:36 GMT-0300 (Brasilia Standard Time)\"\n}\n```\n\nPATCH - `http://localhost:3000/users/86cb86ed-bcc1-408c-a1e8-d703ae1092fd` - 400 Bad Request\n\n```JSON\n\"User not found\"\n```\n\n### Delete\n\nIt is necessary just insert the token being the owner or the administrador. Request body should be empty.\n\nDELETE - `http://localhost:3000/users/:userid` \n\nWe are goind to delete the same user we had update:\n\nDELETE - `http://localhost:3000/users/86cb86ed-bcc1-408c-a1e8-d703ae1092fd` - 200 OK\n\n```JSON\n\"User deleted successfully\"\n```\n\nNow, this user is deleted, so we cannot delete it again.\n\nDELETE - `http://localhost:3000/users/86cb86ed-bcc1-408c-a1e8-d703ae1092fd` - 400 Bad Request\n\n```JSON\n\"User not found\"\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrawlingthebits%2Fusers-crud-adm-permission","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrawlingthebits%2Fusers-crud-adm-permission","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrawlingthebits%2Fusers-crud-adm-permission/lists"}