{"id":32864036,"url":"https://github.com/adhilunnikrishnan/node-mongoose-jwt-apis","last_synced_at":"2026-05-01T23:36:54.599Z","repository":{"id":320550758,"uuid":"1082484897","full_name":"adhilunnikrishnan/Node-Mongoose-JWT-APIs","owner":"adhilunnikrishnan","description":"A secure REST APIs built using Node.js, Express, and MongoDB with JWT authentication, role-based access, and CRUD operations for Users, Products, and Students.","archived":false,"fork":false,"pushed_at":"2025-11-04T06:51:29.000Z","size":65,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-04T08:29:39.698Z","etag":null,"topics":["error-handling","expressjs","javascript","joi-validation","jwt","mongoose","rest-api","swagger","validation"],"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/adhilunnikrishnan.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-24T10:03:21.000Z","updated_at":"2025-11-04T06:51:33.000Z","dependencies_parsed_at":"2025-10-24T13:12:04.523Z","dependency_job_id":"2317f574-7feb-4859-aa97-e39c5f0e5106","html_url":"https://github.com/adhilunnikrishnan/Node-Mongoose-JWT-APIs","commit_stats":null,"previous_names":["adhilunnikrishnan/node-mongoose-jwt-apis"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adhilunnikrishnan/Node-Mongoose-JWT-APIs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhilunnikrishnan%2FNode-Mongoose-JWT-APIs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhilunnikrishnan%2FNode-Mongoose-JWT-APIs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhilunnikrishnan%2FNode-Mongoose-JWT-APIs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhilunnikrishnan%2FNode-Mongoose-JWT-APIs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adhilunnikrishnan","download_url":"https://codeload.github.com/adhilunnikrishnan/Node-Mongoose-JWT-APIs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhilunnikrishnan%2FNode-Mongoose-JWT-APIs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":283447137,"owners_count":26837401,"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","status":"online","status_checked_at":"2025-11-09T02:00:05.828Z","response_time":62,"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":["error-handling","expressjs","javascript","joi-validation","jwt","mongoose","rest-api","swagger","validation"],"created_at":"2025-11-09T02:01:12.135Z","updated_at":"2025-11-09T02:02:13.512Z","avatar_url":"https://github.com/adhilunnikrishnan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⚙ Node-Mongoose-JWT-APIs\n\nA secure REST APIs built using Node.js, Express, and MongoDB with JWT authentication, role-based access, and CRUD operations for Users, Products, and Students.\n\n\u003cdiv\u003e\n  \u003cimg src=\"https://img.shields.io/badge/-Node.js-339933?style=for-the-badge\u0026logo=node.js\u0026logoColor=white\" alt=\"Node.js\" /\u003e\n  \u003cimg src=\"https://img.shields.io/badge/-Express.js-000000?style=for-the-badge\u0026logo=express\u0026logoColor=white\" alt=\"Express.js\" /\u003e\n  \u003cimg src=\"https://img.shields.io/badge/-MongoDB-47A248?style=for-the-badge\u0026logo=mongodb\u0026logoColor=white\" alt=\"MongoDB + Mongoose\" /\u003e\n  \u003cimg src=\"https://img.shields.io/badge/-JWT-000000?style=for-the-badge\u0026logo=jsonwebtokens\u0026logoColor=white\" alt=\"JWT (Authentication)\" /\u003e\n  \u003cimg src=\"https://img.shields.io/badge/-bcryptjs-003366?style=for-the-badge\u0026logo=security\u0026logoColor=white\" alt=\"bcryptjs\" /\u003e\n  \u003cimg src=\"https://img.shields.io/badge/-dotenv-009639?style=for-the-badge\u0026logo=dotenv\u0026logoColor=white\" alt=\"dotenv\" /\u003e\n  \u003cimg src=\"https://img.shields.io/badge/-Joi-FFB703?style=for-the-badge\u0026logo=javascript\u0026logoColor=black\" alt=\"Joi Validation\" /\u003e\n  \u003ca href=\"https://node-mongoose-jwt-apis.onrender.com/api-docs\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/-Swagger-85EA2D?style=for-the-badge\u0026logo=swagger\u0026logoColor=black\" alt=\"Swagger API Docs\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\n\n\n---\n\n## 🧭 Table of Contents\n\n1. 📖 [Introduction](#-introduction)\n2. ⚙ [Tech Stack](#-tech-stack)\n3. 🔋 [Features](#-features)\n4. 📦 [Quick Start (Setup Guide)](#-quick-start-setup-guide)\n5. 📬 [Postman Collection](#-postman-collection)\n\n## 📖 Introduction\n\nThis project demonstrates how to build a **secure REST API** using:\n- **Express.js** for routing  \n- **Mongoose** for MongoDB object modeling  \n- **JWT** for authentication  \n- **Middleware** for access control and validation  \n\nIt provides a ready-to-use backend for projects that need **user management**, **authentication**, **student and product CRUD**, and **role-based authorization**.\n\n---\n\n## ⚙ Tech Stack\n\n| Technology | Description |\n|-------------|-------------|\n| **Node.js** | JavaScript runtime for building the server |\n| **Express.js** | Web framework for building APIs |\n| **MongoDB + Mongoose** | NoSQL database and ODM |\n| **JWT (JSON Web Token)** | Authentication and authorization |\n| **bcryptjs** | Password hashing |\n| **dotenv** | Environment variable management |\n| **Joi** | Schema validation |\n\n---\n\n## 🔋 Features\n\n✅ **User Authentication \u0026 Authorization** (JWT)  \n✅ **Role-based Access Control** (Admin/User)  \n✅ **CRUD Operations** for Users, Students, and Products  \n✅ **Validation** using Joi  \n✅ **Secure Password Hashing** with bcrypt  \n✅ **Error Handling Middleware**  \n✅ **Query Filters** (e.g., `/api/users?role=admin\u0026age=25`)  \n✅ **Environment Config Support (.env)**  \n\n---\n## 📦 Quick Start (Setup Guide)\n\n### 1️⃣ Clone the repository\n```bash\ngit clone https://github.com/adhilunnikrishnan/Node-Mongoose-JWT-APIs.git\ncd Node-Mongoose-JWT-APIs\n```\n\n### 2️⃣ Install dependencies\n```bash\nnpm install\n```\n\n### 3️⃣ Create `.env` file in the root directory\n```env\n# Server Port\nPORT=9002\n\n# Database name\nDATABASE = Mini-Rest-API-DB\n\n# MongoDB Connection URI\nMONGO_URI=mongodb+srv://\u003cUSERNAME\u003e:\u003cPASSWORD\u003e@\u003cCLUSTER\u003e.mongodb.net/\n\n# JWT Secret Key for Authentication\nJWT_SECRET=your_jwt_secret_key_here\n\n# Node Environment: development or production\nNODE_ENV=development\n\n```\n\n### 4️⃣ Start the server\n```bash\nnpm run dev   # Development mode\nnpm start     # Production mode\n```\n\nServer will run on:  \n👉 **http://localhost:9002**\n\n---\n\n## 📬 Postman Collection\n\nThe Postman collection JSON file is available in the repo under the `postman` folder\n\n--- \n## Swagger API documentation\n```\nswagger: '2.0'\ninfo:\n  title: REST API\n  description: Auto-generated Swagger doc\n  version: 1.0.0\nhost: localhost:9002\nbasePath: /\nschemes:\n  - http\npaths:\n  /api/register:\n    post:\n      description: ''\n      parameters:\n        - name: body\n          in: body\n          schema:\n            type: object\n            properties:\n              username:\n                example: any\n              email:\n                example: any\n              password:\n                example: any\n              role:\n                example: any\n              age:\n                example: any\n      responses:\n        '201':\n          description: Created\n        '400':\n          description: Bad Request\n  /api/login:\n    post:\n      description: ''\n      parameters:\n        - name: body\n          in: body\n          schema:\n            type: object\n            properties:\n              email:\n                example: any\n              password:\n                example: any\n      responses:\n        '200':\n          description: OK\n        '400':\n          description: Bad Request\n        '401':\n          description: Unauthorized\n  /api/users/:\n    get:\n      description: ''\n      parameters:\n        - name: age\n          in: query\n          type: string\n        - name: role\n          in: query\n          type: string\n      responses:\n        '200':\n          description: OK\n  /api/users/{id}:\n    get:\n      description: ''\n      parameters:\n        - name: id\n          in: path\n          required: true\n          type: string\n      responses:\n        '200':\n          description: OK\n        '400':\n          description: Bad Request\n        '404':\n          description: Not Found\n  /api/products/:\n    post:\n      description: ''\n      parameters:\n        - name: body\n          in: body\n          schema:\n            type: object\n            properties:\n              title:\n                example: any\n              author:\n                example: any\n              price:\n                example: any\n              category:\n                example: any\n              publisher:\n                example: any\n              isbn:\n                example: any\n              stock:\n                example: any\n      responses:\n        '201':\n          description: Created\n        '400':\n          description: Bad Request\n        '403':\n          description: Forbidden\n    get:\n      description: ''\n      parameters:\n        - name: category\n          in: query\n          type: string\n        - name: minPrice\n          in: query\n          type: string\n        - name: maxPrice\n          in: query\n          type: string\n      responses:\n        '200':\n          description: OK\n  /api/products/{id}:\n    patch:\n      description: ''\n      parameters:\n        - name: id\n          in: path\n          required: true\n          type: string\n        - name: body\n          in: body\n          schema:\n            type: object\n            properties:\n              title:\n                example: any\n              author:\n                example: any\n              price:\n                example: any\n              category:\n                example: any\n              publisher:\n                example: any\n              isbn:\n                example: any\n              stock:\n                example: any\n      responses:\n        '200':\n          description: OK\n        '400':\n          description: Bad Request\n        '403':\n          description: Forbidden\n        '404':\n          description: Not Found\n    delete:\n      description: ''\n      parameters:\n        - name: id\n          in: path\n          required: true\n          type: string\n      responses:\n        '200':\n          description: OK\n        '403':\n          description: Forbidden\n        '404':\n          description: Not Found\n  /api/students/:\n    post:\n      description: ''\n      parameters:\n        - name: body\n          in: body\n          schema:\n            type: object\n            properties:\n              name:\n                example: any\n              marks:\n                example: any\n              class:\n                example: any\n      responses:\n        '201':\n          description: Created\n        '400':\n          description: Bad Request\n    get:\n      description: ''\n      parameters:\n        - name: class\n          in: query\n          type: string\n      responses:\n        '200':\n          description: OK\n  /api/students/{id}/marks:\n    get:\n      description: ''\n      parameters:\n        - name: id\n          in: path\n          required: true\n          type: string\n      responses:\n        '200':\n          description: OK\n        '400':\n          description: Bad Request\n        '404':\n          description: Not Found\n  /api/students/{id}:\n    patch:\n      description: ''\n      parameters:\n        - name: id\n          in: path\n          required: true\n          type: string\n      responses:\n        '200':\n          description: OK\n        '400':\n          description: Bad Request\n        '404':\n          description: Not Found\n    delete:\n      description: ''\n      parameters:\n        - name: id\n          in: path\n          required: true\n          type: string\n      responses:\n        '200':\n          description: OK\n        '404':\n          description: Not Found\n\n\n```\n---\nIf you like this project, **please ⭐ star the repo!**","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadhilunnikrishnan%2Fnode-mongoose-jwt-apis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadhilunnikrishnan%2Fnode-mongoose-jwt-apis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadhilunnikrishnan%2Fnode-mongoose-jwt-apis/lists"}