Utils
Utility functions and base classes
Enumerations
MetadataKeys
Defined in: packages/core/src/core/utils/metadata.keys.ts:1
Enumeration Members
AUTHENTICATION_HANDLERS
AUTHENTICATION_HANDLERS: "auth:authentication";
Defined in: packages/core/src/core/utils/metadata.keys.ts:14
AUTHORIZATION
AUTHORIZATION: "server:authorization";
Defined in: packages/core/src/core/utils/metadata.keys.ts:11
AUTHORIZATION_OR_MODE
AUTHORIZATION_OR_MODE: "server:authorization:or_mode";
Defined in: packages/core/src/core/utils/metadata.keys.ts:12
AUTHORIZATION_VALIDATORS
AUTHORIZATION_VALIDATORS: "server:authorization:validators";
Defined in: packages/core/src/core/utils/metadata.keys.ts:13
BASE_PATH
BASE_PATH: "express:base_path";
Defined in: packages/core/src/core/utils/metadata.keys.ts:3
EXPRESS_USE_HANDLERS
EXPRESS_USE_HANDLERS: "express:handlers";
Defined in: packages/core/src/core/utils/metadata.keys.ts:7
MIDDLEWARE
MIDDLEWARE: "express:middleware";
Defined in: packages/core/src/core/utils/metadata.keys.ts:9
ROUTERS
ROUTERS: "express:routers";
Defined in: packages/core/src/core/utils/metadata.keys.ts:5
SCHEDULE_CRON
SCHEDULE_CRON: "scheduler:cron";
Defined in: packages/core/src/core/utils/metadata.keys.ts:16
SCHEDULE_METADATA
SCHEDULE_METADATA: "scheduler:metadata";
Defined in: packages/core/src/core/utils/metadata.keys.ts:18
SCHEDULE_OPTIONS
SCHEDULE_OPTIONS: "scheduler:options";
Defined in: packages/core/src/core/utils/metadata.keys.ts:17
Classes
abstract BaseMapper
Defined in: packages/core/src/core/utils/base.mapper.ts:5
Base mapper class for bidirectional entity-DTO transformation Provides generic mapping functionality that can be extended by specific mappers
Type Parameters
Entity
Entity
DTO
DTO
Constructors
Constructor
new BaseMapper<Entity, DTO>(): BaseMapper<Entity, DTO>;
Returns
BaseMapper<Entity, DTO>
Methods
fromDTO()
abstract fromDTO(dto): Partial<Entity>;
Defined in: packages/core/src/core/utils/base.mapper.ts:18
Maps a DTO to its entity representation
Parameters
dto
DTO
The DTO to map
Returns
Partial<Entity>
The mapped entity (partial or complete depending on implementation)
fromDTOList()
fromDTOList(dtos): Partial<Entity>[];
Defined in: packages/core/src/core/utils/base.mapper.ts:34
Maps an array of DTOs to their entity representations
Parameters
dtos
DTO[]
The array of DTOs to map
Returns
Partial<Entity>[]
Array of mapped entities
fromDTOOrNull()
fromDTOOrNull(dto): Partial<Entity>;
Defined in: packages/core/src/core/utils/base.mapper.ts:52
Maps a single DTO to entity, returning null if DTO is null/undefined
Parameters
dto
DTO
The DTO to map (can be null/undefined)
Returns
Partial<Entity>
The mapped entity or null
toDTO()
abstract toDTO(entity): DTO;
Defined in: packages/core/src/core/utils/base.mapper.ts:11
Maps a single entity to its DTO representation
Parameters
entity
Entity
The entity to map
Returns
DTO
The mapped DTO
toDTOList()
toDTOList(entities): DTO[];
Defined in: packages/core/src/core/utils/base.mapper.ts:25
Maps an array of entities to their DTO representations
Parameters
entities
Entity[]
The array of entities to map
Returns
DTO[]
Array of mapped DTOs
toDTOOrNull()
toDTOOrNull(entity): DTO;
Defined in: packages/core/src/core/utils/base.mapper.ts:43
Maps a single entity to DTO, returning null if entity is null/undefined
Parameters
entity
Entity
The entity to map (can be null/undefined)
Returns
DTO
The mapped DTO or null
LogRequest
Defined in: packages/core/src/core/utils/logRequest.ts:17
Adds request tracking headers to a response.
Sets x-request-id and x-request-timestamp headers
for request tracing and debugging.
Example
app.use((req, res, next) => {
const log = new LogRequest(res);
console.log(`Request ${log.requestId} at ${log.timestamp}`);
next();
});
Constructors
Constructor
new LogRequest(res): LogRequest;
Defined in: packages/core/src/core/utils/logRequest.ts:21
Parameters
res
Response
Returns
Properties
requestId
requestId: string;
Defined in: packages/core/src/core/utils/logRequest.ts:19
timestamp
timestamp: string;
Defined in: packages/core/src/core/utils/logRequest.ts:18
Functions
generateMagicLink()
function generateMagicLink(size?): string;
Defined in: packages/core/src/core/utils/generics.ts:54
Generates a magic link token for passwordless authentication.
Parameters
size?
number = 95
Length of the token (default: 95)
Returns
string
Random token string
generateRandomPassword()
function generateRandomPassword(length?): string;
Defined in: packages/core/src/core/utils/generics.ts:44
Generates a random password.
Parameters
length?
number = 12
Length of the password (default: 12)
Returns
string
Random alphanumeric password
generateRandomString()
function generateRandomString(length?): string;
Defined in: packages/core/src/core/utils/generics.ts:25
Generates a random alphanumeric string.
Parameters
length?
number = 10
Length of the string (default: 10)
Returns
string
Random alphanumeric string
Example
const token = generateRandomString(20);
generateUUID()
function generateUUID(): string;
Defined in: packages/core/src/core/utils/generics.ts:12
Generates a UUID v4 string.
Returns
string
A unique UUID string
Example
const id = generateUUID();
// Returns: '550e8400-e29b-41d4-a716-446655440000'
hashedPassword()
function hashedPassword(password): string;
Defined in: packages/core/src/core/utils/crypto.ts:12
Hashes a password using SHA-256.
Parameters
password
string
The plaintext password to hash
Returns
string
The SHA-256 hash as a hex string
Example
const hash = hashedPassword('mypassword');
loadSecret()
function loadSecret(envVarName): string;
Defined in: packages/core/src/core/utils/loadSecrets.ts:9
Load a secret from a file or environment variable Use this function to load Docker mounts
Parameters
envVarName
string
The name of the environment variable that holds the secret path or value
Returns
string
The secret value as a string
processSetUpDataBaseService()
function processSetUpDataBaseService(fileList, setUpDatabaseAction): void;
Defined in: packages/core/src/core/utils/processSetUpDataBaseFiles.ts:5
Parameters
fileList
setUpDatabaseAction
Returns
void
renderHtmlTemplate()
function renderHtmlTemplate(template, data): string;
Defined in: packages/core/src/core/utils/renderHtmlTemplate.ts:15
Renders an HTML template by replacing {{placeholder}} with actual data.
Parameters
template
string
The HTML template string with {{key}} placeholders
data
Record<string, string>
Object with key-value pairs for replacement
Returns
string
The rendered HTML string
Example
const html = renderHtmlTemplate(
'<h1>Hello {{name}}</h1>',
{ name: 'World' }
);
// Returns: '<h1>Hello World</h1>'