{"id":48966817,"url":"https://github.com/yujhenchen/express-mongo-otp-auth-ts","last_synced_at":"2026-04-18T04:35:32.304Z","repository":{"id":242692649,"uuid":"808517129","full_name":"yujhenchen/express-mongo-otp-auth-ts","owner":"yujhenchen","description":"An authentication Restful API featuring OTP verification, JSON Web Token authentication ( JWT ), and database CRUD. Built with Express.js, MongoDB, Mongoose, and TypeScript","archived":false,"fork":false,"pushed_at":"2024-07-30T12:40:28.000Z","size":316,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-07-30T18:55:45.170Z","etag":null,"topics":["express","express-js","expressjs","jsonwebtoken","jwt","jwt-authentication","mongodb","mongoose","nodejs","nodemailer","otp","restful-api","restfulapi","restfull-api","typescipt","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/yujhenchen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-05-31T08:30:19.000Z","updated_at":"2024-07-30T12:40:31.000Z","dependencies_parsed_at":"2024-06-29T07:22:50.656Z","dependency_job_id":"b9fb142e-fa8d-4adc-8718-46a04a62159f","html_url":"https://github.com/yujhenchen/express-mongo-otp-auth-ts","commit_stats":null,"previous_names":["yujhenchen/express-mongo-otp-auth-ts"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yujhenchen/express-mongo-otp-auth-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yujhenchen%2Fexpress-mongo-otp-auth-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yujhenchen%2Fexpress-mongo-otp-auth-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yujhenchen%2Fexpress-mongo-otp-auth-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yujhenchen%2Fexpress-mongo-otp-auth-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yujhenchen","download_url":"https://codeload.github.com/yujhenchen/express-mongo-otp-auth-ts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yujhenchen%2Fexpress-mongo-otp-auth-ts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31957084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["express","express-js","expressjs","jsonwebtoken","jwt","jwt-authentication","mongodb","mongoose","nodejs","nodemailer","otp","restful-api","restfulapi","restfull-api","typescipt","typescript"],"created_at":"2026-04-18T04:35:31.550Z","updated_at":"2026-04-18T04:35:32.275Z","avatar_url":"https://github.com/yujhenchen.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca name=\"readme-top\"\u003e\u003c/a\u003e\r\n\r\n\u003c!-- PROJECT LOGO --\u003e\r\n\u003cbr /\u003e\r\n\u003cdiv align=\"center\"\u003e\r\n\r\n\u003ch3 align=\"center\"\u003eExpress MongoDB OTP Auth API\u003c/h3\u003e\r\n\r\n\u003c/div\u003e\r\n\r\n\u003c!-- TABLE OF CONTENTS --\u003e\r\n\u003cdetails\u003e\r\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\r\n  \u003col\u003e\r\n    \u003cli\u003e\r\n      \u003ca href=\"#about-the-project\"\u003eAbout The Project\u003c/a\u003e\r\n      \u003cul\u003e\r\n        \u003cli\u003e\u003ca href=\"#built-with\"\u003eBuilt With\u003c/a\u003e\u003c/li\u003e\r\n      \u003c/ul\u003e\r\n    \u003c/li\u003e\r\n    \u003cli\u003e\r\n      \u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e\r\n      \u003cul\u003e\r\n        \u003c!-- \u003cli\u003e\u003ca href=\"#prerequisites\"\u003ePrerequisites\u003c/a\u003e\u003c/li\u003e --\u003e\r\n        \u003cli\u003e\u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\u003c/li\u003e\r\n      \u003c/ul\u003e\r\n    \u003c/li\u003e\r\n    \u003c!-- \u003cli\u003e\u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\u003c/li\u003e --\u003e\r\n    \u003cli\u003e\u003ca href=\"#issues-and-solutions\"\u003eIssues and solutions\u003c/a\u003e\u003c/li\u003e\r\n    \u003cli\u003e\u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\u003c/li\u003e\r\n  \u003c/ol\u003e\r\n\u003c/details\u003e\r\n\r\n\u003c!-- ABOUT THE PROJECT --\u003e\r\n\r\n## About The Project\r\n\r\nA Restful API backend application built with Express.js and TypeScript, offering robust and scalable solutions for user authentication and data management.\r\n\r\n### Feautres\r\n1. mean Stack Architecture: Follows the [mean stack](https://github.com/linnovate/mean) for a well-structured and maintainable project\r\n2. Schema and Data Validation: Utilizes Joi for defining schemas and validating data, including environment variables (process.env)\r\n3. MongoDB Integration: Employs Mongoose to model and interact with MongoDB Atlas\r\n4. User Authentication: Supports user sign-up, sign-in, and logout functionalities\r\n5. Email Service with OTP: Built with Nodemailer and Brevo, allowing the generation and sending of OTP codes via email\r\n6. CRUD Operations: Provides create, read, update, and delete (CRUD) operations for user data in the MongoDB Atlas database\r\n7. Role-Based Access Control: Implements role-based access control using Bearer Authentication for sensitive API endpoints, such as changing user roles and deleting users\r\n8. Request Validation Middleware: Includes middleware for validating incoming requests to ensure data integrity and security\r\n9. JWT Authentication: Generates JSON Web Tokens (JWT) using the jsonwebtoken library for secure user authentication and authorization\r\n\r\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\r\n\r\n### Built With\r\n\r\n- [![Express.js]][Express.js-url]\r\n- [![MongoDB]][MongoDB-url]\r\n- [![TypeScript]][TypeScript-url]\r\n- [Joi]\r\n- [Mongoose]\r\n- [jsonwebtoken]\r\n- [module-alias]\r\n- [Nodemailer]\r\n\r\n\r\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\r\n\r\n\u003c!-- GETTING STARTED --\u003e\r\n\r\n## Getting Started\r\n\r\nsome steps\r\n\r\n\u003c!-- ### Prerequisites\r\n\r\nThis is an example of how to list things you need to use the software and how to install them.\r\n* npm\r\n  ```sh\r\n  npm install npm@latest -g\r\n  ``` --\u003e\r\n\r\n### Installation\r\n\r\nInstall packages\r\n\r\n```sh\r\nyarn\r\n```\r\n\r\nLaunch at localhost in development mode\r\n\r\n```sh\r\nyarn dev\r\n```\r\n\r\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\r\n\r\n\u003c!-- USAGE EXAMPLES --\u003e\r\n\u003c!-- ## Usage\r\n\r\nUse this space to show useful examples of how a project can be used. Additional screenshots, code examples and demos work well in this space. You may also link to more resources.\r\n\r\n_For more examples, please refer to the [Documentation](https://example.com)_\r\n\r\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e --\u003e\r\n\r\n\u003c!-- ISSUES AND SOLUTIONS --\u003e\r\n\r\n## Issues and solutions\r\n\r\n### Get error `Error: Method no longer accepts array arguments: valid`\r\nThe full error message:\r\n````\r\nnode_modules\\@hapi\\hoek\\lib\\error.js:23\r\n            Error.captureStackTrace(this, exports.assert);\r\n                  ^\r\nError: Method no longer accepts array arguments: valid\r\n````\r\n\r\nWhen passing the array `Object.values(UserRole)` into `Joi.string().valid()`\r\n````\r\nexport const UserRole = {\r\n    ADMIN: 'admin',\r\n    visitor: 'user',\r\n    GUEST: 'guest'\r\n} as const;\r\n\r\n...\r\n\r\nrole: Joi.string().valid(Object.values(UserRole)),\r\n\r\n...\r\n````\r\n\r\n##### Solution\r\n- https://github.com/hapijs/joi/issues/2468\r\n\r\nUse Spread syntax (...) to expand the array.\r\n\r\n````\r\n...\r\n\r\nrole: Joi.string().valid(...Object.values(UserRole)),\r\n\r\n...\r\n````\r\n\r\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\r\n\r\n\u003c!-- LICENSE --\u003e\r\n\r\n## License\r\n\r\nDistributed under the MIT License. See `LICENSE.txt` for more information.\r\n\r\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\r\n\r\n\r\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\r\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\r\n[Express.js]: https://img.shields.io/badge/express.js-%23404d59.svg?style=for-the-badge\u0026logo=express\u0026logoColor=%2361DAFB\r\n[Express.js-url]: https://expressjs.com/\r\n[MongoDB]: https://img.shields.io/badge/MongoDB-%234ea94b.svg?style=for-the-badge\u0026logo=mongodb\u0026logoColor=white\r\n[MongoDB-url]: https://www.mongodb.com/products/platform/atlas-database\r\n[TypeScript]: https://img.shields.io/badge/typescript-%23007ACC.svg?style=for-the-badge\u0026logo=typescript\u0026logoColor=white\r\n[TypeScript-url]: https://www.typescriptlang.org/\r\n[Joi]: https://joi.dev/\r\n[Mongoose]: https://mongoosejs.com/\r\n[jsonwebtoken]: https://github.com/auth0/node-jsonwebtoken\r\n[module-alias]: https://github.com/ilearnio/module-alias\r\n[Nodemailer]: https://nodemailer.com/\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyujhenchen%2Fexpress-mongo-otp-auth-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyujhenchen%2Fexpress-mongo-otp-auth-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyujhenchen%2Fexpress-mongo-otp-auth-ts/lists"}