A lightweight, Express-like web framework for Node.js built from scratch for learning purposes
Bomba is a minimalist web framework created specifically to help developers understand how web frameworks work under the hood. Inspired by Express.js, it provides the essential building blocks for creating web applications and APIs while being simple enough to read, understand, and extend.
This framework was built as a learning project to demonstrate:
- How HTTP servers work in Node.js
- Middleware pattern implementation
- URL routing and pattern matching
- Request/Response enhancement
- Asynchronous request handling
- Error handling in web applications
Perfect for: Students, bootcamp participants, and developers who want to understand how Express.js and similar frameworks work internally.
- π Educational: Built specifically for learning and understanding web frameworks
- π§ Simple: Clean, readable code that's easy to follow and extend
- πͺΆ Lightweight: Minimal dependencies, focusing on core concepts
- π― Familiar: Express-like API for easy learning transition
- π§ Insightful: Heavily commented code explaining the "why" behind each decision
- β HTTP method routing (GET, POST, PUT, DELETE, PATCH)
- β Middleware support
- β
Route parameters (
:id,:name) - β Query string parsing
- β Enhanced request/response objects
- β Error handling
- β Chainable API
npm installconst createApp = require('./src/index');
const app = createApp();
// Middleware
app.use((req, res, next) => {
console.log(`${req.method} ${req.url}`);
next();
});
// Routes
app.get('/', (req, res) => {
res.send('Hello World!');
});
app.get('/users/:id', (req, res) => {
res.json({ userId: req.params.id });
});
// Start server
app.listen(3000, () => {
console.log('Server running on port 3000');
});Register middleware that runs for all requests.
Register a GET route.
Register a POST route.
Register a PUT route.
Register a DELETE route.
Start the server on specified port.
req.params- Route parametersreq.query- Query string parametersreq.get(headerName)- Get header valuereq.accepts(type)- Check accepted content type
res.status(code)- Set status coderes.json(data)- Send JSON responseres.send(data)- Send responseres.set(field, value)- Set headerres.redirect([status], url)- Redirect to URL
npm run exampleThen visit http://localhost:3000
framework/
βββ src/
β βββ index.js # Main entry point
β βββ application.js # Application class
β βββ router.js # Router implementation
β βββ enhancers.js # Request/Response enhancements
βββ examples/
β βββ basic-server.js # Example server
βββ package.json
βββ README.md
Potential features to add:
- Cookie parsing
- Template engine support
- Better error handling
- Router mounting
- CORS support
- Compression
- Security headers
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- [β ] Body parsing (JSON, URL-encoded, multipart)
- Cookie parsing and session management
- [β ] Static file serving
- Template engine support
- Router mounting and sub-applications
- CORS middleware
- Security headers
- Compression middleware
- Rate limiting
- WebSocket support
Found a bug or have a feature request? Please open an issue on GitHub Issues.
If you like this project, please consider giving it a star on GitHub!
This project is licensed under the MIT License - see the LICENSE file for details.
Shuhrat Kobulov
- GitHub: @shuhrat-kobulov
β If this helped you understand web frameworks better, please star the repo!