This is the backend service for Moventure, a travel technology platform focused on providing travel solutions and booking capabilities. The service is built using Node.js and Express and interacts with a MongoDB database for data management.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
-
Install Dependencies Navigate to the backend directory and install the project dependencies.
npm install
-
Set Up Environment Variables Customize the environment configurations as needed. Begin by copying the contents from
example.json
todevelopment.json
,production.json
, andtest.json
in theenv
folder:cat ./env/example.json | tee ./env/development.json ./env/production.json ./env/test.json > /dev/null
Set up the Nodemailer with an app password for Gmail. Refer to this guide for details on generating an app password.
To start the server, run:
npm run start
For development, using Nodemon to automatically restart the server upon file changes:
npm run dev
To deploy this on a live system, consider the following steps:
- Ensure environment variables are set according to the production environment.
- Use a process manager like PM2 for managing and keeping the Node.js server alive.
- Configure reverse proxy settings with Nginx if serving through a domain.
This project utilizes several key NPM packages:
- Express: Web framework for Node.js.
- Mongoose: MongoDB object modeling tool designed to work in an asynchronous environment.
- Joi: Powerful schema description language and data validator for JavaScript.
- Nodemailer: Module for sending emails from Node.js applications.
- Bcrypt: Library to help you hash passwords.
- jsonwebtoken: Implementation of JSON Web Tokens for secure data transmission.
- Cors: Package to enable CORS (Cross-Origin Resource Sharing) with various options.
- Config: Node.js module for managing configuration files.
For development, the following packages are used:
- Nodemon: Utility that monitors for any changes in your source and automatically restarts your server.
- Jest: Delightful JavaScript Testing Framework with a focus on simplicity.
- Supertest: Super-agent driven library for testing HTTP servers.
- ESLint: Tool for identifying and reporting on patterns found in ECMAScript/JavaScript code.
- ESLint-plugin-unicorn: Linter plugin with some useful rules for improving code quality.
For a comprehensive list of all the packages, including their specific versions used in development, please refer to the package.json
file in the project repository.
-
POST /api/auth
- Authenticates users and returns a token.
- Used for user login sessions.
-
GET, POST, PUT, DELETE /api/users
GET
: Retrieves a list of all users or a specific user by ID.POST
: Creates a new user.PUT
: Updates an existing user's information.DELETE
: Deletes a user from the system.
-
POST /api/reset-password
- Initiates a password reset process for a user.
- Users can request a password reset link.
- GET, POST, DELETE /api/bookings
GET
: Retrieves all bookings or a specific booking by ID.POST
: Creates a new booking.DELETE
: Cancels an existing booking.
- GET, POST, PUT, DELETE /api/destinations
GET
: Fetches all destinations or a specific destination by ID.POST
: Adds a new destination.PUT
: Updates details of an existing destination.DELETE
: Removes a destination from the system.
-
GET /api/flights/offers/:id
- Fetches flight offers based on id.
- Used for displaying available flight options to users.
-
POST /api/flights/offers?{query_parameters}
- Retrieves flight offers with additional filtering options provided via query parameters.
- Allows for customized searches of flight offers.