Papupata Documentation

API Reference

class DeclaredAPI

exposed type ServerResponseType

Purpose

Represents the type returned from the API implementation.

Usage

The exposed types are used with the typeof operator. See the example below for details.

Although the types are presented as fields on the API, they have no runtime value.

Examples

Implicit, same type
import { APIDeclaration } from 'papupata'
const api = new APIDeclaration()
const myAPI = api.declarePostAPI('/do-stuff')
  .response<string>()

type ServerResponseType = typeof myAPI['ServerResponseType']
// ServerResponseType is now string
Explicit differing type
import { APIDeclaration } from 'papupata'
const api = new APIDeclaration()
const myAPI = api.declarePostAPI('/do-stuff')
  .response<string, Date>()

type ServerResponseType = typeof myAPI['ServerResponseType']
// ServerResponseType is now Date