Options
All
  • Public
  • Public/Protected
  • All
Menu

@unifed/backend-core

This package is a collection of functions and classes used across the backend of the application. Mostly, this includes code for the database models, logging, and accessing configuration properties.

Index

Type aliases

AnyJSON

AnyJSON: boolean | number | string | null | JSONArray | JSONMap | toJSON

Valid JSON types.

EntityID

EntityID: string

Type representing the ID of an entity.

JSONArray

JSONArray: AnyJSON[]

A JSON array.

PostContent

PostContent: Pick<Post, "body" | "contentType">

Type consisting of the body and contentType fields from Post.

Variables

Const CommunityModel

CommunityModel: ReturnModelType<typeof Community, BeAnObject> = ...

Community model used for manipulating the MongoDB database.

Const PostModel

PostModel: ReturnModelType<typeof Post, BeAnObject> = ...

Post model used for manipulating the MongoDB database.

Const UserModel

UserModel: ReturnModelType<typeof User, BeAnObject> = ...

User model used for manipulating the MongoDB database.

Const logger

logger: Logger = ...

Used for logging messages throughout the application.

Examples:

logger.log('silly', "127.0.0.1 - there's no place like home");
logger.log('debug', "127.0.0.1 - there's no place like home");
logger.log('verbose', "127.0.0.1 - there's no place like home");
logger.log('info', "127.0.0.1 - there's no place like home");
logger.log('warn', "127.0.0.1 - there's no place like home");
logger.log('error', "127.0.0.1 - there's no place like home");
logger.info("127.0.0.1 - there's no place like home");
logger.warn("127.0.0.1 - there's no place like home");
logger.error("127.0.0.1 - there's no place like home");

Functions

dateToUnixTimestamp

  • dateToUnixTimestamp(date?: Date): number

extractPostBody

getIdFromRef

  • getIdFromRef<T>(item: Ref<T> | null): EntityID | null
  • Gets an ID from a reference object.

    References can either be documents (resolved) or an ID to a document (unresolved). This function always returns the ID, even in the resolved case.

    internal

    Type parameters

    Parameters

    • item: Ref<T> | null

      The reference to get the ID from.

    Returns EntityID | null

    The reference's ID.

getValidationMessage

  • getValidationMessage(errors: ValidationError[]): string | undefined
  • Converts an array of validation errors (produced by the class-validator package) to a string representation.

    Parameters

    • errors: ValidationError[]

      The validation errors.

    Returns string | undefined

    A string representation of the errors, or undefined if there were no errors.

Generated using TypeDoc