PromptBase
Upgrade
Close icon
General
Home
Marketplace
Create
Hire
Login
Chat
Sell
Explore

Prompt Details

Model
Chat - (gpt-5.5)
Token size
196
Example input
[Project Description]: A user authentication microservice with JWT login, registration, and password reset via email [Project Name]: AuthGuard API [Tech Stack]: Node.js, Express, MongoDB
Example output
## Overview # AuthGuard API AuthGuard API is a user authentication microservice built with **Node.js**, **Express**, and **MongoDB**. It provides secure user registration, JWT-based authentication, and password reset functionality via email. ### Features * User Registration * User Login with JWT Authentication * Protected Route Authorization * Password Reset via Email * MongoDB Data Persistence * Secure Password Hashing * Environment-Based Configuration * RESTful API Architecture ### Tech Stack * Node.js * Express.js * MongoDB * Mongoose * JSON Web Token (JWT) * bcrypt * Nodemailer ### Project Structure ```text AuthGuard-API/ │ ├── src/ │ ├── controllers/ │ ├── routes/ │ ├── models/ │ ├── middleware/ │ ├── services/ │ └── utils/ │ ├── .env ├── package.json └── server.js ``` --- ## Installation ### Clone Repository ```bash git clone https://github.com/your-username/authguard-api.git cd authguard-api ``` ### Install Dependencies ```bash npm install ``` ### Configure Environment Variables Create a `.env` file: ```env PORT=5000 MONGODB_URI=mongodb://localhost:27017/authguard JWT_SECRET=your_jwt_secret JWT_EXPIRES_IN=7d EMAIL_HOST=smtp.mailprovider.com EMAIL_PORT=587 EMAIL_USER=your_email@example.com EMAIL_PASSWORD=your_email_password CLIENT_URL=http://localhost:3000 ``` ### Start Development Server ```bash npm run dev ``` ### Start Production Server ```bash npm start ``` ### Verify Service ```bash curl http://localhost:5000/api/health ``` Expected Response: ```json { "status": "success", "message": "AuthGuard API is running" } ``` --- ## API Endpoints / Usage ### Base URL ```text http://localhost:5000/api/auth ``` --- ### Register User **Endpoint** ```http POST /register ``` **Request Body** ```json { "name": "John Doe", "email": "john@example.com", "password": "StrongPassword123" } ``` **Success Response** ```json { "success": true, "message": "User registered successfully", "token": "jwt_token_here" } ``` **Error Response** ```json { "success": false, "message": "Email already exists" } ``` --- ### Login User **Endpoint** ```http POST /login ``` **Request Body** ```json { "email": "john@example.com", "password": "StrongPassword123" } ``` **Success Response** ```json { "success": true, "message": "Login successful", "token": "jwt_token_here" } ``` **Error Response** ```json { "success": false, "message": "Invalid credentials" } ``` --- ### Get Current User **Endpoint** ```http GET /me ``` **Headers** ```http Authorization: Bearer <jwt_token> ``` **Success Response** ```json { "success": true, "user": { "_id": "665f8f1a2e34ab1234567890", "name": "John Doe", "email": "john@example.com" } } ``` **Unauthorized Response** ```json { "success": false, "message": "Unauthorized" } ``` --- ### Request Password Reset **Endpoint** ```http POST /forgot-password ``` **Request Body** ```json { "email": "john@example.com" } ``` **Success Response** ```json { "success": true, "message": "Password reset email sent" } ``` --- ### Reset Password **Endpoint** ```http POST /reset-password/:token ``` **Request Body** ```json { "password": "NewStrongPassword123" } ``` **Success Response** ```json { "success": true, "message": "Password reset successful" } ``` **Error Response** ```json { "success": false, "message": "Invalid or expired reset token" } ``` --- ### Example Protected Route Middleware ```javascript const jwt = require("jsonwebtoken"); const authMiddleware = (req, res, next) => { const authHeader = req.headers.authorization; if (!authHeader) { return res.status(401).json({ success: false, message: "Unauthorized" }); } const token = authHeader.split(" ")[1]; const decoded = jwt.verify( token, process.env.JWT_SECRET ); req.user = decoded; next(); }; module.exports = authMiddleware; ``` --- ## Contributing & License ### Contributing 1. Fork the repository. 2. Create a feature branch. ```bash git checkout -b feature/new-feature ``` 3. Commit changes. ```bash git commit -m "Add new feature" ``` 4. Push branch. ```bash git push origin feature/new-feature ``` 5. Open a Pull Request. ### Development Standards ```text - Follow REST API conventions - Write reusable middleware - Validate request payloads - Use environment variables for secrets - Maintain consistent error handling ``` ### License ```text MIT License Copyright (c) AuthGuard API Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files, to deal in the Software without restriction. ```
🤖 GPT

Github Readme Api Doc Architect

Add to Cart
Instant accessInstant access
Usage rightsCommercial use
Money-back guaranteeMoney‑back
By purchasing this prompt, you agree to our terms of service
GPT-5.5
Tested icon
Guide icon
4 examples icon
Free credits icon
Instantly generate perfectly structured GitHub README files and API documentation from messy code or basic descriptions. Outputs pure Markdown with installation steps, code blocks, and endpoints. Essential for developers and open-source creators.
...more
Added 2 days ago
Report
Browse Marketplace