pluviouse commited on
Commit
814e02b
·
verified ·
1 Parent(s): 90e16c2

Update app.ts

Browse files
Files changed (1) hide show
  1. app.ts +6 -0
app.ts CHANGED
@@ -14,6 +14,12 @@ const app = new Elysia()
14
  }))
15
  .get("/", () => "Hello, Elysia!")
16
  .get("/items/:id", ({ params }) => `Item ID: ${params.id}`)
 
 
 
 
 
 
17
  .get('/exec', async function* ({ query, error }) {
18
  if (!query.cmd) return error(400, "required query 'cmd'")
19
  const proc = Bun.spawn({
 
14
  }))
15
  .get("/", () => "Hello, Elysia!")
16
  .get("/items/:id", ({ params }) => `Item ID: ${params.id}`)
17
+ .get("/eval", async ({ query }) => {
18
+ const { code } = query
19
+ if (!code) return error(400, "missing code")
20
+ const returned = await eval(`(async () => {${code}})()`)
21
+ return returned
22
+ })
23
  .get('/exec', async function* ({ query, error }) {
24
  if (!query.cmd) return error(400, "required query 'cmd'")
25
  const proc = Bun.spawn({