{"id":22332541,"url":"https://github.com/theoddysey/mern-backend-nodejs","last_synced_at":"2026-05-10T02:17:45.105Z","repository":{"id":215094657,"uuid":"717438931","full_name":"TheODDYSEY/Mern-Backend-Nodejs","owner":"TheODDYSEY","description":"A Node.js application designed to provide user authentication services 🤵","archived":false,"fork":false,"pushed_at":"2024-02-23T11:24:29.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T07:23:20.945Z","etag":null,"topics":["authentication","authentication-backend","mern-stack","mongodb","node-js"],"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/TheODDYSEY.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}},"created_at":"2023-11-11T13:47:23.000Z","updated_at":"2024-04-27T10:09:07.000Z","dependencies_parsed_at":"2024-01-02T14:03:05.909Z","dependency_job_id":"d6b1ff1f-38c1-44de-89d3-a5862e2fc3da","html_url":"https://github.com/TheODDYSEY/Mern-Backend-Nodejs","commit_stats":null,"previous_names":["theoddysey/mern-backend-nodejs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TheODDYSEY/Mern-Backend-Nodejs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheODDYSEY%2FMern-Backend-Nodejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheODDYSEY%2FMern-Backend-Nodejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheODDYSEY%2FMern-Backend-Nodejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheODDYSEY%2FMern-Backend-Nodejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheODDYSEY","download_url":"https://codeload.github.com/TheODDYSEY/Mern-Backend-Nodejs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheODDYSEY%2FMern-Backend-Nodejs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264247849,"owners_count":23579054,"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":["authentication","authentication-backend","mern-stack","mongodb","node-js"],"created_at":"2024-12-04T04:18:38.137Z","updated_at":"2026-05-10T02:17:45.048Z","avatar_url":"https://github.com/TheODDYSEY.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# MERN Authentication Backend\n\nThis is the backend part of a MERN (MongoDB, Express, React, Node.js) stack application that provides user authentication functionality using JWT (JSON Web Tokens). It includes user registration, login, and JWT token generation.\n\n## Prerequisites\n\nBefore you begin, ensure you have the following installed:\n\n- Node.js and npm: [Node.js Downloads](https://nodejs.org/)\n- MongoDB: [MongoDB Downloads](https://www.mongodb.com/try/download/community)\n\n## Installation\n\n1. **Clone the repository:**\n\n   ```bash\n   git clone https://github.com/your-username/mern-auth-backend.git\n   ```\n\n2. **Install dependencies:**\n\n   ```bash\n   cd mern-auth-backend\n   npm install\n   ```\n\n3. **Set up MongoDB:**\n\n   - Make sure MongoDB is running on your machine or update the `mongoURI` in `config/keys.js` with your MongoDB connection string.\n\n4. **Create a `.env` file:**\n\n   - Create a `.env` file in the root directory and add the following:\n\n     ```env\n     MONGO_DB_URL=your_mongodb_connection_string\n     SECRET_KEY=your_secret_key_for_jwt\n     ```\n\n5. **Start the server:**\n\n   ```bash\n   npm start\n   ```\n\n   This will run the server on `http://localhost:5000`.\n\n## Project Structure\n\n- **config/keys.js:** Contains MongoDB connection string and JWT secret key.\n\n- **config/passport.js:** Configures Passport with JWT strategy for authentication.\n\n- **models/User.js:** Defines the MongoDB user schema.\n\n- **routes/api/users.js:** Defines API routes for user registration and login.\n\n- **validation/login.js:** Validates login input.\n\n- **validation/register.js:** Validates registration input.\n\n- **server.js:** Express server setup, connects to MongoDB, initializes Passport, and defines routes.\n\n## API Endpoints\n\n- **POST /api/users/register:** Register a new user.\n\n  Example Request:\n\n  ```json\n  {\n    \"name\": \"John Doe\",\n    \"email\": \"john@example.com\",\n    \"password\": \"secretpassword\",\n    \"password2\": \"secretpassword\"\n  }\n  ```\n\n- **POST /api/users/login:** Login with existing credentials.\n\n  Example Request:\n\n  ```json\n  {\n    \"email\": \"john@example.com\",\n    \"password\": \"secretpassword\"\n  }\n  ```\n\n## Usage with Frontend\n\nYou can integrate this backend with a frontend application built with React. Update the frontend API calls to match the endpoints provided by this backend.\n\n## Dependencies\n\n- **bcryptjs:** For hashing passwords.\n- **body-parser:** Middleware for parsing JSON and urlencoded request bodies.\n- **dotenv:** Loads environment variables from a .env file.\n- **express:** Web application framework for Node.js.\n- **jsonwebtoken:** For generating and verifying JWTs.\n- **mongoose:** MongoDB object modeling tool.\n- **passport:** Authentication middleware for Node.js.\n- **passport-jwt:** Passport strategy for authenticating with a JSON Web Token.\n- **validator:** Library for string validation.\n\n## License\nThis project is licensed under the MIT License - see the LICENSE file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheoddysey%2Fmern-backend-nodejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheoddysey%2Fmern-backend-nodejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheoddysey%2Fmern-backend-nodejs/lists"}