baxjs
v1.1.7
Published
baxjs is a lightweight Node.js backend starter toolkit that bundles essential packages for building APIs and servers. It includes Express for routing, CORS for cross-origin support, JWT for authentication, Axios for HTTP requests, Morgan for logging, Cook
Maintainers
Readme
baxjs
baxjs is a lightweight Node.js backend starter toolkit that bundles essential packages for building APIs and servers. It aims to save developers time by including preconfigured utilities commonly used in backend development.
Features
- 🚀 Express – Fast and flexible web framework for Node.js
- 🔑 JWT (jsonwebtoken) – Secure authentication handling
- 🌐 CORS – Cross-Origin Resource Sharing support
- 🍪 Cookie-Parser – Parse and manage cookies easily
- 📦 Axios – Make HTTP requests with ease
- 📝 Morgan – HTTP request logger middleware
- ⚙️ Dotenv – Load environment variables from
.env - 📋 Dependency overview – View all installed dependencies with their versions
Installation
npm install baxjsAfter installation, baxjs will automatically run a postinstall script to display all bundled dependencies with their versions.
Usage
Here’s a minimal example to get started:
// Import everything you need from baxjs
const {
express,
cors,
morgan,
cookieParser,
dotenv,
axios,
jwt
} = require('baxjs');
// Initialize dotenv
dotenv.config();
const app = express();
// Middleware
app.use(cors());
app.use(express.json());
app.use(cookieParser());
app.use(morgan('dev'));
// Routes
app.get('/', (req, res) => {
res.json({ message: 'Hello from baxjs starter backend!' });
});
// Example protected route with JWT
app.get('/protected', (req, res) => {
const token = req.headers['authorization'];
if (!token) return res.status(403).json({ error: 'No token provided' });
jwt.verify(token, process.env.JWT_SECRET, (err, decoded) => {
if (err) return res.status(401).json({ error: 'Unauthorized' });
res.json({ message: 'Access granted', user: decoded });
});
});
// Server
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
console.log(`🚀 Server running on port ${PORT}`);
});
Scripts
postinstall– Runs automatically after installation to display installed dependencies.
Dependencies
Why baxjs?
Instead of setting up a Node.js backend from scratch every time, baxjs gives you a boilerplate toolkit with the most commonly used packages pre-installed and ready to go.
Author
👨💻 Bichitra Behera
License
This project is licensed under the MIT License.
