The function runs in the context of Server Connect and has access to several of its internal methods. this.parse
is like dmx.parse
in App Connect, it parses an expression and returns the result. The input can also be a complete object, it will then check all the properties if it contains a string with an expression to parse and parses them all.
Other maybe handy methods/properties:
// parse an option or throw an error if not a valid string
this.parseRequired(options.value, 'string', 'parameter value is required.');
// parse an option, a default value will be used if it is not a valid string
this.parseOptional(options.value, 'string', 'default value');
// parse an option, like above a default value will be used if it is not set, it doesn't check the type
this.parseOptional(options.value, '*', 'default value');
// execute sub steps/actions
// always set the second parameter to true
await this.exec(options.then, true);
// express req object
this.req
// express res object
this.res
// set session variable
this.setSession(key, value);
// get session variable
this.getSession(key);
// remove session variable
this.removeSession(key);
// set cookie
this.setCookie(name, value, opts);
// get cookie
this.getCookie(name, opts);
// remove cookie
this.removeCookie(name);
I think these will be the most important ones. These only applies to custom modules, they are not available with formatters.