FaasJS
Home
  • Guide
  • Documents
  • Starter Template
  • Changelog
  • Ecosystem

    • VS Code Plugin
    • Docker Images
  • Github
  • Contributing
  • Sponsor
  • Security
  • English
  • 简体中文
Home
  • Guide
  • Documents
  • Starter Template
  • Changelog
  • Ecosystem

    • VS Code Plugin
    • Docker Images
  • Github
  • Contributing
  • Sponsor
  • Security
  • English
  • 简体中文

Documents / @faasjs/server

@faasjs/server

FaasJS's server module.

License: MITNPM Version

Install

# If you are using bun, tsx is not required.
npm install @faasjs/server tsx

Usage

  1. Create a server.ts file:
// server.ts
import { Server } from '@faasjs/server'

const server = new Server({
 // options
})

server.start()
  1. Run the server:
tsx server.ts // or `bun server.ts` if you are not using bun

Routing

Static routing:

  • / -> index.func.ts or index.func.tsx
  • /path -> path.func.ts or path.func.tsx or path/index.func.ts or path/index.func.tsx

Dynamic routing:

  • /* -> default.func.ts or default.func.tsx
  • /path/* -> path/default.func.ts or path/default.func.tsx

Functions

  • closeAll
  • getAll
  • staticHandler
  • useMiddleware
  • useMiddlewares

Classes

  • Server

Type Aliases

  • Middleware
  • MiddlewareContext
  • MiddlewareEvent
  • ServerHandlerOptions
  • ServerOptions
  • StaticHandlerOptions