Skip to content

A Node.js template with Express.js, MongoDB, RESTful API, Multer for file uploads, and error handling. A structured foundation for accelerated development.

Notifications You must be signed in to change notification settings

malek-labidi/template-node-js

Repository files navigation

Node.js Template

This repository serves as a template for building a Node.js application. It provides a structured foundation with essential features, frameworks, and tools.

Features

  • Express.js Backend: Utilizes Express.js for handling routes, requests, and responses.
  • MongoDB Integration: Optional MongoDB integration for seamless data persistence.
  • RESTful API: Follows RESTful principles for a scalable and maintainable architecture.
  • File Uploads with Multer: Integrates Multer middleware for handling file uploads.
  • Error Handling Middleware: Implements middleware functions for graceful error management.
  • Dockerized Deployment: Includes Dockerfile for containerizing the Node.js application.
  • Docker Compose: Provides Docker Compose configuration for orchestrating multiple containers, including the Node.js app and MongoDB.

Usage

  1. Clone the Repository:

    git clone https://github.com/malek-labidi/template-node-js.git
    cd template-node-js
  2. Install Dependencies:

    npm install
  3. Configure Environment Variables:

    • Set up environment variables as needed, e.g., MongoDB connection details.
  4. Run the Application:

    npm run dev

    This command starts the development server using Nodemon for automatic reloading.

  5. Access the Application:

Sample Endpoints:

GET All Tests: URL: http://localhost:9090/tests Method: GET

GET Test by ID: URL: http://localhost:9090/tests/:id Method: GET

Create a New Test: URL: http://localhost:9090/tests Method: POST Body: JSON payload with test details

Update a Test by ID: URL: http://localhost:9090/tests/:id Method: PUT Body: JSON payload with updated test details

Delete a Test by ID: URL: http://localhost:9090/tests/:id Method: DELETE

Additional Commands

  • Start in Production Mode:
    npm start

Wishing you the best of luck with your exam!

About

A Node.js template with Express.js, MongoDB, RESTful API, Multer for file uploads, and error handling. A structured foundation for accelerated development.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published