Deno Functions Framework

Deno Functions Framework

A lightweight, open source FaaS (Function as a Service) framework for Deno.

Deno Functions Framework

WARNING: WIP

A lightweight, open source FaaS (Function as a Service) framework for Deno.

The framework allows you to go from:

/**
 * Send "Hello, World!"
 * @param request The Deno request https://deno.land/[email protected]/http/server.ts
 */
export default async (request) => {
  request.respond({
    status: 200,
    body: 'Hello, World!',
  });
};

To:

curl http://my-url
# Output: Hello, World!

All without needing to worry about writing an HTTP server or complicated request handling logic.

Features

  • Spin up a local development server for quick testing
  • Invoke a function in response to a request
  • Automatically unmarshal events conforming to the CloudEvents spec
  • Portable between serverless platforms

Installation

There's no installation step for this library. It's Deno.

Quickstart

Assumes you have Deno installed

  1. Create an main.ts file with the following contents:

    export default async (request) => {
      request.respond({
        status: 200,
        body: 'Hello, World!',
      });
    };
  2. Start the local server:

    deno run --allow-net --allow-read --allow-env main.ts
  3. Send requests to this function using curl from another terminal window:

    curl localhost:8080
    Output: Hello, World!

Run in Container

You can also run this server in a container:

docker run -it --init \
-p 8080:8080 \
-v $PWD:/app hayd/alpine-deno:1.4.4 \
run --allow-net --allow-read --allow-env /app/main.ts

Deploy to Cloud Run

Currently doesn't work due to a gvizor issue.

PROJECT=$(gcloud config get-value core/project 2> /dev/null)
gcloud builds submit --tag gcr.io/$PROJECT/deno-ff
gcloud run deploy deno-ff \
--image gcr.io/$PROJECT/deno-ff \
--allow-unauthenticated

Current error:

Gvizor: Container Sandbox: Unsupported syscall setsockopt

Publish

TODO: Publish this to a separate repo:

https://dev.to/craigmorten/how-to-publish-deno-modules-2cg6

Download Details:

Author: grant

Source Code: https://github.com/grant/functions-framework-deno

deno node nodejs javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

AEM Querybuilder for JavaScript (Browser, Node, Deno)

Helix Querybuilder .AEM Querybuilder for JavaScript (Browser, Node, Deno)

NKeys for JavaScript - Node.js, Browsers, and Deno

A public-key signature system based on Ed25519 for the NATS ecosystem system for JavaScript. The nkeys.js library works in Deno, Node.js, and the browser!

Javascript module for easily generating mazes,compatible with both Deno and Node

A work-in-progress Javascript maze generator module, compatible with both Deno and Node.

Deno Tutorial for Beginners: Deno vs. Node: Better Than NodeJS?

Deno is released, it’s time to find out if it can prove a worthy competition for Node.js. What is Deno? Why Deno can be considered an alternative to Node? The main differences between Deno and Node. Write a simple Deno app.

What is Deno? The Node.JS Killer? The Deno-minator to Node?

What is Deno? The Node.JS Killer? The Deno-minator to Node? Deno is the new hype and will it be better than node.js? Deno is a secure runtime for JavaScript and TypeScript that is based on the V8 JavaScript engine and the Rust programming language that addresses Node’s shortcomings