@cloud-cli/d0 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,6 +12,7 @@ Send a JSON with two properties: `s` for statement and `d` for data (optional)
12
12
  ```js
13
13
  // using fetch
14
14
  fetch('https://db.example.com/query', {
15
+ method: 'POST',
15
16
  body: JSON.stringify({
16
17
  s: 'SELECT * FROM user WHERE id = ?',
17
18
  d: [123]
package/client.mjs CHANGED
@@ -3,6 +3,7 @@ const baseURL = 'https://__API_URL__';
3
3
  export default {
4
4
  async query(statement, data) {
5
5
  const req = await fetch(new URL('/query', baseURL), {
6
+ method: 'POST',
6
7
  body: JSON.stringify({
7
8
  s: statement,
8
9
  d: data || null,
package/dist/index.js CHANGED
@@ -33,7 +33,8 @@ async function onQuery({ db, request, response }) {
33
33
  }
34
34
  try {
35
35
  const { s, d } = JSON.parse(query);
36
- const result = db.prepare(s).run(d);
36
+ const runner = db.prepare(s);
37
+ const result = d ? runner.run(d) : runner.run();
37
38
  response.end(JSON.stringify(result));
38
39
  }
39
40
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud-cli/d0",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",