diff --git a/examples/QuickJS/.pages.yaml b/examples/QuickJS/.pages.yaml index 6947309..07b9ebf 100644 --- a/examples/QuickJS/.pages.yaml +++ b/examples/QuickJS/.pages.yaml @@ -1,5 +1,8 @@ routes: -- path: "api/v1/**" +- path: "api/dev/**" qjs: exec: "index.js" - debug: true \ No newline at end of file + debug: true +- path: "api/prod/**" + qjs: + exec: "json.js" \ No newline at end of file diff --git a/examples/QuickJS/index.html b/examples/QuickJS/index.html index 686f81a..7a6795a 100644 --- a/examples/QuickJS/index.html +++ b/examples/QuickJS/index.html @@ -5,7 +5,7 @@ - Document + Quickjs 概念验证 diff --git a/examples/QuickJS/index.js b/examples/QuickJS/index.js index 8c9502c..d112657 100644 --- a/examples/QuickJS/index.js +++ b/examples/QuickJS/index.js @@ -1,7 +1,7 @@ response.write("hello world") console.log("hello world") console.log(req.methaaod) -function aaa(){ +function testError(){ throw Error("Method not implemented") } -aaa() \ No newline at end of file +testError() \ No newline at end of file diff --git a/examples/QuickJS/json.js b/examples/QuickJS/json.js new file mode 100644 index 0000000..329d90f --- /dev/null +++ b/examples/QuickJS/json.js @@ -0,0 +1,4 @@ +resp.setHeader("content-type", "application/json"); +resp.write(JSON.stringify({ + 'method': req.method, +}))