Papupata Documentation

API Reference

class IncompleteAPIDeclaration

method queryBool

Deprecated

This method has been deprecated as of 2.0.0. The suggested alternative is to just use query and declare the type of a parameter to be a boolean.

Purpose

Declares boolean query parameters for an API

Usage

Path params and other query parameters may be defined before query.

Parameters

NameTypeDescription
booleanQueryParamsConst string array

Names of the query parameters. See the example below for the recommended way to set up the const string array.

At typescript level a regular string array is not treated as an error at declaration time, but using is NOT correct. Unfortunately we have not come up with a way to prevent this kind of usage.

Returns

PartiallyDeclaredAPI

Caveats

This feature is intented mainly to be used for papupata-to-papupata communications. The string "true" stands for true values on the server, all other values stand for false.

Examples

Declaration
import { APIDeclaration } from 'papupata'
const api = new APIDeclaration()
const myAPI = api.declarePostAPI('/do-stuff')
  .queryBool(['query1', 'query2'] as const)
  .response<string>()
Usage in invocation
await myAPI({query1: true, query2: false})
// Invokes URL /do-stuff?query1=true&query2=false
Usage in implementation
myAPI.implement(req => {
  const {query1, query2} = req.query
  return query1 + query2 // would return truefalse in the example. They come in as booleans, not strings.
})