{"id":48951239,"url":"https://github.com/ccfontes/faas-bb","last_synced_at":"2026-04-17T20:32:59.378Z","repository":{"id":155503295,"uuid":"626607858","full_name":"ccfontes/faas-bb","owner":"ccfontes","description":"An OpenFaaS template for writing Functions in Babashka.","archived":false,"fork":false,"pushed_at":"2024-05-21T09:54:23.000Z","size":75,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-20T04:02:34.723Z","etag":null,"topics":["babashka","bb","clojure","openfaas"],"latest_commit_sha":null,"homepage":"","language":"Clojure","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/ccfontes.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-04-11T20:08:52.000Z","updated_at":"2024-05-21T09:54:26.000Z","dependencies_parsed_at":"2023-12-20T12:51:40.056Z","dependency_job_id":"5a7c2a51-ea9f-403b-9313-93cb1bf3755a","html_url":"https://github.com/ccfontes/faas-bb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ccfontes/faas-bb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccfontes%2Ffaas-bb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccfontes%2Ffaas-bb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccfontes%2Ffaas-bb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccfontes%2Ffaas-bb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ccfontes","download_url":"https://codeload.github.com/ccfontes/faas-bb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccfontes%2Ffaas-bb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31945090,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T17:29:20.459Z","status":"ssl_error","status_checked_at":"2026-04-17T17:28:47.801Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["babashka","bb","clojure","openfaas"],"created_at":"2026-04-17T20:32:55.942Z","updated_at":"2026-04-17T20:32:59.369Z","avatar_url":"https://github.com/ccfontes.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":":url-proj: https://github.com/ccfontes/faas-bb\n:img-ci-tests-status: {url-proj}/actions/workflows/faas_fn_build_invoke.yml/badge.svg\n:img-ci-hadolint-status: {url-proj}/actions/workflows/hadolint.yml/badge.svg\n:img-ci-clj-kondo-status: {url-proj}/actions/workflows/clj-kondo.yml/badge.svg\n:url-ci-status-tests: \"{url-proj}/actions/workflows/faas_fn_build_invoke.yml\"\n:url-ci-status-hadolint: \"{url-proj}/actions/workflows/hadolint.yml\"\n:url-ci-status-clj-kondo: \"{url-proj}/actions/workflows/clj-kondo.yml\"\n:img-license: https://img.shields.io/badge/license-MIT-black.svg\n\n= faas-bb image:{img-ci-tests-status}[link={url-ci-status-tests}] image:{img-ci-hadolint-status}[link={url-ci-status-hadolint}] image:{img-ci-clj-kondo-status}[link={url-ci-status-clj-kondo}] image:{img-license}[link=LICENSE]\n\nAn https://github.com/openfaas[OpenFaaS] template for writing Functions in https://babashka.org[Babashka] (v1.3.187 SNAPSHOT).\n\n== Why\n\n\u003e The ergonomics of Babashka, combined with the simplicity of Clojure, make it a great choice for writing Functions in OpenFaaS, from single purpose Functions, to frontend facing REST APIs, to serving hiccup backed HTML pages - delivered with a back-to-back joyful development experience.\n\nBabashka is designed for minimal memory usage, allowing you to scale up your narrow-purposed Functions with comparable RAM consumption.\n\nBabashka scripts run immediately, ensuring:\n\n* that Function cold start times are kept to a minimum.\n* a rapid development feedback loop.\n* a simple REPL workflow - just start everything all over again, it's fast.\n\n== Prerequisites\n\n* https://docs.openfaas.com/cli/install/[OpenFaaS CLI]: makes the `faas-cli` command available.\n\n*Optional for REPL support*\n\n* https://github.com/babashka/babashka#installation[Babashka]: makes the `bb` command available.\n* rlwrap: readline support, here for Babashka REPL.\n\n== Usage\n\n=== Pull OpenFaaS template\n\nTo create Babashka Functions with this template, use the following command *once*:\n[source, bash]\n----\nfaas-cli template pull https://github.com/ccfontes/faas-bb\n----\nIf you ever need to update the template, simply run the command above with the `--overwrite` flag.\n\n=== Create a Babashka Function\n\nCreate Babashka Functions as with the following command example:\n[source, bash]\n----\nfaas-cli new --lang bb my-bb-function\n----\nA new project is created for a function defined as `my-bb-function`. It will contain:\n\n* a `handler` namespace that is required for the template to work properly. This namespace needs to have a top-level `handler` function with 0 or 1 arguments.\n* a `bb.edn` file where ship dependencies can be added. Remove this file if you don't need to add any dependencies or run a REPL without passing the classpath explicitly.\n* a `test` directory containing:\n** `run_tests.clj` with the namespace that will be used to run the tests. You can use any test library and test runner you like.\n** a `bb.edn` file where test dependencies can be added. Remove this file if you don't need to add any dependencies.\n\n=== Defining Function handler\n\nIn `bb` language:\n[source, clojure]\n----\n(defn handler [{:keys [headers body context] :as event}]\n  ...)\n----\n`event` is a map containing `:headers`, `:body` and `:context` keys.\n\n`:headers` contains headers, as such:\n[source, clojure]\n----\n{:content-type \"application/json\"}\n----\n\n`:body` is the payload body. When passing a JSON object payload and using `bb` language, the payload will be automatically parsed as a Clojure map with keyword keys. There are cases where it's preferable to have string keys in the payload body, and it's possible to support them by setting `keywords: false` in the Function in `stack.yml`:\n[source, yml]\n----\nmy-function:\n  lang: bb\n  handler: ./anything/my-function\n  image: ${DOCKER_REGISTRY_IMG_ORG_PATH}/my-function\n  environment:\n    keywords: false\n----\n\n`:context` contains environment variables. Additional environment variables can be defined in the `stack.yml` file, as such:\n[source, yml]\n----\nmy-function:\n  lang: bb\n  handler: ./anything/my-function\n  image: ${DOCKER_REGISTRY_IMG_ORG_PATH}/my-function\n  environment:\n    MY_ENV1: foo\n    MY_ENV2: 2\n----\n`:context` will contain:\n[source, clojure]\n----\n {:my-env1 \"foo\"\n  :my-env2 2}\n----\n\nIf you declare secrets in the `stack.yml` file, these will be available in `:context` map as well. Let's start with an example:\n[source, yml]\n----\nmy-function:\n  lang: bb\n  handler: ./anything/my-function\n  image: ${DOCKER_REGISTRY_IMG_ORG_PATH}/my-function\n  secrets:\n    - foo\n    - baz\n----\nA secret value that is an EDN string, when internally parsed as a Clojure map, will have its content spliced into the `:context` map. Otherwise, the secret will be available in the `:context` map as `{:secret-name \u003csecret-value\u003e}`, with `\u003csecret-value\u003e` parsed as a Clojure data structure other than a map.\n\nFollowing up from the definition of `my-function` above, we define the following secrets:\n[source, bash]\n----\necho 'bar' | faas-cli secret create foo\necho '{:spam \"eggs\"}' | faas-cli secret create baz\n----\nbecomes this in the `:context` map:\n[source, clojure]\n----\n{:foo \"bar\" :spam \"eggs\"}\n----\n\n=== Function tests\n\nTests for your Function run when you build the Function image (`faas-cli build`).\n\nA `test` directory in the Function's top-level directory is provided, containing:\n\n* `run_tests.clj`, with the namespace that will be used to run the tests. You can use any test library and test runner you like.\n* a `bb.edn` file where test dependencies can be added. Remove this file if you don't need to add any dependencies.\n\nTo disable running existing tests, set the `TEST` build time argument to `false`:\n[source, yml]\n----\nmy-function:\n  lang: bb\n  handler: ./anything/my-function\n  image: ${DOCKER_REGISTRY_IMG_ORG_PATH}/my-function\n   build_args:\n      TEST: false\n----\n\nIf you don't plan on testing, you can remove the `test` directory altogether.\n\nExisting test files are removed from the final Docker image used to run the Function in OpenFaaS.\n\n=== Spin up a REPL\n\nSpin up a REPL in the context of your Function project.\n\nNOTE: You'll need to have https://github.com/babashka/babashka#installation[Babashka installed] in your local.\n\nIn the root directory of your Function run:\n[source, bash]\n----\nrlwrap bb\n----\n\nSpins up a REPL with readline support.\n\nIf you remove `bb.edn` with just `{:paths [\".\"]}` in it, the Function will still work, but then you will need to explicitly pass the classpath when spinning up a REPL:\n\n[source, bash]\n----\nrlwrap bb -cp .\n----\n\n== link:examples[Function examples]\n\nSee the link:examples[examples] directory to find a fully working set of OpenFaaS Functions written in Babashka.\n\n== faas-bb tests\n\n=== CI tests\n\nAll tests run in CI with Github Actions. Some commands link:.github/workflows/faas_fn_build_invoke.yml[can be found in a Github Actions workflow] to help you with testing your changes before pushing them to a topic branch.\n\n=== Unit tests\n\nRun locally the unit tests for the `bb` template.\n\nThe requirement is that babashka (`bb`) is https://github.com/babashka/babashka#installation[installed].\n\n[source, bash]\n----\ncd template/bb\nbb --config tests.edn tests.clj\n----\n`tests.clj` is included with the template so you can test any changes you make to the template before using it.\n\n== Projects using faas-bb\n\n- https://www.mailbriefly.com[MailBriefly.com] is using `faas-bb` on all its microservices (with joy).\n\n== Contributing\n\nContributions are welcome! If you find a bug or have an idea for a new feature, please open an issue or submit a pull request.\n\nThe template may benefit from some common middleware functions, such as those offered in the https://github.com/ring-clojure/ring-defaults/blob/master/src/ring/middleware/defaults.clj[ring-defaults library]. Users are welcome to recommend integrating any middleware they think would be useful for handling common web application needs.\n\n== Third party code\n\nThe following files are derived from https://github.com/ring-clojure[ring] to work with Babashka, originally authored by James Reeves and contributors, and used under the MIT license: link:template/bb/lib/ring/middleware/json.clj[ring.middleware.json], link:template/bb/lib/ring/util/io.clj[ring.util.io], link:template/bb/lib/ring/util/mime_type.clj[ring.util.mime-type], link:template/bb/lib/ring/util/parsing.clj[ring.util.parsing], link:template/bb/lib/ring/util/response.clj[ring.util.response], link:template/bb/lib/ring/util/time.clj[ring.util.time].\n\n== link:LICENSE[License]\n\nCopyright (c) 2023 Carlos da Cunha Fontes.\n\nThis project is licensed under the MIT License. See link:LICENSE[LICENSE] for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccfontes%2Ffaas-bb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fccfontes%2Ffaas-bb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccfontes%2Ffaas-bb/lists"}