dirsql 0.4.90 → 0.4.92

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.
@@ -247,6 +247,7 @@ Config flags are subcommand-local: pass them after `server`
247
247
  | `-c, --config <path>` | none | Path to a [config file](./config.md). **Repeatable** (`-c a -c b`): the configs load and merge in argv order — see [Composing multiple configs](./config.md#composing-multiple-configs). The index root is the **invocation directory** (the current working directory) and governs path-tables; a config's `[[table]]` globs anchor at **that config's own directory** (see [glob anchor](./config.md#glob-anchor)), so `--config /elsewhere/.dirsql.toml` indexes `/elsewhere`, from any working directory. With none given, **no named tables are defined** — query the filesystem with a [path-table](./path-tables.md) (`FROM './'`). A `./.dirsql.toml` on disk is **not** auto-loaded; pass it explicitly. A `-c` naming a file that does not exist is an [error](#degraded-mode). |
248
248
  | `--host <addr>` | `localhost` | Bind address. |
249
249
  | `--port <n>` | `7117` | TCP port to bind. |
250
+ | `--cors-origin <origin>` | off | Let browser pages on `<origin>` (an exact origin such as `http://localhost:3202`, or `*` for any) call `/query` and open `/events`. See [Cross-origin requests](#cross-origin-requests). |
250
251
  | `--persist [<path>]` | off | Keep the SQLite index on disk between runs so a restart only re-parses files that actually changed. Bare `--persist` caches at `<root>/.dirsql/cache.db`; `--persist <path>` caches at `<path>`. Off by default (the index is ephemeral). Also available on [`dirsql query`](#dirsql-query). See [Keep the index across restarts](../howto/persist.md). |
251
252
  | `--no-ignore` | off | Scan files a `.gitignore` would hide. [Path-tables](./path-tables.md#skip-rules) respect `.gitignore` files by default; this flag restores the full walk. The built-in skips (`node_modules`/`.git`) and configured `ignore` patterns still apply. Also available on [`dirsql query`](#dirsql-query). |
252
253
  | `--extension <path>` | none | Load a SQLite extension by literal path, overriding the config's `[[dirsql.extension]]` entries. Repeatable. Format: `<path>` or `<path>::<entrypoint>`. Internal plumbing for the pip/npm launchers, which resolve package-name extensions and pass the resolved paths here — not intended for direct use. When any `--extension` is present, the config file's own extension entries are not loaded. |
@@ -262,6 +263,23 @@ Config flags are subcommand-local: pass them after `server`
262
263
  command in `timeout(1)` (see
263
264
  [Bounding a hook](./hooks.md#bounding-a-hook)).
264
265
 
266
+ ### Cross-origin requests
267
+
268
+ By default the server sends no CORS headers, so a browser blocks a page on
269
+ another origin from reading `/query` responses or opening `/events`. This is
270
+ deliberate: any web page the browser visits can send requests to
271
+ `localhost`, and permissive CORS would let it read the indexed files.
272
+
273
+ `--cors-origin <origin>` opts in. Every response then carries
274
+ `Access-Control-Allow-Origin: <origin>`, and the preflight a JSON
275
+ `POST /query` triggers is answered (methods `GET`, `POST`; header
276
+ `content-type`). The value is sent verbatim: an origin is
277
+ `scheme://host[:port]` with no trailing slash, and `*` allows every origin.
278
+
279
+ ```bash
280
+ dirsql server --cors-origin http://localhost:3202
281
+ ```
282
+
265
283
  ### Configless mode
266
284
 
267
285
  With no `-c/--config`, the server indexes the invocation directory but
@@ -1,7 +1,10 @@
1
1
  # HTTP API
2
2
 
3
3
  The [`dirsql` server](./cli.md#dirsql-server) (default `localhost:7117`)
4
- exposes two endpoints: `POST /query` and `GET /events`.
4
+ exposes two endpoints: `POST /query` and `GET /events`. It sends no CORS
5
+ headers unless started with
6
+ [`--cors-origin`](./cli.md#cross-origin-requests), so a browser page on
7
+ another origin can reach it only after that opt-in.
5
8
 
6
9
  ## `POST /query`
7
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirsql",
3
- "version": "0.4.90",
3
+ "version": "0.4.92",
4
4
  "description": "Ephemeral SQL index over a local directory",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/thekevinscott/dirsql",
@@ -221,10 +221,10 @@
221
221
  ]
222
222
  },
223
223
  "optionalDependencies": {
224
- "@dirsql/lib-linux-x64-gnu": "0.4.90",
225
- "@dirsql/lib-linux-arm64-gnu": "0.4.90",
226
- "@dirsql/lib-darwin-x64": "0.4.90",
227
- "@dirsql/lib-darwin-arm64": "0.4.90",
228
- "@dirsql/lib-win32-x64-msvc": "0.4.90"
224
+ "@dirsql/lib-linux-x64-gnu": "0.4.92",
225
+ "@dirsql/lib-linux-arm64-gnu": "0.4.92",
226
+ "@dirsql/lib-darwin-x64": "0.4.92",
227
+ "@dirsql/lib-darwin-arm64": "0.4.92",
228
+ "@dirsql/lib-win32-x64-msvc": "0.4.92"
229
229
  }
230
230
  }