A robust backend API for managing logistics and transportation operations.
- Node.js (v14 or higher)
- MySQL (v8.0 or higher)
- Clone the repository:
git clone https://github.com/yourusername/logistics-platform.git
cd logistics-platform- Install dependencies:
npm install- Create a
.envfile in the root directory with the following variables:
PORT=5000
DB_HOST=localhost
DB_USER=your_mysql_username
DB_PASSWORD=your_mysql_password
DB_NAME=logistics_platform
DB_PORT=3306
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRES_IN=90d
EMAIL_HOST=smtp.example.com
EMAIL_PORT=587
EMAIL_USER=your_email@example.com
EMAIL_PASSWORD=your_email_password
RAZORPAY_KEY_ID=your_razorpay_key_id
RAZORPAY_KEY_SECRET=your_razorpay_key_secret- Set up the database:
# Create the database
mysql -u root -p
CREATE DATABASE logistics_platform;
# Run migrations
npm run migrate- Start the development server:
npm run devThe API will be available at http://localhost:5000/api
npm test- Build the project:
npm run build- Start the production server:
npm starthttp://localhost:5000/api
POST /auth/registerRequest Body:
{
"name": "John Doe",
"email": "john@example.com",
"password": "password123",
"phone": "+1234567890",
"address": {
"street": "123 Main St",
"city": "New York",
"state": "NY",
"country": "USA",
"zipCode": "10001"
}
}Response:
{
"status": "success",
"token": "jwt_token",
"data": {
"user": {
"name": "John Doe",
"email": "john@example.com",
"phone": "+1234567890",
"address": {
"street": "123 Main St",
"city": "New York",
"state": "NY",
"country": "USA",
"zipCode": "10001"
}
}
}
}POST /auth/loginRequest Body:
{
"email": "john@example.com",
"password": "password123"
}Response:
{
"status": "success",
"token": "jwt_token",
"data": {
"user": {
"name": "John Doe",
"email": "john@example.com",
"role": "user"
}
}
}