A robust authentication server template built with Node.js, TypeScript, Express.js, MongoDB and Redis.
- Node.js & TypeScript
- Express.js
- MongoDB with Mongoose
- Redis
- Express Session
- Joi for validation
- Node.js (v17+)
- MongoDB
- Redis
- TypeScript
Create a .env
file in the root directory:
PORT=58303
MONGODB_URI="mongodb://localhost:27017/your_database"
SESSION_SECRET="your_session_secret"
CLIENT_URL="http://localhost:3000"
REDIS_HOST="localhost"
REDIS_PORT="6379"
REDIS_PASSWORD=""
# Install dependencies
npm install
# Run in development
npm run dev
# Build for production
npm run build
# Start production server
npm start
# Install dependencies
yarn install
# Run in development
yarn dev
# Build for production
yarn build
# Start production server
yarn start
-
POST
/signup
- Register new user
- Body:
{ "fullname": "John Doe", "email": "john@example.com", "password": "Password123", "confirmPassword": "Password123" }
-
POST
/signin
- Login existing user
- Body:
{ "email": "john@example.com", "password": "Password123" }
-
GET
/signout
- Logout user
- Requires authentication
-
POST
/forgot-password
- Request password reset
- Body:
{ "email": "john@example.com" }
-
POST
/reset-password/:selector/:token
- Reset password with token
- Body:
{ "password": "NewPassword123", "confirmPassword": "NewPassword123" }
- GET
/
- Get current user profile
- Requires authentication
- Minimum 8 characters
- At least one uppercase letter
- At least one number
- Sessions stored in Redis
- Cookie expires in 14 days
- Single active session per user
ISC