expresspro
v2.0.0
Published
[](https://www.npmjs.com/package/expresspro) [](https://opensource.org/licenses/ISC) [;
// Enable CORS
app.use(express.cors());
// Initialize JWT Authentication
const auth = new express.auth('your-secret-key', 'token');
// 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');
});Documentation
For detailed documentation, please visit our documentation directory:
Available Extensions
Authentication (express.auth)
const auth = new express.auth('secret', 'token');
app.get('/protected', auth.authMiddleware(), (req, res) => {
res.json({ user: req.user });
});Builtin JWT (express.jwt)
// Create token
const token=express.jwt.sign({id: 1, name: 'Suryansh'});
// Verify token
const decoded = express.jwt.verify(token, 'secret');Error Handling (express.error)
app.use(express.error);
throw new express.AppError('Not found', 404);Response Utilities (express.resp)
express.resp(res, 200, 'Success', { data });Async Handler (express.asyncHandler)
app.get('/async', express.asyncHandler(async (req, res) => {
const data = await someAsyncOperation();
res.json({ data });
}));TypeScript Support
ExpressPro is written in TypeScript and includes type definitions. The types are available in the @types directory.
import express from 'expresspro';
import { Request, Response } from 'express';
app.get('/users', express.asyncHandler(async (req: Request, res: Response) => {
const users = await User.findAll();
res.json({ users });
}));Contributing
We welcome contributions! Please see our Contributing Guide for details.
Changelog
See our Changelog for a list of changes.
License
This project is licensed under the ISC License - see the LICENSE file for details.
Author
Suryansh Verma
Repository
Support
Related Projects
- Express.js - The web framework for Node.js
- jsonwebtoken - JSON Web Token implementation
- bcryptjs - Password hashing
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Acknowledgments
- Express.js team for the amazing framework
- All contributors who have helped shape ExpressPro
