Help needed: I am looking for contributors to help me with this project. If you are interested, please let me know.
Hasty Server is a lightweight, zero-dependency HTTP framework built with raw TCP sockets in Node.js. Inspired by Express.js, it provides a clean API for building web servers and APIs while teaching HTTP internals.
Hasty Server is a production-ready HTTP framework designed for building web APIs and applications. It provides enterprise-grade security features while maintaining zero dependencies.
What Hasty Server provides:
- β HTTP/1.1 compliant server with proper request/response handling
- β Security features: Configurable security headers, rate limiting, request size limits, CORS security
- β Request tracing: Unique request IDs for debugging and monitoring
- β Structured logging: Production-ready logging system
- β Error handling: Consistent JSON error responses
- β Static file serving with security protections
- β Zero dependencies: Pure Node.js implementation
What you need to add:
- π§ Input validation: Use Zod, Joi, Yup, or your preferred validation library
- π Authentication: Implement JWT, sessions, or OAuth as needed
- πΎ Database: Add MongoDB, PostgreSQL, or your preferred database
- π External services: Redis for caching, reverse proxy for HTTPS
- π Monitoring: Add health checks, metrics, and alerting
Perfect for:
- Learning HTTP internals and server architecture
- Building APIs with your preferred tools and libraries
- Zero-dependency deployments
- Custom server implementations
Not suitable for:
- Applications requiring middleware systems (Express-style
app.use()) - Complex routing with nested middleware
- Built-in authentication or database integration
npm install hasty-serverHasty Server supports multiple module systems for maximum compatibility:
const Hasty = require('hasty-server');
const server = new Hasty();import Hasty from 'hasty-server';
const server = new Hasty();import Hasty from 'hasty-server';
const app = new Hasty();
// Enable security features
app.setSecurityHeaders(true);
app.setRateLimit(true);
app.get('/', (req, res) => {
res.json({ message: 'Hello from TypeScript!' });
});The framework automatically detects your module system and provides the appropriate format:
- CommonJS projects: Uses
.jsfiles - ESM projects: Uses
.mjsfiles - TypeScript projects: Uses
.d.tstype definitions
const Hasty = require('hasty-server');
const app = new Hasty();
// Enable production-ready security features
app.setSecurityHeaders(true); // XSS, CSRF, clickjacking protection
app.setRateLimit(true); // Rate limiting (100 req/15min per IP)
app.setMaxRequestSize(5 * 1024 * 1024); // 5MB request size limit
// Basic routes
app.get('/', (req, res) => {
res.json({ message: 'Hello World', timestamp: new Date().toISOString() });
});
app.post('/api/users', (req, res) => {
// Add your validation logic here (Zod, Joi, etc.)
// Add your database logic here
res.status(201).json({ id: 1, created: true });
});
app.listen(3000, () => {
console.log('π Server running on http://localhost:3000');
});app.get(path, handler)- Handle GET requestsapp.post(path, handler)- Handle POST requestsapp.put(path, handler)- Handle PUT requestsapp.delete(path, handler)- Handle DELETE requestsapp.patch(path, handler)- Handle PATCH requestsapp.head(path, handler)- Handle HEAD requestsapp.options(path, handler)- Handle OPTIONS requests
app.setSecurityHeaders(config)- Enable security headersapp.setRateLimit(config)- Configure rate limitingapp.setMaxRequestSize(bytes)- Set maximum request sizeapp.cors(enabled)- Enable/disable CORS
res.send(data)- Send response datares.json(data)- Send JSON responseres.status(code)- Set HTTP status coderes.setHeader(key, value)- Set response headerres.sendFile(path)- Send file as response
req.method- HTTP method (GET, POST, etc.)req.path- Request pathreq.query- Parsed query parametersreq.params- URL parametersreq.body- Parsed request bodyreq.headers- Request headersreq.ip- Client IP addressreq.id- Unique request ID for tracing
For production deployment, consider these best practices:
const Hasty = require('hasty-server');
const app = new Hasty();
// Security first
app.setSecurityHeaders(true);
app.setRateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
maxRequests: 100
});
app.setMaxRequestSize(10 * 1024 * 1024); // 10MB
// Add your routes and business logic
app.get('/health', (req, res) => {
res.json({ status: 'ok', timestamp: Date.now() });
});
// Deploy behind reverse proxy (nginx/traefik) for HTTPS
app.listen(process.env.PORT || 3000);We welcome contributions! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Important: This project maintains zero dependencies. All code must be pure Node.js.
Hasty Server is designed as a lightweight HTTP framework. It does not include:
- Middleware system (
app.use()) - Built-in authentication
- Built-in database integration
- Built-in input validation
- Built-in session management
For these features, integrate your preferred libraries (Zod for validation, JWT for auth, etc.).
-
v1.0.0 - Production Ready Release
- Added configurable security headers
- Implemented rate limiting
- Added request tracing with unique IDs
- Fixed CORS credentials bug
- Improved error handling consistency
- Replaced console logging with structured logging
- Added request size limits
-
v0.9.6
- Added comprehensive module support (CommonJS, ESM, TypeScript)
- Added dual package support with automatic module detection
For more information, see . CHANGELOG
This project is licensed under LGPL-2.1 - see the LICENSE file for details.
All rights reserved to the author.