Members
config :Object
- Object
findRoute
Find route by route name
routeDir
Get route directory by plugin's name
(static, constant) alias :string
- string
- Default Value
- 'w'
(static, constant) dependencies :Array.<string>
- Array.<string>
- Default Value
- ['bajo-extra']
(static, constant) escapeChars :TEscapeChars
- TEscapeChars
(static, constant) hookTypes :Array.<string>
- Array.<string>
- Default Value
- ['onRequest', 'onResponse', 'preParsing', 'preValidation', 'preHandler', 'preSerialization', 'onSend', 'onTimeout', 'onError']
Methods
escape(text) → {string}
Escape text
Name | Type | Description |
---|---|---|
text | string |
- Type:
- string
(async) exit()
Exit handler
(async) fetch(url, optsopt, extraopt) → {Object}
Fetch something from url. A wrapper of bajo-extra's fetchUrl which support bajo's ns based url.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
url | string | Also support ns based url | ||
opts | Object | <optional> | {} | node's fetch options |
extra | Object | <optional> | {} | See bajo-extra |
- Type:
- Object
getIp(req) → {string}
Get visitor IP from fastify's request object
Name | Type | Description |
---|---|---|
req | Object | request object |
- Type:
- string
getOrigin(req) → {string}
Get origin of fastify's request object
Name | Type | Description |
---|---|---|
req | Object |
- Type:
- string
getPluginByPrefix(prefix) → {Object}
Get plugin by prefix
Name | Type | Description |
---|---|---|
prefix | string |
- Type:
- Object
getPluginPrefix(name, webAppopt) → {string}
Get plugin's prefix by name
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name | string | Plugin's name | ||
webApp | string | <optional> | waibuMpa | Web app to use |
- Type:
- string
getRoutes(groupedopt, liteopt) → {Array}
Get all available routes
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
grouped | boolean | <optional> | false | Returns as groups of urls and methods |
lite | * | <optional> | false | Retuns only urls and methods |
- Type:
- Array
getUploadedFiles(reqId, fileUrlopt, returnDir) → {Object|Array}
Get uploaded files by request ID
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
reqId | string | Request ID | ||
fileUrl | boolean | <optional> | false | If |
returnDir | * | If |
- Returns object if
returnDir
istrue
, array of files otherwise
- Type:
- Object |
Array
(async) init()
Initialize plugin
isIntlPath(ns) → {boolean}
Is namespace's path contains language detector token?
Name | Type | Description |
---|---|---|
ns | string | Plugin name |
- Type:
- boolean
parseFilter(req) → {Object}
Parse filter found from Fastify's request based on keys set in config object
Name | Type | Description |
---|---|---|
req | Object | Request object |
- Type:
- Object
routePath(name, optionsopt) → {string}
Get route path by route's name:
- If it is a
mailto:
ortel:
url, it returns as is - If it is a ns based name, it will be parsed first
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name | string | ||||||||||||||||||||||||||||
options | Object | <optional> | {} | Options object Properties
|
- Type:
- string
(async) sendMail(tpl, paramsopt)
Method to send mail through Masohi Messaging System. It is a thin wrapper for masohi-mail send method.
If masohi is not loaded, nothing is delivered.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
tpl | string | | Mail's template to use. If a string is given, the same template will be used for html & plaintext versions. Otherwise, the first template will be used for html mail, and the second one is for it's plaintext version | ||
params | Object | <optional> | {} | masohi-mail's params object. |
(async) start()
Start plugin
unescape(text) → {string}
Unescape text using TEscapeChars rules
Name | Type | Description |
---|---|---|
text | string | Text to unescape |
- Type:
- string
unescapeBlock(content, start, end, startReplacer, endReplacer) → {string}
Recursively unescape block of texts
Name | Type | Description |
---|---|---|
content | string | Source content |
start | string | Block's start |
end | string | Block's end |
startReplacer | string | Token to use as block's start replacer |
endReplacer | string | Token to use as block's end replacer |
- Type:
- string
Type Definitions
TEscapeChars
- Object
Name | Type | Default | Description |
---|---|---|---|
< | string | < | |
> | string | > | |
" | string | " | |
' | string | ' |