New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

dbackend

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dbackend

Modular backend utility library

latest
npmnpm
Version
1.0.10
Version published
Maintainers
1
Created
Source

🧠 THE Backend (by Devansh)

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.

🚀 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!

FAQs

Package last updated on 09 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts