Skip to content

sluongng/alicloud-fc-ts-template

Repository files navigation

alicloud-fc-ts-template

A template reposistory for Serverless project using Aliyun(AliCloud) Function Compute service.

This project is a Work In Progress(WIP) and changes as well as bugs are expected.

Please feel free to submit an issue or pull request where you deem fit.

Requirement

In this project, we operate under the following assumptions:

How to use

git clone https://github.com/sluongng/alicloud-fc-ts-template
  1. Update env-setup.sh with appropriate names so npm run <script-name> will work properly
  2. Development happen in ./src folder
  3. Compile codes to *.js with npm run build
  4. Test the function locally with npm test
  5. Create/Update the function using npm run func-create / npm run func-update commands
  6. Invoke the function online with npm run func-invoke
  7. (Assuming you have SLS setup for FC service) Check logs of function in the last 5 minutes using npm run func-logs
  8. Create/Update trigger with npm run trigger-create / npm run trigger-update
  9. Run whole live cycle with npm run all

Debugging

  • This repository also included ts-node and the launch.json configurations for debugging on VSCode.

  • TODO: Include Docker setup

Http Trigger

As noted in official documentation [CN] [EN], the Http Triggered function has different interface compare to normal event-based functions

function(request, response, context) {}

In this repository, I have also provided a working example via httpFunc.ts and neccessary models via httpModels.ts.

The example functionality here is based on the official example on Aliyun/AlibabaCloud website.

An example of httpTrigger.yml file is also included.

To Do

  • Provided basic setup of event driven function
  • Provided basic npm scripts to assit with building, testing and deploy code
  • Provided standard TypeScript Compiler and TSlint configurations
  • Provided simple VSCode launch.json configuration for debugging locally
  • Provided basic setup of http driven function
  • To provide setup/scripts for local docker testing with aliyun/fc-docker
  • To provide more event models for OSS, CDN and SLS based events
  • To provide more event models for Gateway, TableStore, IoT and DataHub based events
  • Reimplement models with toJSON() and fromJSON() so that it works better with JSON. More information here

About

Template for a simple Serverless project using Function Compute(FC) of Alicloud, using TypeScript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published