{"id":20753581,"url":"https://github.com/vharmain/nbb-lambda-adapter","last_synced_at":"2026-03-15T08:10:16.567Z","repository":{"id":57309187,"uuid":"423116367","full_name":"vharmain/nbb-lambda-adapter","owner":"vharmain","description":"NPM package to enable running Clojurescript code on AWS Lambda NodeJS runtime","archived":false,"fork":false,"pushed_at":"2022-01-08T19:51:57.000Z","size":23,"stargazers_count":24,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-19T00:05:14.433Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vharmain.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-31T10:30:01.000Z","updated_at":"2023-06-12T02:29:55.000Z","dependencies_parsed_at":"2022-09-07T03:10:24.132Z","dependency_job_id":null,"html_url":"https://github.com/vharmain/nbb-lambda-adapter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vharmain%2Fnbb-lambda-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vharmain%2Fnbb-lambda-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vharmain%2Fnbb-lambda-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vharmain%2Fnbb-lambda-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vharmain","download_url":"https://codeload.github.com/vharmain/nbb-lambda-adapter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251344391,"owners_count":21574531,"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","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":[],"created_at":"2024-11-17T09:14:14.762Z","updated_at":"2026-03-15T08:10:11.549Z","avatar_url":"https://github.com/vharmain.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# THIS MODULE IS NO MORE NECESSARY\n\nAs of 6.1.2022 AWS Lambda [NodeJS 14.x Runtime supports top-level await for es-modules](https://aws.amazon.com/about-aws/whats-new/2022/01/aws-lambda-es-modules-top-level-await-node-js-14/). It's now possible to just let `nbb` to load cljs code on the top-level without the adapter.\n\n## Example `index.mjs`\n\n```\nimport { loadFile } from 'nbb';\n\nconst { handler } = await loadFile('./example.cljs');\n\nexport { handler }\n```\n\nSee also https://github.com/vharmain/nbb-serverless-example\n\n----------------------\n\n# Old README\n\n# nbb-lambda-adapter\n\n[NPM package](https://www.npmjs.com/package/nbb-lambda-adapter) to enable running Clojurescript code on AWS Lambda NodeJS runtime using [nbb](https://github.com/babashka/nbb).\n\nMajor benefit with this library is rapid Lambda development directly in the Lambda Console. There's no need to compile CLJS to JS so the feedback loop is very quick.\n\nThis approach is also compatible with all existing tooling for `node`. Use CDK, SAM, Serverless or whatever build/deployment tool.\n\n## index.js\n\n```javascript\nconst handlerProxy = require(\"nbb-lambda-adapter\");\n\nmodule.exports = {\n  handler: handlerProxy(\"demo.cljs\", \"handler\"),\n};\n```\n\n## demo.cljs\n\n```clojure\n(ns demo)\n\n(defn handler [event _ctx]\n  (js/console.log event)\n  (js/Promise.resolve #js{:hello \"world\"}))\n\n;; Exports\n#js {:handler handler}\n```\n\n## Setup\n\n* `npm init`\n* `npm install --save nbb-lambda-adapter`\n* Create index.js according to example above\n* Create demo.cljs according to example above\n* `zip -r app.zip .`\n* Go to AWS Console -\u003e Lambda -\u003e Author from Scratch -\u003e Runtime Node.s 14.x + arm64, configure with 512mb or more (for fast startup)\n*  Upload `app.zip` to your Lambda, test and start hacking in the inline code editor\n\n## Tips \u0026 tricks\n\n* nbb loads slowly with 128MB of memory. Increase the timeout or add more memory. Startup will speed up significantly when more memory is added because Lambda gets also more CPU power with the extra memory.\n* ARM64 architecture provides cost and speed benefits over x86\n* `aws-sdk` is available on the NodeJS runtime and it can be required `(require '[\"aws-sdk$default\" :as AWS])`\n\n## AWS SDK example\n\n```clojure\n(ns example\n    (:require [\"aws-sdk$default\" :as AWS]))\n\n(def s3-client (AWS/S3.))\n\n(defn handler [event _ctx]\n  (-\u003e s3-client\n      (.listObjects #js{:Bucket \"nbb-adapter-test\"})\n      .promise\n      (.then js/console.log)))\n\n;; Exports\n#js {:handler handler}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvharmain%2Fnbb-lambda-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvharmain%2Fnbb-lambda-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvharmain%2Fnbb-lambda-adapter/lists"}