{"id":29749861,"url":"https://github.com/mujibsayyad/node-authify","last_synced_at":"2026-04-16T10:32:10.825Z","repository":{"id":153069369,"uuid":"626284950","full_name":"mujibsayyad/node-authify","owner":"mujibsayyad","description":"Node-Authify: Easy Authentication for MERN Stack","archived":false,"fork":false,"pushed_at":"2023-04-14T19:20:13.000Z","size":880,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-27T22:58:42.537Z","etag":null,"topics":["authentication","express","expressjs","jwt","jwt-authentication","middleware","node-authify","nodejs","npm","npm-package"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/node-authify","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mujibsayyad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null}},"created_at":"2023-04-11T06:53:07.000Z","updated_at":"2023-10-19T19:48:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"9f3c0b15-c9e3-4600-8cc0-c8d6b63c201a","html_url":"https://github.com/mujibsayyad/node-authify","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mujibsayyad/node-authify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mujibsayyad%2Fnode-authify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mujibsayyad%2Fnode-authify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mujibsayyad%2Fnode-authify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mujibsayyad%2Fnode-authify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mujibsayyad","download_url":"https://codeload.github.com/mujibsayyad/node-authify/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mujibsayyad%2Fnode-authify/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31882064,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T09:23:21.276Z","status":"ssl_error","status_checked_at":"2026-04-16T09:23:15.028Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["authentication","express","expressjs","jwt","jwt-authentication","middleware","node-authify","nodejs","npm","npm-package"],"created_at":"2025-07-26T12:12:59.765Z","updated_at":"2026-04-16T10:32:10.810Z","avatar_url":"https://github.com/mujibsayyad.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-authify\n\n### Authentication Library for MERN Stack\n\nThis is a simple library for implementing user authentication in a MERN (MongoDB, Express, React, Node.js) stack. It uses JWT (JSON Web Tokens) for authentication and authorization.\n\n## Integration\n\nSecure your React.js application with ease using [react-authify](https://www.npmjs.com/package/react-authify), a library that provides ready-to-use authentication components.\n\n## Installation\n\nTo install the library, use npm or yarn:\n\n```bash\nnpm install node-authify\n```\n\n```bash\nyarn add node-authify\n```\n\n## Usage\n\nStep 1: Create a `.env` file and add `secretkey` for JWT token.\n`Ex. SECRETKEY = SOMERANDOMEKEYHARDTOGUESS`\n\n## Login\n\nWhen generating the token during the `login` process, make sure to use the same secret key that is specified in the `.env` file. This is important because the `checkAuth` function uses this secret key to verify the authenticity of the token during subsequent requests. If a different secret key is used, the token will not be verified successfully and the request will be rejected.\n\n```javascript\nexports.login = async (req, res) =\u003e {\n  const { email, password } = req.body; // Check if email and password are present\n  if (!email || !password) {\n    return res.status(422).json({ message: 'Email and password are required' });\n  }\n\n  // rest of your code\n\n  // If the email and password are correct, create a JWT token\n  // Make sure to use same SECRETKEY in this function\n  const token = jwt.sign({ user: foundUser }, process.env.SECRETKEY, {\n    expiresIn: '12h',\n  });\n\n  res.status(201).json({ user: foundUser, token: token });\n};\n```\n\n## Middleware\n\nStep 2: Pass this `SECRETKEY` in `checkAuth(process.env.SECRETKEY)` middleware\n\n```javascript\n// routes.js\nconst express = require('express');\nconst router = express.Router();\nconst checkAuth = require('node-authify');\n\nrouter.use(checkAuth('secret-key'));\n\nrouter.delete('/delete/:id', deleteUserById);\n\n// OR you can use like this\n\nrouter.delete('/delete/:id', checkAuth('secret-key'), deleteUserById);\n```\n\nAfter succesfull verification you can access users information. You can perform authorization task based on this.\n\n## Usage Note\n\nAnother point to mention in the library overview would be that upon successful verification of the JWT token, the checkAuth middleware adds the decoded token as a property `user` to the `req` object. This allows the user's information to be accessed in subsequent middleware or route handlers, enabling the implementation of role-based access control or other forms of user authentication.\n\n```javascript\nconst userId = req.user.userId;\nif (todo.user.toString() !== userId) {\n  return res.status(401).json({ message: 'Unauthorized' });\n}\n```\n\n## Feedback\n\nNode-Authify is actively under development to add more features, improve performance, and address any issues reported during testing. Feedback from users testing the library is appreciated.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmujibsayyad%2Fnode-authify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmujibsayyad%2Fnode-authify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmujibsayyad%2Fnode-authify/lists"}