Prerequisites
Before you begin, ensure you have the following installed:- Node.js (v14 or higher)
- npm or yarn
- MySQL (v8.0 or higher)
- ngrok (optional, for webhook testing)
Installation
Install dependencies
Install all required npm packages:This will install the following key dependencies:
express- Web frameworkmysql2- MySQL database driverjsonwebtoken- JWT authenticationbcrypt- Password hashingmulter- File upload handlingexpress-rate-limit- Rate limitingdotenv- Environment variable managementcors- Cross-origin resource sharingswagger-ui-express- API documentation
Set up the database
Create a new MySQL database for the application:
You’ll need to create the required tables for users, products, categories, orders, cart, reviews, and addresses. Refer to your database schema documentation for the complete table structure.
Configure environment variables
Create a See the Configuration guide for detailed information about all available environment variables.
.env file in the root directory with your configuration:Development scripts
The following npm scripts are available for development:Script descriptions
npm run dev- Starts the server with nodemon for automatic reloading during developmentnpm start- Starts the server in production modenpm run tunnel- Creates an ngrok tunnel to expose your local server to the internet
Setting up ngrok tunnel
For testing webhooks or allowing external access to your local server, you can use the ngrok tunnel:Verify installation
Once the server is running, you can verify the installation:Project structure
After setup, your project structure should look like this:Next steps
Configuration
Learn about environment variables and configuration options
Authentication
Understand how to authenticate API requests