{"id":37729811,"url":"https://github.com/techiev2/vajra","last_synced_at":"2026-01-20T17:52:42.633Z","repository":{"id":331210306,"uuid":"1124723239","full_name":"techiev2/vajra","owner":"techiev2","description":"Ultra-minimal, zero-dependency Node.js HTTP server Routing · Middleware · Multipart parsing · HTML templating","archived":false,"fork":false,"pushed_at":"2026-01-14T09:15:19.000Z","size":1733,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-14T13:27:22.213Z","etag":null,"topics":["javascript","nodejs","webserver"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/techiev2.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-29T14:00:35.000Z","updated_at":"2026-01-14T09:15:20.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/techiev2/vajra","commit_stats":null,"previous_names":["techiev2/vajra"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/techiev2/vajra","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techiev2%2Fvajra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techiev2%2Fvajra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techiev2%2Fvajra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techiev2%2Fvajra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/techiev2","download_url":"https://codeload.github.com/techiev2/vajra/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techiev2%2Fvajra/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28479034,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","nodejs","webserver"],"created_at":"2026-01-16T13:48:21.841Z","updated_at":"2026-01-16T13:48:21.922Z","avatar_url":"https://github.com/techiev2.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vajra ⚡\n\n![Vajra Thunderbolt](assets/vajra.jpg)  \u003c!-- or use one of the above hosted URLs if you like --\u003e\n\n\n**Ultra-minimal, zero-dependency Node.js HTTP server**  \nRouting · Middleware · Multipart parsing · HTML templating  \nAll in **111 lines** of pure JavaScript\n\n## Name Origin\n\nVajra draws from the Rigvedic thunderbolt weapon of Indra — crafted from the bones of Sage Dadhichi, symbolizing unbreakable strength through selfless sacrifice.\n\nLike the Vajra, this server delivers maximum power in minimal form.\n\n\n[![npm version](https://img.shields.io/npm/v/@techiev2/vajra.svg?style=flat-square)](https://www.npmjs.com/package/@techiev2/vajra)\n[![npm downloads](https://img.shields.io/npm/dm/vajra.svg?style=flat-square)](https://www.npmjs.com/package/@techiev2/vajra)\n[![Node.js version](https://img.shields.io/node/v/@techiev2/vajra.svg?style=flat-square)](https://nodejs.org)\n[![License](https://img.shields.io/npm/l/@techiev2/vajra.svg?style=flat-square)](LICENSE)\n\n\n## Changelog\n\n### 1.5.3 (2026-01-14)\n- Downgrades createServer to come from http module. Secure server support to be provided in a later minor version.\n\n### 1.5.2 (2026-01-12)\n- Upgrades createServer to come from https module on snyk suggestion.\n\n### 1.5.1 (2026-01-04)\n- Adds a pre-allocated buffer based body reader for improvement.\n\n### 1.5.0 (2026-01-03)\n- Adds support for res.sendFile.\n\n### 1.4.3 (2026-01-02)\n- Adds guardrails for unsafe operations with template paths.\n\n### 1.4.2 (2026-01-02)\n- Fixes bug in parsing params that dropped file extensions.\n\n### 1.4.1 (2026-01-01)\n- Added support to handle drift in system time after signing\n\n### 1.4.0 (2025-12-31)\n- Added full HS256 JWT support (`@techiev2/vajra/libs/auth/jwt.js`)\n  - Ultra-minimal, zero-dependency implementation\n  - Key and header caching for maximum performance\n  - Robust base64url handling\n  - Numeric exp validation and expiration checks\n\n### 1.3.0 (2025-12-30)\n- Performance improvements to routing in bare routes\n\n### 1.2.0 (2025-12-30)\n- Adds cookie support\n\n### 1.0.0 (2025-12-25)\n- Initial release\n\n## Features\n\n- Zero external dependencies\n- Built-in routing with named parameters (`:id`)\n- Asynchronous batched logging for performance\n- Global middleware support with `next()` chaining\n- JSON, urlencoded, and **multipart/form-data** body parsing\n- Fast HTML templating with loops, nested objects, and simple array headers\n- Helper methods: `res.json()`, `res.html()`, `res.status()`, `res.writeMessage()`\n- Payload size limiting with 413 responses\n- Sensible defaults for 404/405/500\n\n## Performance (Apple M4, Node 20+)\n\n| Test Case                                      | Vajra          | Express + Multer | Notes                     |\n|------------------------------------------------|----------------|------------------|---------------------------|\n| 1MB Multipart Upload (wrk -t16 -c600)          | **~94–98k req/s** | ~72k req/s      | +30% faster               |\n| Idle RSS                                       | ~52–53 MB      | ~44 MB           | Zero deps vs extra packages |\n| Peak RSS under load                            | ~228 MB        | ~209 MB          | Full buffering trade-off  |\n| Code size (source)                             | **111 lines**  | ~2k+ lines       | Hand-crafted minimalism   |\n\n## Performance Benchmarks (wrk)\n\n![wrk multipart benchmarks on M4 and VPS](assets/wrk-benchmarks.png)\n\n## Installation\n\n```bash\nnpm install vajra\n```\n\n\n## Quick Start\n```JavaScript\nimport Vajra from '../index.js';\nimport { encode } from 'node:querystring';\n\nasync function getUsers(query = {}) {\n  return (await fetch(`https://jsonplaceholder.typicode.com/users?${encode(query)}`)).json()\n}\n\nconst { get, post, use, start, setProperty, log } = Vajra.create();\n\nsetProperty({ viewsRoot: `${import.meta.url}/views` })\n// Or as a key-value pair\n// setProperty('viewsRoot', `${import.meta.url}/views`)\n\nuse((req, res, next) =\u003e {\n  // Vajra provides an async batched logger to provide a balance between 100% log coverage and performance.\n  // If you prefer blocking immediate logs, you can switch to console.log\n  // or any other library of your choice.\n  log(`${req.method} ${req.url}`);\n  next();\n});\n\nget('/', (req, res) =\u003e {\n  res.writeMessage('Hello from Vajra ⚡');\n});\n\npost('/upload', (req, res) =\u003e {\n  res.json({ received: true, filesCount: req.files.length, files: req.files, body: req.body });\n});\n\nstart({ port: 4002 }, () =\u003e {\n  console.log('Ready at http://localhost:4002');\n});\n\nget('/api/users', async ({ query }, res) =\u003e {\n  const users = await getUsers(query)\n  return res.json({ users })\n})\n\nget('/web/users', async ({ query }, res) =\u003e {\n  const users = await getUsers(query)\n  const headers = Object.keys(users[0])\n  return res.html(`users.html`, { users, headers })\n})\n```\n\n## HTML Templating\n```JavaScript\nimport Vajra from '../index.js';\nconst { get, post, use, start, setProperty } = Vajra.create();\n\nget('/users', (req, res) =\u003e {\n  const data = {\n    users: [\n      { id: 1, name: 'Alice' },\n      { id: 2, name: 'Bob' }\n    ],\n    headers: ['ID', 'Name']\n  };\n\n  // If no view root is set, .html() expects the absolute path.\n  res.html('views/users.html', data);\n});\n```\n\n#### views/users.html\n```html\n\u003ctable\u003e\n  \u003cthead\u003e\n    {{# headers }}\n      \u003cth\u003e{{ header@ }}\u003c/th\u003e\n    {{/ headers }}\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    {{# users }}\n      \u003ctr\u003e\n        \u003ctd\u003e{{ id }}\u003c/td\u003e\n        \u003ctd\u003e{{ name }}\u003c/td\u003e\n      \u003c/tr\u003e\n    {{/ users }}\n  \u003c/tbody\u003e\n\u003c/table\u003e\n```\n\nSupports:\n\n- Loops ({{# array }} ... {{/ array }})\n- Dot notation ({{ user.name }})\n- Special header shorthand ({{ header@ }} for simple arrays)\n\n\n## Configuration\n```JavaScript\nconst app = vajra.create({\n  maxFileSize: 10 // in MB (default: 2)\n});\n\n// Set view root path\napp.setProperty('viewRoot', './views');\n```\n\n\n## API\n\n- `get/post/put/patch/delete/head/options(path, handler)`\n- `use(middleware)`\n- `start({ port, host }, callback?)`\n- `setProperty(key, value)` or `setProperty({ key: value })`\n- `log(message)`\n\n\n#### Response helpers:\n\n`res.status(code)`\n`res.json(data)`\n`res.writeMessage(text)`\n`res.html(pathOrString, data)`\n\n\n## Philosophy\n\nVajra is built on the principle that minimalism can maximise outcomes.\n\nEverything you need for real internal tools, admin panels, APIs, and prototypes — without the bloat.\n\nNo dependencies.\nNo build step.\nJust copy `index.js` and go.\n\n\n## Benchmarks \u0026 Memory\nRun under extreme multipart load (wrk -t16 -c600 -d30s 1MB payloads):\n\nThroughput: ~95k req/s\nIdle RSS: ~52 MB\nPeak under load: ~228 MB (drops back on idle)\n\n## License\nMIT\n\n## Credits\nHand-crafted by [[Sriram Velamur](https://linkedin.com/in/techiev2)/[@techiev2](https://x.com/techiev2)]\n\nInspired by the desire for a truly tiny, powerful, and dependency-free Node server.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechiev2%2Fvajra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechiev2%2Fvajra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechiev2%2Fvajra/lists"}