@jesuferanmi/resource-transformer
Version:
Laravel-style API resources for NestJS apps
23 lines (22 loc) • 668 B
TypeScript
import { BaseResource } from './base.resource';
export declare class ResourceCollection<T = any> {
private resources;
private ResourceClass;
private additionalMeta;
constructor(resources: T[], ResourceClass: new (item: T) => BaseResource<T>);
/**
* Transform the collection of resources into an array of JSON objects
*/
toJSON(): any[];
/**
* Add or merge additional metadata to the collection response
*/
withMeta(meta: Record<string, any>): this;
/**
* Return the full collection response with data and metadata
*/
toResponse(): {
data: any[];
meta: Record<string, any>;
};
}