Getting Started
Installation
npm install expresspro
or
yarn add expresspro
or
pnpm add expresspro
Basic Usage
import express from 'expresspro';
const app = express();
// Enable CORS
app.use(express.cors());
// Initialize JWT Authentication
const auth = new express.auth('your-secret-key', 'token');
// Basic route
app.get('/', (req, res) => {
res.json({ message: 'Welcome to ExpressPro!' });
});
// Protected route
app.get('/protected', auth.authMiddleware(), (req, res) => {
res.json({ message: 'Protected route accessed' });
});
app.listen(3000, () => {
console.log('Server running on port 3000');
});
Available Extensions
ExpressPro extends the Express.js framework with the following features:
-
Authentication (
express.auth
)- JWT-based authentication
- Token management
- Protected route middleware
-
Error Handling (
express.error
)- Global error handler
- Custom error class (
AppError
)
-
Response Utilities (
express.resp
)- Standardized response format
- Success/error response helpers
-
Async Handler (
express.asyncHandler
)- Clean async/await error handling
- No try-catch blocks needed
-
CORS Support (
express.cors
)- Built-in CORS middleware
- Easy configuration
-
Password Hashing (
express.bcrypt
)- Built-in bcrypt integration
- Secure password management
TypeScript Support
ExpressPro is written in TypeScript and includes type definitions. The types are available in the @types
directory.
Next Steps
- Read the Authentication guide to learn about JWT implementation
- Check out Error Handling for managing errors
- Explore Response Utilities for standardized responses
- Learn about Async Handler for clean async code