Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A lightweight Express-like web framework for Node.js built from scratch for learning purposes - Perfect for understanding how web frameworks work

License

shuhrat-kobulov/bomba

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Bomba Framework ⚑

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.

πŸŽ“ Educational Purpose

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.

πŸš€ Why Bomba?

  • πŸ“š 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

Features

  • βœ… 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

Installation

npm install

Quick Start

const 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');
});

API Reference

Application Methods

app.use([path], handler)

Register middleware that runs for all requests.

app.get(path, ...handlers)

Register a GET route.

app.post(path, ...handlers)

Register a POST route.

app.put(path, ...handlers)

Register a PUT route.

app.delete(path, ...handlers)

Register a DELETE route.

app.listen(port, callback)

Start the server on specified port.

Request Object

  • req.params - Route parameters
  • req.query - Query string parameters
  • req.get(headerName) - Get header value
  • req.accepts(type) - Check accepted content type

Response Object

  • res.status(code) - Set status code
  • res.json(data) - Send JSON response
  • res.send(data) - Send response
  • res.set(field, value) - Set header
  • res.redirect([status], url) - Redirect to URL

Running the Example

npm run example

Then visit http://localhost:3000

Project Structure

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

Next Steps

Potential features to add:

  • Cookie parsing
  • Template engine support
  • Better error handling
  • Router mounting
  • CORS support
  • Compression
  • Security headers

🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

πŸ“‹ Roadmap

  • [βœ…] 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

πŸ› Issues

Found a bug or have a feature request? Please open an issue on GitHub Issues.

⭐ Show Your Support

If you like this project, please consider giving it a star on GitHub!

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘¨β€πŸ’» Author

Shuhrat Kobulov


Built with ❀️ for learning and the Node.js community
⭐ If this helped you understand web frameworks better, please star the repo!

About

A lightweight Express-like web framework for Node.js built from scratch for learning purposes - Perfect for understanding how web frameworks work

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published