This project demonstrates how to create a RESTful API using Hapi.js with Node.js. The API supports basic CRUD operations and includes authentication using JWT (JSON Web Tokens).
- Hapi.js Framework: Robust and scalable web framework for building APIs.
- JWT Authentication: Secure user authentication using JSON Web Tokens.
- CRUD Operations: Basic Create, Read, Update, and Delete functionalities.
- Error Handling: Graceful error handling using Boom.
- Data Validation: Request payload validation using Joi.
- Node.js: Ensure you have Node.js installed. You can download it from nodejs.org.
- npm: Node package manager is installed with Node.js.
-
Clone the repository:
git clone https://github.com/khoido2003/Hapi-Nodejs.git
-
Install Dependencies:
npm install
-
Start the Project:
npm run start
Before running the application, you need to set up the configuration variables. Create a .env
file in the root directory of the project and add the following variables:
NODE_ENV=''
HAPI_PORT=''
HAPI_HOST=''
MONGODB_URI=''
JWT_SECRET=''
JWT_EXPIRES_IN=''
JWT_COOKIE_EXPIRES_IN=''