Methods

(async) factory(pkgName) → {WaibuRestApi}

Plugin factory.

Never call this function directly!!! It's only-meant to be called by the Bajo framework during plugin initialization.

Parameters:
NameTypeDescription
pkgNamestring

NPM package name

Returns:

WaibuRestApi class

Type: 
WaibuRestApi

Type Definitions

TConfig

Type:
  • Object
Properties
NameTypeAttributesDefaultDescription
waibuObject<optional>
{}

Waibu configuration

Properties
NameTypeAttributesDefaultDescription
prefixstring<optional>
'api'

Prefix for the Waibu REST API routes

mountMainAsRootboolean<optional>
true

Whether to mount the main route as root

exposeHeadboolean<optional>
true

Whether to expose the HEAD method

enablePatchboolean<optional>
false

Whether to enable the PATCH method

bodyLimitnumber<optional>
1048576

Maximum size of the request body in bytes

intlObject<optional>
{}

Internationalization configuration

Properties
NameTypeAttributesDefaultDescription
detectorsArray.<string><optional>
['qs', 'header']

List of detectors for internationalization

formatObject<optional>
{}

Format configuration

Properties
NameTypeAttributesDefaultDescription
supportedArray.<string><optional>
['json', 'xml']

List of supported formats (e.g., 'json', 'xml')

asExtboolean<optional>
false

Whether to use file extensions for format detection

xmlObject<optional>
{}

XML format configuration

Properties
NameTypeAttributesDefaultDescription
bodyParserObject<optional>
{}

XML body parser configuration

Properties
NameTypeAttributesDefaultDescription
contentTypesArray.<string><optional>
['text/xml', 'application/xml', 'application/rss+xml']

List of content types for XML body parsing

validateboolean<optional>
false

Whether to validate XML body

responseObject<optional>
{}

XML response configuration

Properties
NameTypeAttributesDefaultDescription
wrapperstring<optional>
'doc'

Wrapper element for XML response

declarationboolean<optional>
true

Whether to include XML declaration in response

valueAsAttributesboolean<optional>
true

Whether to treat values as attributes in XML response

responseKeyObject<optional>
{}

Response key mapping configuration

Properties
NameTypeAttributesDefaultDescription
datastring<optional>
'data'

Key for data in the response

oldDatastring<optional>
'oldData'

Key for old data in the response

pagestring<optional>
'page'

Key for page number in the response

countstring<optional>
'count'

Key for count

pagesstring<optional>
'pages'

Key for total pages

successstring<optional>
'success'

Key for success status

statusCodestring<optional>
'code'

Key for status code

errorstring<optional>
'error'

Key for error message

cachedstring<optional>
'cached'

Key for cached status

hardCappedstring<optional>
'hardCapped'

Key for hard capped status

messagestring<optional>
'message'

Key for message

warningsstring<optional>
'warnings'

Key for warnings

detailsstring<optional>
'details'

Key for details