Skip to content

digitalocean/sample-functions-typescript-helloworld

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample Function: TypeScript "Hello World"

Introduction

This repository contains a sample "Hello World" function written in TypeScript. You can deploy it on DigitalOcean's App Platform as a Serverless Function component or as a standalone Function. Documentation is available at https://docs.digitalocean.com/products/functions.

Requirements

Deploying the Function

# clone this repo
git clone git@github.com:digitalocean/sample-functions-typescript-helloworld.git
# deploy the project, using a remote build so that compiled executable matched runtime environment
> doctl serverless deploy sample-functions-typescript-helloworld --remote-build
Deploying 'sample-functions-typescript-helloworld'
  to namespace 'fn-...'
  on host 'https://faas-...'
Submitted action 'hello' for remote building and deployment in runtime typescript:default (id: ...)

Deployed functions ('doctl sls fn get <funcName> --url' for URL):
  - sample/hello

Using the Function

doctl CLI

doctl serverless functions invoke sample/hello
{
  "body": "Hello stranger!"
}

doctl CLI with a request Body

doctl serverless functions invoke sample/hello -p name:Sammy
{
  "body": "Hello Sammy!"
}

curl

curl $(doctl sls fn get sample/hello --url)
Hello stranger!

💡 The output above is not in json format because it's performing an HTTP get directly and the body of the function does not return a json object, but a plain string.

Learn More

You can learn more about Functions and App Platform integration in the official App Platform Documentation.

About

No description, website, or topics provided.

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •