Git Product home page Git Product logo

sajaltimilsina / natour---node-api Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 29.62 MB

Node Server for Tour company- includes User authentication, JWT token, login, signup, forget password, Access management, CURD on Tour and Reviews & many more features.

Home Page: https://documenter.getpostman.com/view/30945305/2s9YkuYyCW

JavaScript 39.14% Pug 14.11% CSS 20.71% HTML 26.04%
aliasing data-modeling data-sanitization event-loop jwt-authentication mongoose nodejs nodemailer pagination sorting thread express

natour---node-api's Introduction

MERN Stack Application - API Server

This repository contains the backend code for a MERN (MongoDB, Express, React, Node.js) stack application, specifically the API server. This is designed for a Tour company, where use ca loginIn, Signup, forget the password, and CURD operations regarding Tours and reviews.

image

Environment Variables

To set up the server, ensure the following environment variables are configured:


NODE_ENV: Set to development or production.
PORT: Port number for the server.
USER: Your username for the database.
DATABASE: MongoDB connection string.
DATABASE_PASSWORD: Password for the database.
JWT_SECRET: Secret key for JWT token generation.
JWT_EXPIRES_IN: Expiry time for JWT tokens.
JWT_COOKIE_EXPIRES_IN: Expiry time for JWT cookies.
EMAIL_USERNAME: Username for sending emails.
EMAIL_PASSWORD: Password for the email account.
EMAIL_HOSTNAME: SMTP hostname for sending emails.
EMAIL_PORT: Port number for the email service.

Project Structure

The project structure is divided into various components:

  • routes: Contains route handlers for different entities.
  • controllers: Includes controller functions to handle business logic.
  • models: Defines the database models using Mongoose.
  • utils: Houses utility functions and helper modules.
  • middleware: Stores middleware functions used in the application.

Scripts

The available scripts for the server include:

npm start         # Starts the server in development mode
npm run start:prod # Sets the server in production mode
npm run debug     # Runs the server in debug mode using NDB

Dependencies

The server uses various dependencies:

express:           Web framework for Node.js to handle routes and requests.
mongoose:          ODM library for MongoDB, facilitating interaction with the database.
jsonwebtoken:      Helps in generating and verifying JSON Web Tokens (JWT) for user authentication.
bcryptjs:          A library for hashing passwords.
nodemailer:        Used for sending emails in the application.
dotenv:            Loads environment variables from a .env file into process.env.

Middleware

The server employs several middleware functions:

  • express-rate-limit: Limits repeated requests from the same IP.
  • helmet: Sets various HTTP headers to enhance security.
  • express-mongo-sanitize: Sanitizes data to prevent NoSQL injection attacks.
  • xss-clean: Prevents Cross-Site Scripting (XSS) attacks.
  • hpp: Helps in preventing HTTP Parameter Pollution attacks.

Usage

  1. Clone this repository: git clone <repository-url>
  2. Install dependencies: npm install
  3. Set up environment variables as specified in .env file.
  4. Start the server:
    • Development Mode: npm start
    • Production Mode: npm run start:prod
    • Debug Mode: npm run debug

Contribution

Contributions, bug reports, and feature suggestions are welcome. To contribute:

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature-name
  3. Make changes and commit them: git commit -m 'Add feature'
  4. Push to the branch: git push origin feature-name
  5. Open a pull request.

License

This project is licensed under the ISC License. Feel free to use, modify, or distribute the code as per the terms of this license.


Please replace placeholders like `<PASSWORD>` and `your_username_here` with actual values in your `.env` file and project-specific information.

natour---node-api's People

Contributors

sajaltimilsina avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.