Skip to content

harshit-dugar/backend-model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backend-Wrapper

A modular Node.js + Express + MongoDB backend template with authentication and utilities.

This boilerplate is designed to help contributors and developers quickly set up, extend, and maintain backend APIs.

📂 Project Structure

src/
├── controllers/        # Route controllers (business logic)
├── db/                 # Database connection setup
├── middlewares/        # Express middlewares (auth, validation, etc.)
├── models/             # Mongoose models (e.g., User.models.js)
├── routes/             # API routes (e.g., healthCheck, user)
├── util/               # Helpers (ApiError, ApiResponse, asyncHandler, constants)
├── app.js              # Express app initialization
├── index.js            # Entry point

⚡ Features

✅ Express server setup

✅ MongoDB with Mongoose models

✅ Error handling with ApiError and asyncHandler

✅ Standardized API responses with ApiResponse

✅ JWT-based authentication (Access + Refresh tokens)

✅ Clean modular folder structure

🛠️ Getting Started

  1. Clone the repo (Fork first)
git clone https://github.com/your-username/backend-model.git
cd backend-model
  1. Install dependencies
npm install
  1. Configure environment variables

Copy the .env.example file to .env.local:

cp .env.local .env

Open .env and fill in your secrets:

⚠️ Do not commit .env or real secrets. Only .env.local should be in Git.

  1. Run the server
npm run dev

The server will start on http://localhost:4000 (or the port you set).

🔑 Authentication Flow

  • Register: POST /api/v1/users/register

  • Login: POST /api/v1/users/login

  • Access token: Short-lived (1h), used for protected routes

  • Refresh token: Long-lived (10d), stored in DB + HTTP-only cookie

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors