From ffd687d03453fcd973f57f25b0ced16ac4ed46d6 Mon Sep 17 00:00:00 2001 From: Shyam20001 Date: Sat, 1 Nov 2025 14:11:02 +0530 Subject: [PATCH 1/2] brahma-firelight added --- .../TypeScript/brahma-firelight/.gitignore | 34 +++++++++++++++++ .../TypeScript/brahma-firelight/README.md | 25 +++++++++++++ .../brahma-firelight/benchmark_config.json | 21 +++++++++++ .../brahma-firelight.dockerfile | 13 +++++++ .../TypeScript/brahma-firelight/bun.lock | 34 +++++++++++++++++ .../TypeScript/brahma-firelight/config.toml | 15 ++++++++ .../TypeScript/brahma-firelight/package.json | 19 ++++++++++ .../TypeScript/brahma-firelight/src/main.ts | 37 +++++++++++++++++++ .../TypeScript/brahma-firelight/tsconfig.json | 29 +++++++++++++++ 9 files changed, 227 insertions(+) create mode 100644 frameworks/TypeScript/brahma-firelight/.gitignore create mode 100644 frameworks/TypeScript/brahma-firelight/README.md create mode 100644 frameworks/TypeScript/brahma-firelight/benchmark_config.json create mode 100644 frameworks/TypeScript/brahma-firelight/brahma-firelight.dockerfile create mode 100644 frameworks/TypeScript/brahma-firelight/bun.lock create mode 100644 frameworks/TypeScript/brahma-firelight/config.toml create mode 100644 frameworks/TypeScript/brahma-firelight/package.json create mode 100644 frameworks/TypeScript/brahma-firelight/src/main.ts create mode 100644 frameworks/TypeScript/brahma-firelight/tsconfig.json diff --git a/frameworks/TypeScript/brahma-firelight/.gitignore b/frameworks/TypeScript/brahma-firelight/.gitignore new file mode 100644 index 00000000000..a14702c409d --- /dev/null +++ b/frameworks/TypeScript/brahma-firelight/.gitignore @@ -0,0 +1,34 @@ +# dependencies (bun install) +node_modules + +# output +out +dist +*.tgz + +# code coverage +coverage +*.lcov + +# logs +logs +_.log +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# caches +.eslintcache +.cache +*.tsbuildinfo + +# IntelliJ based IDEs +.idea + +# Finder (MacOS) folder config +.DS_Store diff --git a/frameworks/TypeScript/brahma-firelight/README.md b/frameworks/TypeScript/brahma-firelight/README.md new file mode 100644 index 00000000000..40053a4be24 --- /dev/null +++ b/frameworks/TypeScript/brahma-firelight/README.md @@ -0,0 +1,25 @@ + +# 🗿 Brahma-JS (brahma-firelight) + +Express-style framework ⚡ powered by Rust (Tokio + Hyper). +Plug-n-play for **Node.js**, **Deno**, and **Bun** — no setup, just install and harness the true power of RUST. + +--- + +### 🔗 Links +- Repo: [github.com/Shyam20001/rsjs](https://github.com/Shyam20001/rsjs) +- Site: [shyam20001.github.io/rsjs](https://shyam20001.github.io/rsjs) + +--- + +### ⚙️ Commands +```bash +bun install +bun run build +bun start +# Dev mode: +bun run dev +```` + +Runs on **0.0.0.0:8080** exposing `/plaintext` and `/json` endpoints. + diff --git a/frameworks/TypeScript/brahma-firelight/benchmark_config.json b/frameworks/TypeScript/brahma-firelight/benchmark_config.json new file mode 100644 index 00000000000..5ebbb896e7e --- /dev/null +++ b/frameworks/TypeScript/brahma-firelight/benchmark_config.json @@ -0,0 +1,21 @@ +{ + "framework": "brahma-firelight", + "tests": [{ + "default": { + "json_url": "/json", + "plaintext_url": "/plaintext", + "port": 8080, + "approach": "Realistic", + "classification": "Micro", + "framework": "brahma-firelight", + "language": "TypeScript", + "flavor": "bun", + "platform": "bun", + "webserver": "None", + "os": "Linux", + "database_os": "Linux", + "display_name": "brahma-firelight", + "versus": "nodejs" + } + }] +} diff --git a/frameworks/TypeScript/brahma-firelight/brahma-firelight.dockerfile b/frameworks/TypeScript/brahma-firelight/brahma-firelight.dockerfile new file mode 100644 index 00000000000..dd682eba23f --- /dev/null +++ b/frameworks/TypeScript/brahma-firelight/brahma-firelight.dockerfile @@ -0,0 +1,13 @@ +FROM oven/bun:1.3 + +WORKDIR /app + +COPY . . + +RUN bun install + +RUN bun run build + +EXPOSE 8080 + +CMD ["bun", "dist/main.js"] diff --git a/frameworks/TypeScript/brahma-firelight/bun.lock b/frameworks/TypeScript/brahma-firelight/bun.lock new file mode 100644 index 00000000000..a24e46c51c5 --- /dev/null +++ b/frameworks/TypeScript/brahma-firelight/bun.lock @@ -0,0 +1,34 @@ +{ + "lockfileVersion": 1, + "workspaces": { + "": { + "name": "brahma-firelight", + "dependencies": { + "brahma-firelight": "1.5.16", + }, + "devDependencies": { + "@types/bun": "latest", + }, + "peerDependencies": { + "typescript": "^5", + }, + }, + }, + "packages": { + "@types/bun": ["@types/bun@1.3.1", "", { "dependencies": { "bun-types": "1.3.1" } }, "sha512-4jNMk2/K9YJtfqwoAa28c8wK+T7nvJFOjxI4h/7sORWcypRNxBpr+TPNaCfVWq70tLCJsqoFwcf0oI0JU/fvMQ=="], + + "@types/node": ["@types/node@24.9.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA=="], + + "@types/react": ["@types/react@19.2.2", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA=="], + + "brahma-firelight": ["brahma-firelight@1.5.16", "", {}, "sha512-KwqrG3EHBcEYiOjjx7UvZ4TDxnKTP+DPjnQQqblKuHQcS/mw35NzIYf01YnBZLRM/9VZrb5+UrDaNmrAPZGYlw=="], + + "bun-types": ["bun-types@1.3.1", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="], + + "csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="], + + "typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="], + + "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], + } +} diff --git a/frameworks/TypeScript/brahma-firelight/config.toml b/frameworks/TypeScript/brahma-firelight/config.toml new file mode 100644 index 00000000000..c48a28eaa14 --- /dev/null +++ b/frameworks/TypeScript/brahma-firelight/config.toml @@ -0,0 +1,15 @@ +[framework] +name = "brahma-firelight" + +[main] +urls.plaintext = "/plaintext" +urls.json = "/json" +approach = "Realistic" +classification = "Micro" +database_os = "Linux" +database = "None" +os = "Linux" +orm = "Raw" +platform = "bun" +webserver = "None" +versus = "nodejs" diff --git a/frameworks/TypeScript/brahma-firelight/package.json b/frameworks/TypeScript/brahma-firelight/package.json new file mode 100644 index 00000000000..dbe9f089100 --- /dev/null +++ b/frameworks/TypeScript/brahma-firelight/package.json @@ -0,0 +1,19 @@ +{ + "name": "brahma-firelight", + "type": "module", + "main": "src/index.ts", + "scripts": { + "dev": "bun --hot src/main.ts", + "build": "bun build src/main.ts --packages external --sourcemap --outdir dist --minify", + "start": "bun dist/main.js" + }, + "devDependencies": { + "@types/bun": "latest" + }, + "peerDependencies": { + "typescript": "^5" + }, + "dependencies": { + "brahma-firelight": "1.5.16" + } +} \ No newline at end of file diff --git a/frameworks/TypeScript/brahma-firelight/src/main.ts b/frameworks/TypeScript/brahma-firelight/src/main.ts new file mode 100644 index 00000000000..639d33f3085 --- /dev/null +++ b/frameworks/TypeScript/brahma-firelight/src/main.ts @@ -0,0 +1,37 @@ +import { createApp, type Response, type Request, type App, type NextFunction, type Handler } from "brahma-firelight"; + +const app: App = createApp(); + +// Server Config Middleware +const serverInfo: Handler = (_req: Request, res: Response, next?: NextFunction) => { + res.setHeader("Server", "brahma-firelight"); + next?.(); +}; + +// JSON compute +app.get("/json", serverInfo, (_req: Request, res: Response) => { + res.json({ message: "Hello, World!" }); +}); + +// PLAIN-TEXT +app.get("/plaintext", serverInfo, (_req: Request, res: Response) => { + res.text("Hello, World!"); +}); + +// Port & Host + +app.listen("0.0.0.0", 8080); + +// Enable built in Graceful Shutdown (optional for production use) + +process.on('SIGINT', async () => { + console.log('SIGINT → shutting down...'); + await app.close(2000); // wait up to 2s for requests + process.exit(0); +}); + +process.on('SIGTERM', async () => { + console.log('SIGTERM → shutting down...'); + await app.close(2000); + process.exit(0); +}); \ No newline at end of file diff --git a/frameworks/TypeScript/brahma-firelight/tsconfig.json b/frameworks/TypeScript/brahma-firelight/tsconfig.json new file mode 100644 index 00000000000..976e9d12d50 --- /dev/null +++ b/frameworks/TypeScript/brahma-firelight/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + // Environment setup & latest features + "lib": [ + "ESNext" + ], + "forceConsistentCasingInFileNames": true, + "target": "ESNext", + "module": "es6", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedIndexedAccess": true, + "noImplicitOverride": true, + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false + } +} \ No newline at end of file From f06e84c8fbdaf67c5c746ee06216afe99cc32a6a Mon Sep 17 00:00:00 2001 From: Shyam20001 Date: Sat, 8 Nov 2025 13:44:29 +0530 Subject: [PATCH 2/2] cluster mode enabled --- .../brahma-firelight/benchmark_config.json | 36 ++++++------ .../brahma-firelight.dockerfile | 22 ++++++-- .../TypeScript/brahma-firelight/bun.lock | 4 +- .../TypeScript/brahma-firelight/package.json | 2 +- .../TypeScript/brahma-firelight/src/main.ts | 55 +++++++++++++------ 5 files changed, 78 insertions(+), 41 deletions(-) diff --git a/frameworks/TypeScript/brahma-firelight/benchmark_config.json b/frameworks/TypeScript/brahma-firelight/benchmark_config.json index 5ebbb896e7e..60db94104a9 100644 --- a/frameworks/TypeScript/brahma-firelight/benchmark_config.json +++ b/frameworks/TypeScript/brahma-firelight/benchmark_config.json @@ -1,21 +1,23 @@ { "framework": "brahma-firelight", - "tests": [{ - "default": { - "json_url": "/json", - "plaintext_url": "/plaintext", - "port": 8080, - "approach": "Realistic", - "classification": "Micro", - "framework": "brahma-firelight", - "language": "TypeScript", - "flavor": "bun", - "platform": "bun", - "webserver": "None", - "os": "Linux", - "database_os": "Linux", - "display_name": "brahma-firelight", - "versus": "nodejs" + "tests": [ + { + "default": { + "json_url": "/json", + "plaintext_url": "/plaintext", + "port": 8080, + "approach": "Realistic", + "classification": "Micro", + "framework": "brahma-firelight", + "language": "TypeScript", + "flavor": "bun", + "platform": "bun", + "webserver": "None", + "os": "Linux", + "database_os": "Linux", + "display_name": "brahma-firelight", + "versus": "nodejs" + } } - }] + ] } diff --git a/frameworks/TypeScript/brahma-firelight/brahma-firelight.dockerfile b/frameworks/TypeScript/brahma-firelight/brahma-firelight.dockerfile index dd682eba23f..4ae04a5efbf 100644 --- a/frameworks/TypeScript/brahma-firelight/brahma-firelight.dockerfile +++ b/frameworks/TypeScript/brahma-firelight/brahma-firelight.dockerfile @@ -1,13 +1,25 @@ -FROM oven/bun:1.3 - +FROM oven/bun:1.3 AS builder WORKDIR /app -COPY . . +COPY package.json bun.lock ./ -RUN bun install +RUN bun ci +COPY . . RUN bun run build +FROM oven/bun:1.3 AS runtime +WORKDIR /app + +ENV NODE_ENV=production +ENV PORT=8080 + +COPY --from=builder /app/dist ./dist +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/package.json ./package.json + +ENV NODE_ENV=production + EXPOSE 8080 -CMD ["bun", "dist/main.js"] +ENTRYPOINT ["bun", "dist/main.js"] diff --git a/frameworks/TypeScript/brahma-firelight/bun.lock b/frameworks/TypeScript/brahma-firelight/bun.lock index a24e46c51c5..067ff9b71e3 100644 --- a/frameworks/TypeScript/brahma-firelight/bun.lock +++ b/frameworks/TypeScript/brahma-firelight/bun.lock @@ -4,7 +4,7 @@ "": { "name": "brahma-firelight", "dependencies": { - "brahma-firelight": "1.5.16", + "brahma-firelight": "^1.5.18", }, "devDependencies": { "@types/bun": "latest", @@ -21,7 +21,7 @@ "@types/react": ["@types/react@19.2.2", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA=="], - "brahma-firelight": ["brahma-firelight@1.5.16", "", {}, "sha512-KwqrG3EHBcEYiOjjx7UvZ4TDxnKTP+DPjnQQqblKuHQcS/mw35NzIYf01YnBZLRM/9VZrb5+UrDaNmrAPZGYlw=="], + "brahma-firelight": ["brahma-firelight@1.5.18", "", {}, "sha512-/raDDeb6/AAHYPfvTi4vWA79BjsHwh5Eg63GWJPwWzyip3mvY0tIsNeMqHit4XBdyJZ9t0UgtsvNaHGx3zqFGw=="], "bun-types": ["bun-types@1.3.1", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="], diff --git a/frameworks/TypeScript/brahma-firelight/package.json b/frameworks/TypeScript/brahma-firelight/package.json index dbe9f089100..c7b49a791fd 100644 --- a/frameworks/TypeScript/brahma-firelight/package.json +++ b/frameworks/TypeScript/brahma-firelight/package.json @@ -14,6 +14,6 @@ "typescript": "^5" }, "dependencies": { - "brahma-firelight": "1.5.16" + "brahma-firelight": "^1.5.18" } } \ No newline at end of file diff --git a/frameworks/TypeScript/brahma-firelight/src/main.ts b/frameworks/TypeScript/brahma-firelight/src/main.ts index 639d33f3085..3583f916605 100644 --- a/frameworks/TypeScript/brahma-firelight/src/main.ts +++ b/frameworks/TypeScript/brahma-firelight/src/main.ts @@ -1,10 +1,13 @@ import { createApp, type Response, type Request, type App, type NextFunction, type Handler } from "brahma-firelight"; +import cluster from "node:cluster"; +import os from "node:os"; const app: App = createApp(); // Server Config Middleware const serverInfo: Handler = (_req: Request, res: Response, next?: NextFunction) => { res.setHeader("Server", "brahma-firelight"); + res.setHeader("Connection", "keep-alive") next?.(); }; @@ -19,19 +22,39 @@ app.get("/plaintext", serverInfo, (_req: Request, res: Response) => { }); // Port & Host - -app.listen("0.0.0.0", 8080); - -// Enable built in Graceful Shutdown (optional for production use) - -process.on('SIGINT', async () => { - console.log('SIGINT → shutting down...'); - await app.close(2000); // wait up to 2s for requests - process.exit(0); -}); - -process.on('SIGTERM', async () => { - console.log('SIGTERM → shutting down...'); - await app.close(2000); - process.exit(0); -}); \ No newline at end of file +const PORT = process.env.PORT || 8080; +const HOST = process.env.HOST || "0.0.0.0"; + +// Single CORE +//app.listen(HOST, +PORT); + +// Multi CORE (cluster with max cpus available) +if (cluster.isPrimary) { + const cpuCount = os.cpus().length; + console.log(`Primary ${process.pid} running → forking ${cpuCount} workers...`); + + for (let i = 0; i < cpuCount; i++) { + cluster.fork(); + } + + cluster.on("exit", (worker) => { + console.log(`Worker ${worker.process.pid} died → restarting...`); + cluster.fork(); + }); +} else { + app.listen(HOST, +PORT); +} + +// // Enable built in Graceful Shutdown (optional for production use) + +// process.on('SIGINT', async () => { +// console.log('SIGINT → shutting down...'); +// await app.close(2000); // wait up to 2s for requests +// process.exit(0); +// }); + +// process.on('SIGTERM', async () => { +// console.log('SIGTERM → shutting down...'); +// await app.close(2000); +// process.exit(0); +// }); \ No newline at end of file