Skip to content

Latest commit

 

History

History
50 lines (37 loc) · 964 Bytes

gcloud_functions.md

File metadata and controls

50 lines (37 loc) · 964 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 AWS Lambda is the following:

package.json:

{
    "type": "module",
    "scripts": {
        "start": "functions-framework --target=hello"
    },
    "main": "index.mjs",
    "dependencies": {
        "nbb": "0.2.8",
        "@google-cloud/functions-framework": "~1.9.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"))

#js {:hello hello}

Then deploy the function with:

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

Also see Nbb on AWS Lambda.