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

No packages published