Skip to content

Knative func example created with [kn] func create -l typescript -t cloudevents

Notifications You must be signed in to change notification settings

openshift-dev-console/kn-func-typescript-cloudevents

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypeScript CloudEvent Function

Welcome to your new TypeScript function project! The boilerplate function code can be found in index.ts. This function is meant to respond exclusively to Cloud Events, but you can remove the check for this in the function and it will respond just fine to plain vanilla incoming HTTP requests.

Local execution

To run locally

npm install
npm run build
npm run local

The runtime will expose three endpoints.

  • / The endpoint for your function.
  • /health/readiness The endpoint for a readiness health check
  • /health/liveness The endpoint for a liveness health check

The health checks can be accessed in your browser at http://localhost:8080/health/readiness and http://localhost:8080/health/liveness. You can use curl to POST an event to the function endpoint:

curl -X POST -d '{"name": "Tiger", "customerId": "0123456789"}' \
  -H'Content-type: application/json' \
  -H'Ce-id: 1' \
  -H'Ce-source: cloud-event-example' \
  -H'Ce-type: dev.knative.example' \
  -H'Ce-specversion: 1.0' \
  http://localhost:8080

The readiness and liveness endpoints use overload-protection and will respond with HTTP 503 Service Unavailable with a Client-Retry header if your function is determined to be overloaded, based on the memory usage and event loop delay.

Testing

This function project includes a unit test and an integration test. Modify these, or add additional tests for your business logic.

npm test

About

Knative func example created with [kn] func create -l typescript -t cloudevents

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published