feat: scripts/run + README run instructions for the OpenResty demo by Unisay · Pull Request #6 · purescript-lua/purescript-lua-ngx · GitHub
Skip to content

feat: scripts/run + README run instructions for the OpenResty demo#6

Merged
Unisay merged 3 commits into
mainfrom
feat/run-script
Jun 24, 2026
Merged

feat: scripts/run + README run instructions for the OpenResty demo#6
Unisay merged 3 commits into
mainfrom
feat/run-script

Conversation

@Unisay

@Unisay Unisay commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Adds a way to actually run the compiled bindings, plus the docs to go with it.

The Lua.Ngx bindings wrap the ngx.* API that the lua-nginx-module injects, so they only work inside an OpenResty worker. Until now there was no way to exercise them short of hand writing an nginx config. This adds scripts/run, which generates a minimal config and serves the dist modules under OpenResty so you can curl them, mirroring how scripts/build produces them.

Changes:

  • flake.nix: add openresty to the dev shell, so nix develop -c ./scripts/run has everything it needs, pinned by the flake like the rest of the toolchain.
  • scripts/run: write a throwaway nginx.conf and serve dist/*.lua via dofile, with /say and /status locations. PORT= overrides the listen port. It fails fast with a clear message if openresty is not on PATH (the common case being a direnv shell that predates this change), pointing at nix develop -c ./scripts/run or direnv reload.
  • README.md: document build, run, and how to consume a linked module from your own config (dofile by absolute path, curried Effect calling convention).
  • .gitignore: ignore the direnv cache.

Verified locally: nix develop -c ./scripts/run serves on :8099, curl /say returns the greeting, and curl /status shows the HTTP_OK constant (200) with ngx.status set to 404.

The compiled Lua.Ngx bindings wrap the ngx.* API the lua-nginx-module
injects, so they only run inside an OpenResty worker. scripts/run serves
the dist modules under OpenResty (locations /say and /status) so they can
be curled, mirroring scripts/build.

- flake.nix: add openresty to the dev shell so `nix develop -c ./scripts/run` works.
- scripts/run: generate a minimal nginx.conf and serve dist/*.lua via dofile.
- README.md: document build, run, and how to consume the bindings (dofile + curried Effect).
- .gitignore: ignore the direnv cache (.direnv/).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a first-class way to run and manually exercise the generated Lua.Ngx* Lua modules inside an OpenResty worker, along with documentation and Nix-shell support so contributors can curl a working demo without hand-writing an nginx config.

Changes:

  • Add scripts/run to generate a temporary nginx.conf and serve dist/*.lua via OpenResty with /say and /status endpoints.
  • Extend the dev shell (flake.nix) to include openresty so nix develop -c ./scripts/run works out of the box.
  • Document build/run usage and embedding the linked dist/*.lua modules in your own nginx config; ignore .direnv/.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
scripts/run New demo runner that launches OpenResty with a generated nginx config to execute dist/Lua.Ngx*.lua via dofile.
README.md Adds build/run instructions and explains how to load linked modules (literal-dot filenames) and call curried Effect thunks.
flake.nix Adds openresty to the dev shell toolchain for running the demo.
.gitignore Ignores .direnv/ artifacts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/run
Comment thread scripts/run
Comment thread scripts/run Outdated
Unisay added 2 commits June 24, 2026 14:33
- scripts/run — validate PORT is a 1..65535 integer before interpolating it into the config (#6 (comment))
- scripts/run — fail fast if either served dist module is missing, not just Lua.Ngx.lua (#6 (comment))
@Unisay Unisay merged commit d94ce05 into main Jun 24, 2026
1 check passed
@Unisay Unisay deleted the feat/run-script branch June 24, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants