# Utils

# Utils.buildError(statusCode, code, message) ⇒ Error

Custom Error builder

Kind: static method of Utils

Param Type Description
statusCode number
code string error description
message string error message

# Utils.mkDirByPathSync(targetDir, options) ⇒ Promise.<string>

Create directory

Kind: static method of Utils
Returns: Promise.<string> - directory path

Param Type
targetDir string
options object

# Utils.readFile(options) ⇒ Promise.<object>

Promise wrapper to render EJS template in HTML

Kind: static method of Utils
Returns: Promise.<object> - - HTML file and options

Param Type
options object

# Utils.readFile(filePath, [opts]) ⇒ Promise.<object>

Promise wrapper to read a file

Kind: static method of Utils

Param Type Description
filePath string
[opts] string format of the file

# Utils.writeFile(filePath, data, [opts]) ⇒ Promise.<object>

Promise wrapper to write a file

Kind: static method of Utils

Param Type Description
filePath string
data object file content
[opts] string format of the file

# Utils.removeFile(filePath) ⇒ Promise.<object>

Promise wrapper to remove a file

Kind: static method of Utils

Param Type
filePath string

# Utils.cacheIterator(Model, [filter]) ⇒ Promise.<string>

Iterate over each KV Store keys found in cache

Kind: static method of Utils
Returns: Promise.<string> - Storage key

Param Type Description
Model object Loopback Model
[filter] object filter.match

# Utils.find(Model, [filter]) ⇒ Promise.<Array.<object>>

Promise wrapper to find Model instances

Kind: static method of Utils
Returns: Promise.<Array.<object>> - instances

Param Type
Model function
[filter] object

# Utils.findOne(Model, [filter]) ⇒ Promise.<object>

Promise wrapper to findOne Model instance

Kind: static method of Utils
Returns: Promise.<object> - instance

Param Type
Model function
[filter] object

# Utils.findById(Model, id, [filter]) ⇒ Promise.<object>

Promise wrapper to findById Model instance

Kind: static method of Utils
Returns: Promise.<object> - instance

Param Type
Model function
id string | number
[filter] object

# Utils.create(Model, instances) ⇒ Promise.<(object|Array.<object>)>

Promise wrapper to create Model instance(s)

Kind: static method of Utils

Param Type
Model function
instances object | Array.<object>

# Utils.updateAttribute(instance, name, value) ⇒ Promise.<object>

Promise wrapper to updateAttribute of an instance

Kind: static method of Utils
Returns: Promise.<object> - instance

Param Type
instance function
name string
value any

# Utils.updateAttributes(instance, attributes) ⇒ Promise.<object>

Promise wrapper to updateAttributes of an instance

Kind: static method of Utils
Returns: Promise.<object> - instance

Param Type
instance function
attributes object

# Utils.generateKey([hmacKey], [algorithm], [encoding]) ⇒ string

Key generator for authentification

Kind: static method of Utils
Returns: string - key - Encoded key

Param Type
[hmacKey] string
[algorithm] string
[encoding] string

# Utils.flatten(input) ⇒ array

Array flattener, to transform multi dimensional arrays

Kind: static method of Utils

Param Type
input array

# Utils.exportToCSV(input, [filter]) ⇒ string

Convert an object as a CSV table

Kind: static method of Utils

Param Type
input object | array
[filter] object

# Utils.isMasterProcess(env) ⇒ boolean

Check if a process is configured to be master

Kind: static method of Utils

Param Type Description
env object environment variables

# Utils.getOwnerId(options) ⇒ string | null

Extract ownerId from HTTP user options

Kind: static method of Utils

Param Type
options object

# Utils~getCacheKey(iterator) ⇒ Promise.<string>

Promise wrapper to get next key in Cache store

Kind: inner method of Utils

Param Type
iterator object