@creamapi/cream
Version:
Concise REST API Maker - An extension library for express to create REST APIs faster
32 lines (31 loc) • 1.44 kB
TypeScript
import { Serializer } from './Serializer';
import { Constructable } from '../Utils/Constructable';
export declare const SERIALIZER_METADATA_KEY: unique symbol;
export declare const SERIAL_MAP_METADATA_KEY: unique symbol;
export type SerialMap = {
fieldName: string;
outName: string;
};
/**
* Declares a class to be serialized and also declares the serializer that
* should be used to serialize the decorated class
* @param serializer the Serializer that should be used
* @returns the decorator that will decorate the class
*/
export declare function Serializable<T extends Constructable>(serializer: Constructable<Serializer>): (target: T) => T;
/**
* This method is used to declare a field serializable
* and it will also get the name of the field automatically
* @param target the target class attribute
* @param propertyName the name of the class attribute
* @returns the decorator that will handle the mapping for serialization
*/
export declare function AutoMap(target: any, propertyName: string): void;
/**
* This method is used to declare a field serializable
* and it will also get the name of the field automatically but it will
* map to a different name declared by the user
* @param name the new name of the field in the serialized object
* @returns the decorator that will handle the mapping for serialization
*/
export declare function MapTo(name: string): (target: any, propertyName: string) => void;