anjitpariyar / travel-nodejs

for college project

Home Page:https://travel-nodejs.vercel.app/api-docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Travel Project

Travel Backend

Welcome to the Travel project! This is a learning project for building a Node.js backend with MongoDB for managing travel-related data. The project structure is designed to help you get started with creating APIs, handling database operations, and more.

Table of Contents

Project Structure

The project follows a structured directory layout:

Travel/
├── src/
│ ├── controller/
│ ├── db/
│ ├── middleware/
│ ├── model/
│ ├── routes/
│ ├── utils/
│ └── index.ts
├── .env
├── .gitignore
├── package.json
├── tsconfig.json
└── README.md
  • src/: Contains different components of the application.
  • .env: Environment variable configuration.
  • .gitignore: Specifies files and directories to be ignored by version control.
  • package.json: Lists dependencies and project details.
  • tsconfig.json: TypeScript compiler configuration.

Environment Variables

Create a .env file in the project root and add your environment variables:

mongoDB=mongodb+srv://your-mongodb-uri
mySecret=your-secret-key
API=http://localhost:4001
Env=local

Database Connection

The database connection is established in db/Dbconnect.ts. The connectDb function uses mongoose to connect to MongoDB.

Creating Routes and Controllers

Define your application's routes and controllers. For example, routes/hotelRoutes.ts and controller/Hotel.ts handle hotel-related functionality.

Setting Up Express App

In src/index.ts, the Express app is configured. The server listens on the specified port, and middleware for handling requests and responses is set up.

API Documentation with Swagger

API documentation is generated using Swagger. The swagger.json file defines API paths and definitions. Access the documentation at http://localhost:4001/api-docs.

Running the Project

  1. Install project dependencies:

    yarn
  2. Run the project

    yarn run dev

This starts the server with nodemon, providing live-reloading during development.

Feel free to expand upon this foundation by adding more routes, controllers, models, and other functionalities to create a fully featured travel application. Happy coding!

** Author:**

** Other Team Member **

** Recourse **

About

for college project

https://travel-nodejs.vercel.app/api-docs/


Languages

Language:TypeScript 100.0%