FaasJS

FaasJS

An atomic FaaS Application Framework based on Typescript & Node.js

Features

High development efficiency

The atomized development model can reduce development and iteration to a featherweight level and is more friendly to team development.

FaasJS officially provides plugins such as HTTP, Knex, etc., so that developers can start developing business immediately.

High maintainability

The FaaS architecture guarantees the independence between cloud functions and prevents a single error from causing the failure of the entire system.

FaasJS has built-in automated testing tools to facilitate developers to automate the testing of cloud functions.

High scalability

FaasJS has a simple and easy-to-use plug-in mechanism that allows developers to extend functions and plugins freely.

Example

Cloud function's file

// index.func.ts
// all cloud function file should be ended with .func.ts
import { useFunc } from '@faasjs/func'
import { useHttp } from '@faasjs/http'

export default useFunc(function() {
  useHttp() // use http plugin

  return async function () {
    return 'Hello, world' // response content
  }
})
1
2
3
4
5
6
7
8
9
10
11
12

Unit test's file

// __tests__/index.test.ts
// all unit test file should be ended with .test.ts
import { FuncWarper } from '@faasjs/test'
import Func from '../index.func'

describe('index', function () {
  test('should work', async function () {
    // wrap the cloud function
    const func = new FuncWarper(Func);

    // mock the request
    const { statusCode, data } = await func.JSONhandler()

    // expect the response with 200 status
    expect(statusCode).toEqual(200)
    // expect the response content is 'Hello, world'
    expect(data).toEqual('Hello, world')
  });
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

Get Started

npx create-faas-app --name faasjs --example --noprovider
1




Thanks

Code contributors (in alphabetical order):

luckyporo, onichandame, Vibutnum, victoryifei, zfben

FaasJS is based on the following open source projects (in alphabetical order):

Apollo, Babel, ESLint, Jest, Knex, Node.js, Rollup.js, TypeScript, VuePress