{"id":20330238,"url":"https://github.com/sabo99/nodejs-restfulapi-jwt-mongob","last_synced_at":"2026-04-11T13:35:04.544Z","repository":{"id":170699183,"uuid":"428314086","full_name":"sabo99/nodejs-restfulapi-jwt-mongob","owner":"sabo99","description":"NodeJS-Express | Restful API with MongoDB : User Authentication, Authentication JWT (Json Web Token) \u0026 Device Detector User Login","archived":false,"fork":false,"pushed_at":"2022-05-05T13:47:46.000Z","size":180,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-14T15:20:22.157Z","etag":null,"topics":["api","bcryptjs","device-detector","dotenv","express","joi-validation","jsonwebtoken","jwt","mongodb","mongoose","nodemon","rest","rest-api","restful-api"],"latest_commit_sha":null,"homepage":"","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/sabo99.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":"2021-11-15T15:16:40.000Z","updated_at":"2021-11-30T03:32:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"ad2fd819-49c3-48d0-86f3-4d9969e8151c","html_url":"https://github.com/sabo99/nodejs-restfulapi-jwt-mongob","commit_stats":null,"previous_names":["sabo99/nodejs-restfulapi-jwt-mongob"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabo99%2Fnodejs-restfulapi-jwt-mongob","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabo99%2Fnodejs-restfulapi-jwt-mongob/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabo99%2Fnodejs-restfulapi-jwt-mongob/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabo99%2Fnodejs-restfulapi-jwt-mongob/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sabo99","download_url":"https://codeload.github.com/sabo99/nodejs-restfulapi-jwt-mongob/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241844997,"owners_count":20029756,"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":["api","bcryptjs","device-detector","dotenv","express","joi-validation","jsonwebtoken","jwt","mongodb","mongoose","nodemon","rest","rest-api","restful-api"],"created_at":"2024-11-14T20:15:37.417Z","updated_at":"2025-12-31T01:02:57.974Z","avatar_url":"https://github.com/sabo99.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Restful API with MongoDB : User Authentication + CRUD, Authentication JWT (Json Web Token) \u0026 Device Detector User Login\n\n## Technology Used\n\n-   `bcryptjs: ^2.4.3`\n-   `device-detector-js: ^3.0.0`\n-   `cors: ^2.8.5`\n-   `dotenv: ^10.0.0`\n-   `express: ^4.17.1`\n-   `joi: ^17.4.2`\n-   `jsonwebtoken: ^8.5.1`\n-   `mongoose: ^6.0.12`\n-   `nodemon: ^2.0.15`\n\n\u003cbr\u003e\n\n## Project Structure\n\n\u003cimg src=\"./Project Structure.png\"\u003e\n\n\u003cbr\u003e\n\n## APIs Provided\n\n| Methods     | Urls                  |           Actions           |   Token    |\n| :---------- | :-------------------- | :-------------------------: | :--------: |\n| GET         | /                     |    Retrieve Base on APIs    |     -      |\n| POST        | /api/auth/signup      |     SignUp new Account      |     -      |\n| POST        | /api/auth/signin      |      Login an Account       |     -      |\n| GET         | /api/user/public      |   Retrieve Public Content   |     -      |\n| GET         | /api/user/list        | Retrieve Users List Content | `Required` |\n| GET         | /api/user/find        |    Retrieve User Content    | `Required` |\n| PUT / PATCH | /api/user/{id}/update |     Update User Content     | `Required` |\n| DELETE      | /api/user/{id}/delete |     Delete User Content     | `Required` |\n\n\u003cbr\u003e\n\n## Flow for SignUp \u0026 SignIn with JWT Authentication\n\nFollowing diagram shows the flow that we will implement for the `User Registration`, `User Login`, and `Authenticate JWT` Processes.\n\n\u003cimg src=\"./Flow for Signup \u0026 Login with JWT Authentication.png\"\u003e\n\n\u003cbr\u003e\u003cbr\u003e\n\n## APIs Specification\n\n\u003cbr\u003e\n\n## `Base APIs`\n\nRequest :\n\n-   Method : `GET`\n-   Endpoint : `/`\n-   Header :\n\n    -   Content-Type : `application/json`\n    -   Accept : `application/json`\n\n    \u003cbr\u003e\n\n-   Response :\n\n    ```json\n    {\n        \"code\": \"number\",\n        \"message\": \"string\"\n    }\n    ```\n\n    \u003cbr\u003e\n\n## `User Registration`\n\nRequest :\n\n-   Method : `POST`\n-   Endpoint : `/api/auth/signup`\n-   Header :\n\n    -   Content-Type : `application/json`\n    -   Accept : `application/json`\n\n     \u003cbr\u003e\n\n-   Body :\n\n    ```json\n    {\n        \"email\": \"string\",\n        \"username\": \"string\",\n        \"password\": \"string, hash\"\n    }\n    ```\n\n-   Response :\n\n    ```json\n    {\n        \"code\": \"number\",\n        \"message\": \"string\",\n        \"user\": {\n            \"_id\": \"string\",\n            \"email\": \"string\",\n            \"username\": \"string\",\n            \"createdAt\": \"date-string\"\n        }\n    }\n    ```\n\n    \u003cbr\u003e\n\n## `User Login`\n\nRequest :\n\n-   Method : `POST`\n-   Endpoint : `/api/auth/signin`\n-   Header :\n\n    -   Content-Type : `application/json`\n    -   Accept : `application/json`\n\n     \u003cbr\u003e\n\n-   Body :\n    ```json\n    {\n        \"username\": \"string\",\n        \"password\": \"string, hash\"\n    }\n    ```\n-   Response :\n\n    ```json\n    {\n        \"code\": \"number\",\n        \"message\": \"string\",\n        \"user\": {\n            \"_id\": \"string\",\n            \"email\": \"string\",\n            \"username\": \"string\",\n            \"createdAt\": \"date-string\"\n        },\n        \"device-info\": {\n            \"client\": \"object\",\n            \"os\": \"object\",\n            \"device\": \"object\",\n            \"bot\": \"object\"\n        }\n    }\n    ```\n\n    \u003cbr\u003e\n\n## `Public Content`\n\nRequest :\n\n-   Method : `GET`\n-   Endpoint : `/api/user/public`\n-   Header :\n\n    -   Content-Type : `application/json`\n    -   Accept : `application/json`\n\n    \u003cbr\u003e\n\n-   Response :\n\n    ```json\n    {\n        \"code\": \"number\",\n        \"message\": \"string\"\n    }\n    ```\n\n    \u003cbr\u003e\n\n## `User List`\n\n#### `Require token`\n\nRequest :\n\n-   Method : `GET`\n-   Endpoint : `/api/user/list`\n-   Header :\n\n    -   Content-Type : `application/json`\n    -   Accept : `application/json`\n    -   x-auth-token : `string`\n\n    \u003cbr\u003e\n\n-   Response :\n\n    ```json\n    {\n        \"code\": \"number\",\n        \"message\": \"string\",\n        \"user\": [\n            {\n                \"_id\": \"string\",\n                \"email\": \"string\",\n                \"username\": \"string\",\n                \"createdAt\": \"date-string\"\n            },\n            {\n                \"_id\": \"string\",\n                \"email\": \"string\",\n                \"username\": \"string\",\n                \"createdAt\": \"date-string\"\n            }\n        ]\n    }\n    ```\n\n    \u003cbr\u003e\n\n## `Find User`\n\n#### `Require token`\n\n#### example: `/api/user/find?id=1`\n\nRequest :\n\n-   Method : `GET`\n-   Endpoint : `/api/user/find`\n-   Query :\n\n    -   id : `string`\n\n-   Header :\n\n    -   Content-Type : `application/json`\n    -   Accept : `application/json`\n    -   x-auth-token : `string`\n\n    \u003cbr\u003e\n\n-   Response :\n\n    ```json\n    {\n        \"code\": \"number\",\n        \"message\": \"string\",\n        \"user\": {\n            \"_id\": \"string\",\n            \"email\": \"string\",\n            \"username\": \"string\",\n            \"createdAt\": \"date-string\"\n        }\n    }\n    ```\n\n    \u003cbr\u003e\n\n## `Update User`\n\n#### `Require token`\n\nRequest :\n\n-   Method : `PUT / PATCH`\n-   Endpoint : `/api/user/{id}/update`\n-   Header :\n\n    -   Content-Type : `application/json`\n    -   Accept : `application/json`\n    -   x-auth-token : `string`\n\n    \u003cbr\u003e\n\n-   Body :\n\n    ```json\n    {\n        \"email\": \"string\",\n        \"username\": \"string\",\n        \"password\": \"string, hash\"\n    }\n    ```\n\n-   Response :\n\n    ```json\n    {\n        \"code\": \"number\",\n        \"message\": \"string\"\n    }\n    ```\n\n    \u003cbr\u003e\n\n## `Delete User`\n\n#### `Require token`\n\nRequest :\n\n-   Method : `DELETE`\n-   Endpoint : `/api/user/{id}/delete`\n-   Header :\n\n    -   Content-Type : `application/json`\n    -   Accept : `application/json`\n    -   x-auth-token : `string`\n\n    \u003cbr\u003e\n\n-   Response :\n\n    ```json\n    {\n        \"code\": \"number\",\n        \"message\": \"string\"\n    }\n    ```\n\n    \u003cbr\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsabo99%2Fnodejs-restfulapi-jwt-mongob","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsabo99%2Fnodejs-restfulapi-jwt-mongob","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsabo99%2Fnodejs-restfulapi-jwt-mongob/lists"}