{"id":16592576,"url":"https://github.com/unisay/purescript-lua-example","last_synced_at":"2025-10-13T06:35:03.582Z","repository":{"id":166319071,"uuid":"612629748","full_name":"Unisay/purescript-lua-example","owner":"Unisay","description":"Example project to demonstrate usage of the purescript-lua compiler backend","archived":false,"fork":false,"pushed_at":"2024-04-21T14:16:53.000Z","size":135,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-07T18:40:47.170Z","etag":null,"topics":["lua","nginx","purescript"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Unisay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-03-11T14:17:55.000Z","updated_at":"2024-04-21T14:16:56.000Z","dependencies_parsed_at":"2024-04-21T15:59:43.429Z","dependency_job_id":null,"html_url":"https://github.com/Unisay/purescript-lua-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Unisay/purescript-lua-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Unisay%2Fpurescript-lua-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Unisay%2Fpurescript-lua-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Unisay%2Fpurescript-lua-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Unisay%2Fpurescript-lua-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Unisay","download_url":"https://codeload.github.com/Unisay/purescript-lua-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Unisay%2Fpurescript-lua-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279013970,"owners_count":26085429,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lua","nginx","purescript"],"created_at":"2024-10-11T23:21:24.595Z","updated_at":"2025-10-13T06:35:03.553Z","avatar_url":"https://github.com/Unisay.png","language":"Lua","readme":"# Example project for the purescript-lua\n\nThis project exists to demonstrate usage of the [PureScript compiler backend for Lua](https://github.com/Unisay/purescript-lua).\n\nOne possible usage of Lua scripts is within the [NGINX](https://www.nginx.com/resources/wiki/modules/lua/)\nserver, one can implement a backend application serving HTTP requests.\n\n## How to build / use\n\nThe project relies on `nix` to build dependencies.\n\n1. Initialize nix shell:\n\n   - Using `direnv`: `direnv allow`.\n   - Using `nix develop` command.\n\n1. Nix shell makes 2 executable `./scripts` available on your path:\n\n   - `serve` - starts Nginx and binds http://localhost:58080\n   - `build` - compile PureScript sources to `web/main.lua`\n\n1. Open one terminal for building, then execute:\n\n```sh\n$ build\nBuilding...\nPS Lua: compiling ...\nWrote linked modules to /home/yura/projects/purescript/purescript-lua/example/web/main.lua\n```\n\n1. Open other terminal for serving content with Nginx, run:\n\n```sh\n$ serve\nNGINX: Listening on port 58080\nnginx: [alert] lua_code_cache is off; this will hurt performance in web/conf/nginx.conf:13\n2023/07/05 12:30:12 [notice] 1859398#1859398: using the \"epoll\" event method\n2023/07/05 12:30:12 [notice] 1859398#1859398: openresty/1.21.4.1\n2023/07/05 12:30:12 [notice] 1859398#1859398: built by gcc 12.3.0 (GCC)\n2023/07/05 12:30:12 [notice] 1859398#1859398: OS: Linux 6.1.34\n2023/07/05 12:30:12 [notice] 1859398#1859398: getrlimit(RLIMIT_NOFILE): 524288:524288\n2023/07/05 12:30:12 [notice] 1859398#1859398: start worker processes\n2023/07/05 12:30:12 [notice] 1859398#1859398: start worker process 1859399\n```\n\n`lua_code_cache is off` alert means that nginx isn't going to cache the lua script,\nbut instead will re-read it from disk upon every HTTP request, which is exactly\nwhat we want in the development mode: it allows to re-build PS sources in the first\nterminal and not to restart nginx in order to see the changes.\n\n1. Open browser and navigate to http://localhost:58080\nor use `httpie`:\n\n```sh\nhttp :58080\nHTTP/1.1 200 OK\nConnection: keep-alive\nContent-Type: text/html\nDate: Tue, 16 Apr 2024 07:58:23 GMT\nServer: openresty/1.21.4.3\nTransfer-Encoding: chunked\n\nHello from \"PureScript/Lua\"!\n```\n\n## How to run a compiled script\n\n```sh\nlua -e 'dofile(\"web/main.lua\")'\n```\n\nbut it will fail when using Nginx as there is no global variable `ngx` which\nis only defined when script is executed by nginx:\n\n```\nlua: web/main.lua:208: attempt to index a nil value (global 'ngx')\nstack traceback:\n        web/main.lua:208: in function \u003cweb/main.lua:206\u003e\n        web/main.lua:206: in main chunk\n        [C]: in function 'dofile'\n        (command line):1: in main chunk\n        [C]: in ?\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funisay%2Fpurescript-lua-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funisay%2Fpurescript-lua-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funisay%2Fpurescript-lua-example/lists"}