Modules | ZITADEL Docs

Modules

ZITADEL provides the following modules.

HTTP

This module provides functionality to call REST APIs.

Import

let http = require('zitadel/http')

fetch() function

This function allows to call HTTP servers. The function does NOT fulfil the Fetch API specification.

Parameters

Response

If the request was invalid, an error will be thrown; otherwise, a Response object will be returned.

The object has the following fields and methods:

Example

let http = require('zitadel/http')
let logger = require("zitadel/log")
function make_api_call(ctx, api) {
    var user = http.fetch('API_URL', {
        method: 'POST',
        body: {
            "name": "user 1"
        }
    }).json();
    logger.log(user.id);
}

Log

The log module provides you with the functionality to log to stdout.

Import

   let logger = require("zitadel/log")

log(), warn(), error() function

The logger offers three distinct log levels (info, warn, and error) to effectively communicate messages based on their severity, enhancing debugging and troubleshooting efficiency. Use the function that reflects your log level.

Example

logger.log("This is an info log.")

logger.warn("This is a warn log.")

logger.error("This is an error log.")

Parameters

UUID

This module provides functionality to generate a UUID

Import

    let uuid = require("zitadel/uuid")

uuid.vX() function

This function generates a UUID using google/uuid. vX allows to define the UUID version:

Parameters

Namespaces

The following predefined namespaces can be used for uuid.v3 and uuid.v5:

Example

let uuid = require("zitadel/uuid")
function setUUID(ctx, api) {
  if (api.metadata === undefined) {
    return;
  }

api.v1.user.appendMetadata('custom-id', uuid.v4());
}