Skip to content

Modular, production-ready Node.js backend framework featuring JWT authentication, RESTful APIs, MongoDB integration, and built-in logging — designed to accelerate MVP development for startups and indie developers.

Notifications You must be signed in to change notification settings

CodeReb00t/dbackend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 dbackend ( THE Backend )

THE Backend (dbackend) is a modular, ready-to-use backend toolkit that simplifies user authentication, email handling, middleware management, and MongoDB integration. Designed for rapid backend development with clean structure and extensibility in mind.

Documentation site : https://dbackend-docs.vercel.app/


🚀 Installation

npm install dbackend

📦 Features

  • ✅ MongoDB connection with Mongoose
  • ✅ Authentication system (Signup, Signin, JWT, Email Verification, Password Reset)
  • ✅ Built-in JWT middleware
  • ✅ Mailer integration using Nodemailer
  • ✅ Plug-and-play Express middlewares (CORS, JSON, URL Encoded)

🛠️ Usage

1. Setup

const express = require("express");
const backend = require("dbackend"); // THE Backend
const User = require("./models/User"); // Define your Mongoose User model

2. Connect to MongoDB

backend.mongodb({
  url: "mongodb://localhost:27017/mydb",
});

3. Setup Mailer (Optional)

const mailer = backend.mailer({
  service: "Gmail",
  auth: {
    user: "your@gmail.com",
    pass: "yourpassword",
  },
});

await mailer.sendMail({
  to: "recipient@example.com",
  subject: "Welcome!",
  text: "Thank you for signing up!",
  html: "<h1>Thank you for signing up!</h1>",
});

4. Setup Authentication

const auth = backend.auth({
  jwtSecret: "your_jwt_secret",
  UserModel: User,
  mailer: mailer, // Optional
});

5. Use Middleware

const app = express();

backend.middlewares(app, ["json", "urlencoded", "cors"]);

🔐 Auth API Example

// Sign Up
await auth.signup({
  email: "user@example.com",
  password: "123456",
  name: "Dev User",
});

// Sign In
const result = await auth.signin({
  email: "user@example.com",
  password: "123456",
});

console.log(result.token); // JWT Token

// Middleware Example (Protect Routes)
app.get("/dashboard", auth.middleware(), (req, res) => {
  res.send(`Welcome ${req.user.email}`);
});

📧 Forgot & Reset Password

await auth.forgotPassword("user@example.com");

// Then on /reset-password route
await auth.resetPassword(tokenFromEmail, "newPassword123");

📁 Folder Structure (Example)

your-app/
│
├── models/
│   └── User.js
├── server.js
└── ...

🙌 Credits

Developed with ❤️ by Devansh(CodeReb00t)

Feel free to contribute, report issues, or suggest features!

About

Modular, production-ready Node.js backend framework featuring JWT authentication, RESTful APIs, MongoDB integration, and built-in logging — designed to accelerate MVP development for startups and indie developers.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published