This project is a User Authentication Service built using Node.js and Sequelize ORM. It is designed to handle user data securely with features like email validation, password encryption, and JWT (JSON Web Tokens) for secure authentication.
- User registration with email and password.
- Email validation to ensure proper email format.
- Password encryption using bcrypt for secure storage.
- JWT for secure and efficient user authentication. Authorization check for adding roles to enhance security.
- Default customer role during signup to streamline the user onboarding process.
- Models for a many-to-many association between roles and users to facilitate complex user management scenarios.
- Rate limiter and proxy to improve API performance and security by managing the rate of incoming requests.
- Node.js
- Sequelize ORM
- bcrypt for password encryption
- JSON Web Tokens (JWT)
- Rate limiting tools
- Proxy servers for improved security and load handling
- Added JWT support for enhanced security in user authentication. This allows the server to issue tokens to users upon successful authentication, which are required for subsequent requests to protected routes.
- Improved email validation to ensure accurate email format validation.
- Improved password encryption to provide secure storage for user passwords.
- Improved JWT implementation to provide secure and efficient user authentication.
- Clone the repository:
git clone https://github.com/git-ashutosh571/API-Gateway-Flights.git - Install dependencies:
npm install - Configure environment variables (see below)
- Start the server:
npm startornpm run dev
This service requires environment variables to be configured. Copy .env.example to .env and update the values:
cp .env.example .envServer Configuration:
PORT- Server port (default: 8000)NODE_ENV- Environment (development/production)CORS_ORIGIN- Allowed CORS origins (default: *)
Database Configuration:
DB_HOST- Database host addressDB_PORT- Database port (default: 3306)DB_USER- Database usernameDB_PASSWORD- Database passwordDB_NAME- Database name (api_gateway)DB_DIALECT- Database dialect (mysql)
JWT Configuration:
JWT_SECRET- Secret key for JWT signing (MUST be changed in production)JWT_EXPIRY- Token expiration time (e.g., '1d', '7d')SALT_ROUNDS- Bcrypt salt rounds (default: 10)
Microservices URLs:
FLIGHT_SERVICE- Flights Service URL (e.g., http://localhost:3000)BOOKING_SERVICE- Booking Service URL (e.g., http://localhost:3001)
Rate Limiting:
RATE_LIMIT_WINDOW_MS- Time window in milliseconds (default: 900000 = 15 min)RATE_LIMIT_MAX_REQUESTS- Max requests per window (default: 100)
The service provides a health check endpoint at /health for monitoring and orchestration purposes.
- To use the API Gateway Service, you can make requests to the API endpoints provided in the documentation.