Browse Source

updated brahma-firelight with Rust_Native Router (#10300)

* brahma-firelight added

* cluster mode enabled

* updated with native call-mode
Shyam 2 weeks ago
parent
commit
94ef1d2fc6

+ 2 - 2
frameworks/TypeScript/brahma-firelight/bun.lock

@@ -4,7 +4,7 @@
     "": {
     "": {
       "name": "brahma-firelight",
       "name": "brahma-firelight",
       "dependencies": {
       "dependencies": {
-        "brahma-firelight": "^1.5.18",
+        "brahma-firelight": "^1.5.20",
       },
       },
       "devDependencies": {
       "devDependencies": {
         "@types/bun": "latest",
         "@types/bun": "latest",
@@ -21,7 +21,7 @@
 
 
     "@types/react": ["@types/[email protected]", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA=="],
     "@types/react": ["@types/[email protected]", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA=="],
 
 
-    "brahma-firelight": ["[email protected].18", "", {}, "sha512-/raDDeb6/AAHYPfvTi4vWA79BjsHwh5Eg63GWJPwWzyip3mvY0tIsNeMqHit4XBdyJZ9t0UgtsvNaHGx3zqFGw=="],
+    "brahma-firelight": ["[email protected].20", "", {}, "sha512-ACx1E77gepT1WvHskT3AP4fGoxcp2i0Wt7/0DdornEZr5R+emrA1M8YfuA9JGfpVe0bH5L1E6lZxkpldcd3YHQ=="],
 
 
     "bun-types": ["[email protected]", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="],
     "bun-types": ["[email protected]", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="],
 
 

+ 1 - 1
frameworks/TypeScript/brahma-firelight/package.json

@@ -14,6 +14,6 @@
     "typescript": "^5"
     "typescript": "^5"
   },
   },
   "dependencies": {
   "dependencies": {
-    "brahma-firelight": "^1.5.18"
+    "brahma-firelight": "^1.5.20"
   }
   }
 }
 }

+ 31 - 12
frameworks/TypeScript/brahma-firelight/src/main.ts

@@ -1,25 +1,44 @@
-import { createApp, type Response, type Request, type App, type NextFunction, type Handler } from "brahma-firelight";
+import { createApp, type Response, type Request, type App, type NextFunction, type Handler, registerRustHotpath } from "brahma-firelight";
 import cluster from "node:cluster";
 import cluster from "node:cluster";
 import os from "node:os";
 import os from "node:os";
 
 
 const app: App = createApp();
 const app: App = createApp();
 
 
 // Server Config Middleware
 // Server Config Middleware
-const serverInfo: Handler = (_req: Request, res: Response, next?: NextFunction) => {
-    res.setHeader("Server", "brahma-firelight");
-    res.setHeader("Connection", "keep-alive")
-    next?.();
-};
+// const serverInfo: Handler = (_req: Request, res: Response, next?: NextFunction) => {
+//     res.setHeader("Server", "brahma-firelight");
+//     res.setHeader("Connection", "keep-alive")
+//     next?.();
+// };
 
 
 // JSON compute
 // JSON compute
-app.get("/json", serverInfo, (_req: Request, res: Response) => {
-    res.json({ message: "Hello, World!" });
-});
+// 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!");
+// });
+
+
+// JSON compute
+registerRustHotpath(
+    "GET",
+    "/json",
+    200,
+    '{"Content-Type": "application/json", "Server": "brahma-firelight"}',
+    Buffer.from(JSON.stringify({ message: "Hello, World!" }))
+);
 
 
 // PLAIN-TEXT
 // PLAIN-TEXT
-app.get("/plaintext", serverInfo, (_req: Request, res: Response) => {
-    res.text("Hello, World!");
-});
+registerRustHotpath(
+    "GET",
+    "/plaintext",
+    200,
+    '{"Content-Type": "text/plain", "Server": "brahma-firelight"}',
+    Buffer.from("Hello, World!")
+);
 
 
 // Port & Host 
 // Port & Host 
 const PORT = process.env.PORT || 8080;
 const PORT = process.env.PORT || 8080;