Skip to content

grant/functions-framework-deno

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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/std@0.74.0/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 build -t app . && docker run -it --init -p 8080:8080 app

Deploy to Cloud Run

gcloud beta run deploy deno-ff \
--source . \
--allow-unauthenticated

Publish

TODO: Publish this to a separate repo:

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

About

An experimental Functions Framework for Deno

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published