Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 986 Bytes

gcloud_functions.md

File metadata and controls

51 lines (38 loc) · 986 Bytes

Nbb on Google Cloud Functions

This article is based on this gist by Jack Rusher. Thanks Jack!

Creating an nbb google cloud function

All you need to do to get nbb running on GCP Cloud Functions is the following:

package.json:

{
    "type": "module",
    "scripts": {
        "start": "functions-framework --target=hello"
    },
    "main": "index.mjs",
    "dependencies": {
        "nbb": "~1.2.174",
        "@google-cloud/functions-framework": "~3.2.0"
    }
}

index.mjs:

import { loadFile } from 'nbb';

const { hello } = await loadFile('./hello.cljs');

export { hello }

hello.cljs:

(ns hello)

(defn hello [req res]
  (js/console.log req)
  (.send res "hello world"))

;; export
#js {:hello hello}

Then deploy the function with:

$ gcloud functions deploy hello --runtime nodejs20 --trigger-http

Also see Nbb on AWS Lambda.