Skip to content

faasjs/faasjs

Repository files navigation

🚀 FaasJS

Documentation - Discord - Changelog - Contributing

License: MIT NPM Version Last commit Unit Status Lint Status

Maintainability Coverage Status Commits Downloads Pull requests

faasjs/nginx faasjs/vscode faasjs/node faasjs/bun

An Atomic Application Framework based on Typescript.

基于 Typescript 的原子化应用框架。

Features

Featherweight Development & Collaboration

  • Break down complex projects into manageable components with the atomized development model.
  • Enjoy fast iterations and seamless team collaboration.
  • Jumpstart development with pre-built plugins for common functionalities like HTTP and Knex.

High maintainability

  • The FaaS architecture ensures isolated cloud functions, preventing domino-effect errors.
  • Automated testing tools built-in for robust and efficient testing.

High scalability

  • Extend your application effortlessly with flexible and simple plugin mechanisms.
  • Freely scale your functions up or down based on demand.

Quick start

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

Playground

Fork and open in codespace or your computer.

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
  }
})

Unit test's file

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

describe('index', function () {
  it('should work', async function () {
    // wrap the cloud function
    const func = test(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')
  })
})

FOSSA Status