elm-ssr 0.91.0 → 0.91.1

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
@@ -26,21 +26,59 @@ bunx elm-ssr build
26
26
 
27
27
  ## CLI commands
28
28
 
29
- - **`elm-ssr build`** scans each configured app's `src/<Namespace>/Routes/`
30
- and `Islands/`, generates `.elm-ssr/Main.elm` (the router with file-based
31
- routes + dynamic segments) and the islands manifest, syncs the Elm authoring
32
- modules into the app's `.elm-ssr/src/ElmSsr/`, and compiles via `elm make`
33
- (one combined island bundle exposing `Elm.<App>.Islands.<Name>`).
34
- - **`elm-ssr new <name>`** — scaffold a new app and register it in
35
- `elm-ssr.config.json`.
36
- - **`elm-ssr dev`** — `build` then `wrangler dev` for Cloudflare-like local
37
- development. For other hosts, build with `elm-ssr build` and adapt
38
- `worker.fetch` in your own server/entrypoint.
39
- - **`elm-ssr compress`** — pre-compress generated bundles with gzip.
40
- - **`elm-ssr migrate <up|down|status>`** apply / revert / inspect SQL-file
41
- migrations. `--db postgres://…`, `sqlite://path`, or a plain SQLite file path;
42
- `--dir <path>` (default `./migrations`); `--count N` (for `down`, default 1).
43
- Reads `DATABASE_URL` if `--db` is omitted.
29
+ Run the CLI using `bunx elm-ssr <command>`.
30
+
31
+ ### `build`
32
+ Generates `.elm-ssr/Main.elm` (router) and the islands manifest for all configured apps, syncs the Elm authoring modules into `.elm-ssr/src/ElmSsr/`, and compiles pages and island bundles.
33
+
34
+ ### `compress`
35
+ Runs the `build` pipeline and additionally pre-compresses generated JS/CSS assets with Gzip for faster delivery on edge networks.
36
+
37
+ ### `dev`
38
+ Starts the local development loop. Compiles the Elm code and runs `wrangler dev` (monitoring `.elm` and `.css` files for hot-reloads).
39
+
40
+ ### `init <name> [--db] [--auth betterAuth|auth0]`
41
+ Initialises a self-contained, single-app project in the current directory.
42
+ - `--db`: Configures local SQLite database support (generates initial migration and configures `inMemoryEffects`).
43
+ - `--auth <betterAuth|auth0>`: Scaffolds basic route modules (`Login.elm`, `Profile.elm`), signed cookie/CSRF middleware, and callback intercepts. (Automatically implies `--db`).
44
+
45
+ ### `new <name> [--in <subdir>] [--db] [--auth betterAuth|auth0]`
46
+ Creates a new app under `<workspace>/<name>/` (or `<workspace>/<subdir>/<name>/` if `--in <subdir>` is provided) and registers it in `elm-ssr.config.json`.
47
+ - `--in <subdir>`: Target subdirectory group (e.g. `--in apps` places it under `apps/<name>/`).
48
+ - `--db`: Configures SQLite database support and an initial migration.
49
+ - `--auth <betterAuth|auth0>`: Scaffolds authentication views, cookies, and callback handlers.
50
+
51
+ ### `route <path> [--app <name>] [--api] [--ws] [--sse]`
52
+ Scaffolds a new route or endpoint:
53
+ - `--app <app-name>`: Required if multiple apps are configured in the workspace.
54
+ - `--api`: Scaffolds a JSON API page/action route instead of an HTML page.
55
+ - `--ws` or `--websocket`: Scaffolds a TypeScript WebSocket handler in `src/Endpoints/<route>.ts`.
56
+ - `--sse`: Scaffolds a TypeScript Server-Sent Events (SSE) stream handler in `src/Endpoints/<route>.ts`.
57
+
58
+ ### `query [--app <name>] [--dir <path>] [--output <path>]`
59
+ Generates type-safe Elm database schema and query helpers directly from raw SQL files in the migrations directory.
60
+ - `--app <app-name>`: Required if multiple apps exist.
61
+ - `--dir <path>`: Directory containing migrations (default: `<app_root>/migrations`).
62
+ - `--output <path>`: Directory where Elm Db modules will be generated (default: `<app_root>/src/<Module>/Db`).
63
+
64
+ ### `migrate <up|down|status> [--db <conn>] [--dir <path>] [--count <n>] [--table <name>]`
65
+ SQL migration runner.
66
+ - `up`: Applies all pending migrations.
67
+ - `down`: Reverts the last migration (or `n` migrations via `--count`).
68
+ - `status`: Lists all applied and pending migrations.
69
+ - `--db <conn>`: Database connection string (Postgres URL, SQLite URL, or plain file path). Reads `DATABASE_URL` if omitted.
70
+ - `--dir <path>`: Path to the SQL migrations directory (default: `./migrations`).
71
+ - `--count <n>`: The number of migrations to revert when running `down` (default: 1).
72
+ - `--table <name>`: Tracking database table name (default: `__elm_ssr_migrations`).
73
+
74
+ ### `routes`
75
+ Prints a list of all configured apps, their root directories, and their route source directories.
76
+
77
+ ### `info`
78
+ Prints the workspace name and registered app names.
79
+
80
+ ## Global options
81
+ - `--root <path>`: Overrides where the CLI looks for `elm-ssr.config.json` (defaults to current directory).
44
82
 
45
83
  Configuration lives in `elm-ssr.config.json` at the repo root:
46
84
 
package/lib/scaffold.mjs CHANGED
@@ -341,9 +341,10 @@ userDecoder =
341
341
  (Decode.maybe (Decode.field "name" Decode.string))
342
342
 
343
343
  page : Request -> Loader (Document Never)
344
- page request =
345
- Loader.requireUser userDecoder "/login" request
346
- |> Loader.map view
344
+ page _ =
345
+ Loader.requireUser userDecoder "/login" (\\user ->
346
+ Loader.succeed (view user)
347
+ )
347
348
 
348
349
  action : Request -> Action (Document Never)
349
350
  action _ =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elm-ssr",
3
- "version": "0.91.0",
3
+ "version": "0.91.1",
4
4
  "description": "Elm-first SSR library and framework for Cloudflare Workers (and Bun): file-based routes/islands, backend-neutral effect adapters (KV/D1/Redis/Postgres), background tasks (waitUntil/Queues), SQL-file migrations, CLI scaffold + build.",
5
5
  "license": "MIT",
6
6
  "author": "Michał Majchrzak <michmajchrzak@gmail.com>",