Skip to content

sunnyghodeswar/vegaa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

41 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Vegaa Banner

Vegaa

A modern Node.js framework that makes backend development simple and fast

npm version License: MIT GitHub stars GitHub issues Documentation


๐Ÿ“– Table of Contents


๐ŸŽฏ Why Vegaa?

Vegaa makes Node.js backend development simpler without sacrificing performance.

The Problem with Traditional Frameworks

In Express, you constantly repeat yourself:

app.get('/user/:id', (req, res) => {
  const user = req.user           // Extract from req
  const id = req.params.id        // Extract from params
  res.json({ user, id })          // Manually send response
})

The Vegaa Solution

Just declare what you need โ€” Vegaa handles the rest:

route('/user/:id').get((user, id) => ({ user, id }))

No manual extraction. No req/res juggling. Just clean, readable code.

Express Compatibility Without Compromise

Need Express middleware? Use it seamlessly:

enableExpressCompat(vegaa)
vegaa.useExpressMiddleware(helmet())
route('/users/:id').get((id) => ({ userId: id }))  // Still clean!

Vegaa's DNA stays intact โ€” minimalism and context integration, with Express middleware support when you need it.


๐Ÿ“ฆ Installation

๐Ÿ“š Installation Guide โ†’

Option 1: Start with Templates (Recommended)

Get started instantly with pre-configured templates:

npx vegaa-cli create my-app
# or
npx vegaa create my-app

Choose from 5 production-ready templates! See CLI section for details.

Option 2: Manual Installation

npm install vegaa

Requirements: Node.js 18 or higher


๐Ÿš€ Quick Start

๐Ÿ“š Full Getting Started Guide โ†’

Create your first API in under 30 seconds:

import { vegaa, route } from 'vegaa'

// Define a simple route
route('/ping').get(() => ({ message: 'pong' }))

// Start the server
await vegaa.startVegaaServer()

Visit http://localhost:4000/ping and you'll see:

{
  "message": "pong"
}

That's it! You just built your first API endpoint.


๐Ÿ’ก Core Concepts

๐Ÿ“š Learn more about Core Concepts โ†’

1. Automatic Parameter Injection

Vegaa automatically provides values based on parameter names:

// Route parameters are automatically available
route('/users/:id').get((id) => {
  return { userId: id }
})

// Multiple parameters work too
route('/users/:userId/posts/:postId').get((userId, postId) => {
  return { userId, postId }
})

How it works: Vegaa reads your function parameters and injects the matching values automatically.

2. Smart Parameter Grouping

For routes with request bodies (POST, PUT, PATCH), Vegaa groups data to avoid naming conflicts:

route('/users/:id').post((params, body) => {
  return {
    userId: params.id,      // Route parameter
    userData: body          // Request body
  }
})
  • params โ†’ Route parameters (:id, :postId, etc.)
  • body โ†’ Request body data
  • query โ†’ Query string parameters
  • Any middleware values you define

๐Ÿ”— Middleware System

๐Ÿ“š Learn more about Middleware โ†’

Middleware is the heart of Vegaa โ€” it creates reusable logic that flows through your app.

Global Middleware

Runs for all routes in your application:

// Authentication middleware
vegaa.middleware(async () => {
  return { user: { id: 1, name: 'John' } }
})

// Logging middleware
vegaa.middleware((pathname) => {
  console.log('Request:', pathname)
})

// Now ALL routes have access to 'user'
route('/profile').get((user) => {
  return { message: `Welcome ${user.name}!` }
})

Route-Specific Middleware

Runs only for specific routes:

route('/admin/:id')
  .middleware((params) => {
    // Only runs for /admin/:id
    if (params.id !== '1') {
      throw new Error('Unauthorized')
    }
    return { access: 'granted' }
  })
  .get((params, access) => {
    return { adminId: params.id, access }
  })

Chaining Middleware

Middleware can build on each other โ€” values flow automatically:

vegaa.middleware([
  async () => ({ user: { id: 1, name: 'Bob' } }),
  async (user) => ({ greeting: `Hello ${user.name}` }),
  async (user, greeting) => ({ log: `${greeting} [User ${user.id}]` })
])
route('/welcome')
  .middleware(async (user, greeting) => ({ log: `${greeting} [User ${user.id}]` }))
  .middleware(async (log) => ({ timestamp: new Date().toISOString() }))
  .get((greeting, log, timestamp) => ({ greeting, log, timestamp }))

Key Concept: Each middleware receives values from previous middleware automatically. Think of it as a pipeline where data flows downstream.


๐Ÿ”Œ Built-in Plugins

๐Ÿ“š Learn more about Plugins โ†’

Vegaa comes with powerful plugins that are loaded by default:

Default Plugins (Pre-loaded)

// These are automatically available:
// โœ… jsonPlugin - JSON response helpers
// โœ… bodyParserPlugin - Request body parsing
// โœ… httpClientPlugin - makeRequest() for external APIs

Optional Plugins

CORS Plugin

Enable cross-origin requests:

import { vegaa, corsPlugin } from 'vegaa'

await vegaa.plugin(corsPlugin)

Static File Plugin

Serve HTML, CSS, JavaScript, images:

import { vegaa, staticPlugin } from 'vegaa'

await vegaa.plugin(staticPlugin, {
  root: './public',              // Folder with your files
  prefix: '/assets',             // URL prefix (optional)
  cacheControl: 'public, max-age=3600'
})

// Files in ./public/ โ†’ http://localhost:4000/assets/*

Creating Custom Plugins

const loggerPlugin = {
  name: 'logger',
  version: '1.0.0',
  async register(app) {
    app.middleware((pathname) => {
      console.log('โ†’', pathname)
    })
  }
}

await vegaa.plugin(loggerPlugin)

โœจ Features

๐Ÿ”Œ Express Middleware Compatibility

๐Ÿ“š Learn more about Express Compatibility โ†’

Use any Express middleware with Vegaa's minimal API โ€” no compromises:

import { vegaa, route, enableExpressCompat } from 'vegaa'
import helmet from 'helmet'
import cors from 'cors'

// Enable Express compatibility
enableExpressCompat(vegaa)

// Use Express middleware seamlessly
vegaa.useExpressMiddleware(helmet())
vegaa.useExpressMiddleware(cors())
vegaa.useExpressMiddleware('/api', someMiddleware)

// Your Vegaa routes work exactly as before
route('/users/:id').get((id) => ({ userId: id }))

Key Benefits:

  • โœ… Use existing Express middleware (helmet, cors, morgan, etc.)
  • โœ… Maintains Vegaa's minimal API โ€” no req/res juggling
  • โœ… Express middleware values flow into Vegaa context automatically
  • โœ… Path-specific middleware support
  • โœ… Error middleware automatically handled

Example with Real Express Middleware:

import { vegaa, route, enableExpressCompat } from 'vegaa'
import helmet from 'helmet'
import cors from 'cors'
import morgan from 'morgan'

enableExpressCompat(vegaa)

// Security headers
vegaa.useExpressMiddleware(helmet())

// CORS
vegaa.useExpressMiddleware(cors({ origin: 'https://example.com' }))

// Logging
vegaa.useExpressMiddleware(morgan('combined'))

// Your routes remain clean and minimal
route('/api/users').get(() => ({ users: [] }))

Perfect for: Migrating from Express, using popular Express middleware, maintaining existing middleware investments.


๐Ÿ”ฅ Response Types

JSON (Default)

route('/data').get(() => ({ status: 'success', data: [1, 2, 3] }))

HTML

import { route, html } from 'vegaa'

route('/').get(() => html('<h1>Welcome!</h1>'))

Text

import { route, text } from 'vegaa'

route('/health').get(() => text('OK'))

๐ŸŒ HTTP Client (External API Calls)

Built-in HTTP client powered by Undici:

route('/posts').get(async (makeRequest) => {
  const data = await makeRequest()
    .url('https://api.example.com/posts/1')
    .get()
    .json()
  
  return data
})

// POST request
route('/create').post(async (makeRequest, body) => {
  return await makeRequest()
    .url('https://api.example.com/posts')
    .post()
    .headers({ 'Content-Type': 'application/json' })
    .body(body)
    .json()
})

Available Methods: .get(), .post(), .put(), .delete(), .headers(), .body(), .json(), .text(), .buffer()

๐ŸŽ Custom Decorators

Add custom values available everywhere:

vegaa.decorate('version', '1.0.0')
vegaa.decorate('db', myDatabaseConnection)

route('/info').get((version) => ({ version }))

โš™๏ธ Multi-Core Cluster Mode

Use all CPU cores automatically:

await vegaa.startVegaaServer({
  port: 4000,
  cluster: true  // Enable multi-core mode
})

๐ŸŽ“ Complete Example

Here's everything working together with route chaining:

import { vegaa, route, html } from 'vegaa'

// Global auth middleware
vegaa.middleware(async () => ({
  user: { id: 1, name: 'Alice' }
}))

// Multiple routes with method chaining
route('/users/:id')
  .get((id, user) => ({ viewerId: user.id, profileId: id }))
  .post((params, body, user) => ({
    created: true,
    data: body,
    authorId: user.id
  }))
  .delete((id) => ({ deleted: true, userId: id }))

// External API call
route('/external').get(async (makeRequest) => {
  return await makeRequest()
    .url('https://api.example.com/data')
    .get()
    .json()
})

// HTML page
route('/').get(() => html('<h1>Welcome to Vegaa!</h1>'))

await vegaa.startVegaaServer({ port: 4000 })

๐Ÿš€ Performance

Vegaa is built for speed while maintaining clean code.

Benchmark Results

Test Environment: MacBook M3, macOS 26, Node v24.3 Tool: autocannon -c 100 -d 300 http://localhost:4000/ping

Framework Requests/sec Latency Notes
Vegaa (Cluster) 112,774 0.09ms Multi-core
Vegaa (Single) 91,488 0.97ms Single-core
Fastify 79,852 1.01ms Industry standard
Express 54,339 1.06ms Most popular

Visual Comparison

Express        โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ       54k req/s
Fastify        โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ   79k req/s
Vegaa          โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ 91k req/s
Vegaa Cluster  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ 112k req/s

Result: Vegaa is 25-30% faster than Fastify and 2x faster than Express.

Technology Stack

Component Technology Purpose
HTTP Server Node.js http Native, low-overhead
Routing find-my-way Fast path matching
JSON fast-json-stringify Optimized serialization
HTTP Client undici High-performance requests
Scaling Node.js cluster Multi-core support

๐Ÿงฐ CLI & Templates

Vegaa CLI provides 5 production-ready templates to kickstart your project:

Installation & Usage

# Install globally
npm install -g vegaa-cli

# Create new project
vegaa create my-app
# or
npx vegaa-cli create my-app

5 Available Templates

Template Description Live Demos
๐ŸŒฑ Minimal Basic /ping server StackBlitz โ€ข CodeSandbox
๐Ÿ”ง Middleware Middleware + Dashboard demo StackBlitz โ€ข CodeSandbox
๐Ÿš€ CRUD JWT Auth + Swagger Docs StackBlitz โ€ข CodeSandbox
๐Ÿ—๏ธ Full-Fledge Production setup (monitoring, admin, etc.) StackBlitz โ€ข CodeSandbox
๐Ÿณ Docker Containerized setup StackBlitz โ€ข CodeSandbox

Try instantly: Launch on your preferred platform โ€” StackBlitz or CodeSandbox โ€” right in the browser, no installation needed!

Quick Commands

cd my-app
npm install
npm start        # Start development server
npm run build    # Build for production

๐Ÿ“ฆ View CLI Documentation


๐Ÿ“š API Reference

Creating Routes

route('/path')
  .get(handler)
  .post(handler)
  .put(handler)
  .delete(handler)

Adding Middleware

vegaa.middleware(middlewareFn)              // Global
route('/path').middleware(middlewareFn)     // Route-specific

Express Middleware Compatibility

import { enableExpressCompat } from 'vegaa'
enableExpressCompat(vegaa)

vegaa.useExpressMiddleware(middleware)           // Global
vegaa.useExpressMiddleware('/path', middleware)  // Path-specific

Starting Server

await vegaa.startVegaaServer({
  port: 4000,
  cluster: false
})

๐Ÿ—บ๏ธ Roadmap

Phase Features Status
Core Engine Context, cluster, plugins โœ… Complete
Dev Tools CLI, validation, caching ๐Ÿšง In Progress
Advanced WebSockets, Redis, Streaming ๐Ÿง  Planned

๐Ÿค Contributing

Contributions welcome! Fork the repo, make changes, and submit a PR.

Need help with: Documentation, bug fixes, performance improvements, new plugins

Open an Issue | View Contributing Guide


๐Ÿ‘จโ€๐Ÿ’ป Author

Sunny Ghodeswar Senior Full-Stack Developer โ€ข Pune, India ๐Ÿ‡ฎ๐Ÿ‡ณ

GitHub โ€ข npm


๐Ÿ“œ License

MIT License โ€” Free for personal and commercial use


๐Ÿ“š Documentation

๐Ÿ“– Visit the Full Documentation Website โ†’

The documentation includes:

  • ๐Ÿ“˜ Getting Started Guide
  • ๐Ÿ’ก Core Concepts & Examples
  • ๐Ÿ”ง Complete API Reference
  • ๐ŸŽฏ Interactive Examples with Stackblitz
  • ๐Ÿš€ Advanced Features & Best Practices

๐Ÿ”— Links & Resources


โšก Vegaa โ€” Named for velocity. Engineered for developers.

Built with โค๏ธ by developers, for developers.

Get Started | Documentation | View Templates | Star on GitHub โญ

About

High-performance Node.js framework with automatic parameter injection, eliminating route handler boilerplate. Features middleware chaining, built-in HTTP client, plugin system, and CLI with

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors