FaasJS
Home
  • Guide
  • Documents
  • Templates
  • Changelog
  • Ecosystem

    • Docker Images
  • Github
  • Contributing
  • Sponsor
  • Security
Home
  • Guide
  • Documents
  • Templates
  • Changelog
  • Ecosystem

    • Docker Images
  • Github
  • Contributing
  • Sponsor
  • Security

Documents / @faasjs/dev

@faasjs/dev

@faasjs/dev

FaasJS development toolkit for local servers, generated route types, and test helpers.

License: MIT NPM Version

Install

npm install -D @faasjs/dev

Features

  • viteFaasJsServer() runs a FaasJS server inside Vite during local development.
  • ViteConfig bundles the standard FaasJS React and Vite Plus defaults.
  • OxfmtConfig and OxlintConfig expose the shared FaasJS formatting and lint rules.
  • generateFaasTypes() emits route declarations for @faasjs/types.
  • testApi() and ApiTester help invoke and assert FaasJS APIs in tests.

Usage: Shared Vite Preset

import { ViteConfig } from '@faasjs/dev'
import { defineConfig } from 'vite-plus'

export default defineConfig({
  ...ViteConfig,
})

Usage: Manual Vite Integration

import { viteFaasJsServer, OxfmtConfig, OxlintConfig } from '@faasjs/dev'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite-plus'

export default defineConfig({
  plugins: [react(), viteFaasJsServer()],
  fmt: OxfmtConfig,
  lint: OxlintConfig,
})

Usage: Type Generation

import { generateFaasTypes } from '@faasjs/dev'

await generateFaasTypes()

Usage: Test Helpers

import { testApi } from '@faasjs/dev'
import api from '../demo.api'

const handler = testApi(api)
const response = await handler({ name: 'FaasJS' })

expect(response.statusCode).toBe(200)
expect(response.data).toEqual({ message: 'Hello, FaasJS' })

API

  • Vite: viteFaasJsServer
  • Config: ViteConfig, OxfmtConfig, OxlintConfig
  • Typegen: generateFaasTypes, isTypegenInputFile
  • Test: testApi, ApiTester

Functions

  • closeAll
  • defineApi
  • generateFaasTypes
  • getAll
  • isTypegenInputFile
  • nameFunc
  • parseApiFilenameFromStack
  • staticHandler
  • testApi
  • useMiddleware
  • useMiddlewares
  • viteFaasJsServer

Classes

  • ApiTester
  • Cookie
  • Func
  • Http
  • HttpError
  • Server
  • Session

Interfaces

  • DefineApiInject

Type Aliases

  • Config
  • CookieOptions
  • DefineApiData
  • ExportedHandler
  • FuncConfig
  • FuncEventType
  • FuncReturnType
  • FuncRuntime
  • GenerateFaasTypesOptions
  • GenerateFaasTypesResult
  • Handler
  • HttpConfig
  • HttpResponseBody
  • HttpSetBody
  • HttpSetContentType
  • HttpSetHeader
  • HttpSetStatusCode
  • InvokeData
  • JsonHandlerBody
  • JsonHandlerOptions
  • JsonHandlerResult
  • LifecycleKey
  • Middleware
  • MiddlewareContext
  • MiddlewareEvent
  • MountData
  • Next
  • Plugin
  • Response
  • RuntimeContext
  • ServerHandlerOptions
  • ServerOptions
  • SessionContent
  • SessionOptions
  • StaticHandlerOptions
  • TestApiHandler

Variables

  • ContentType
  • OxfmtConfig
  • OxlintConfig
  • ViteConfig