{"id":23978174,"url":"https://github.com/softdev629/codevo-nodejs-jwt-auth","last_synced_at":"2025-08-18T09:37:25.145Z","repository":{"id":230972518,"uuid":"780495612","full_name":"softdev629/codevo-nodejs-jwt-auth","owner":"softdev629","description":"JWT Authentication and Authorization","archived":false,"fork":false,"pushed_at":"2024-04-01T21:06:02.000Z","size":46,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-07T08:17:06.732Z","etag":null,"topics":["bycript","cookie","express","jwt-authentication","mongodb","mongoose","nodejs","redis","typegoose","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/softdev629.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}},"created_at":"2024-04-01T15:50:15.000Z","updated_at":"2024-04-01T21:11:55.000Z","dependencies_parsed_at":"2024-04-01T22:24:59.422Z","dependency_job_id":"235f7bae-c3a0-4cbb-919a-3f90b6ee70d5","html_url":"https://github.com/softdev629/codevo-nodejs-jwt-auth","commit_stats":null,"previous_names":["softdev629/codevo-nodejs-jwt-auth"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softdev629%2Fcodevo-nodejs-jwt-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softdev629%2Fcodevo-nodejs-jwt-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softdev629%2Fcodevo-nodejs-jwt-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softdev629%2Fcodevo-nodejs-jwt-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softdev629","download_url":"https://codeload.github.com/softdev629/codevo-nodejs-jwt-auth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240540553,"owners_count":19817791,"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":["bycript","cookie","express","jwt-authentication","mongodb","mongoose","nodejs","redis","typegoose","typescript"],"created_at":"2025-01-07T08:17:08.908Z","updated_at":"2025-02-24T18:52:50.592Z","avatar_url":"https://github.com/softdev629.png","language":"TypeScript","readme":"# JWT Authentication and Authorization\n\n## 1. Node.js + TypeScript + MongoDB: JWT Authentication\n\nIn this article, you'll learn how to add JSON Web Token (JWT) Authentication to your Node.js app with TypeScript, MongoDB, Mongoose, Typegoose, Docker, Redis, and Zod.\n\n![Node.js + TypeScript + MongoDB: JWT Authentication](https://codevoweb.com/wp-content/uploads/2022/04/Node.js-TypeScript-MongoDB-JWT-Authentication.webp)\n\n### Topics Covered\n\n- Setup Development Environment (Optional)\n  - Download and Install Node.js\n  - Download and Install Docker\n  - Download and Install MongoDB Compass\n- Node.js, Redis, MongoDB, Typegoose, Docker: JWT Authentication example\n- JWT Authentication Flow with Redis, MongoDB, and Node.js\n- Project Structure\n- Project Setup\n  - Initialize a Node.js Project with TypeScript\n  - Install the Required Libraries\n  - Initialize and Start the Express Server\n  - Setting up Redis and MongoDB with Docker Compose\n  - Connecting to the MongoDB Docker Container with Mongoose\n  - Connecting to Redis Docker Container\n- Creating the Database Schema with Typegoose\n- How to Generate Private and Public keys for JWT Authentication\n- Define Middleware to Sign and Verify JWTs\n- Define a Custom Error Handler in Express\n- Define the Zod Validation Schema\n- Create a Middleware to Validate the User Inputs\n- Create a Service to Communicate with the Database\n- Create the Authentication Controller\n- Create the User Controller to Test Authorization\n- Define a function to deserialize the User\n- Define a function to check if the user is logged in\n- Define a Middleware to Restrict Unauthorized Access\n- Create the Authentication Routes\n- Update the app.ts file to use the route\n- Testing the JWT Authentication Rest API\n  - Register users\n  - Login user\n  - Get Currently Logged in User's Credentials\n  - Admin Get All Users\n\n## 2. Node.js + TypeScript + MongoDB: JWT Refresh Token\n\nIn this article, you'll learn how to implement JWT Authentication with an Access and a Refresh token using Node.js, TypeScript, MongoDB, Redis, and Docker.\n\n![Node.js + TypeScript + MongoDB: JWT Refresh Token](https://codevoweb.com/wp-content/uploads/2022/04/Node.js-TypeScript-MongoDB-JWT-Refresh-Token.webp)\n\n### Topics Covered\n\n- JWT Refresh Token with Node.js, TypeScript, and MongoDB Overview\n- JWT Refresh Token Implementation Flow\n- Generate Public and Private Keys for the Token\n- Update Environment Variables in Config\n- Update the Sign and Verify JWT Utility Functions\n- Update the Sign Token Service Function\n- Update the Login Controller\n- Create a Controller to Refresh Access Token\n- Create a Controller to Logout User\n- Update the Authentication Routes\n- Update app.ts\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftdev629%2Fcodevo-nodejs-jwt-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftdev629%2Fcodevo-nodejs-jwt-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftdev629%2Fcodevo-nodejs-jwt-auth/lists"}