import { HttpStatusCodes } from '../Server' ; import { Response } from './Response' ; export class SuccessfulResponse extends Response { public static create ( statusCode , data ? , meta ? ) { return new this ( { statusCode , data , meta } ) ; } public static ok ( data ? , meta ? ) { return this . create ( HttpStatusCodes . Ok , data , meta ) ; } public static created ( data ? , meta ? ) { return this . create ( HttpStatusCodes . Created , data , meta ) ; } public static accepted ( data ? , meta ? ) { return this . create ( HttpStatusCodes . Accepted , data , meta ) ; } public static nonAuthoritativeInformation ( data ? , meta ? ) { return this . create ( HttpStatusCodes . NonAuthoritativeInformation , data , meta ) ; } public static noContent ( data ? , meta ? ) { return this . create ( HttpStatusCodes . NoContent , data , meta ) ; } public static resetContent ( data ? , meta ? ) { return this . create ( HttpStatusCodes . ResetContent , data , meta ) ; } public static partialContent ( data ? , meta ? ) { return this . create ( HttpStatusCodes . PartialContent , data , meta ) ; } public static multiStatus ( data ? , meta ? ) { return this . create ( HttpStatusCodes . MultiStatus , data , meta ) ; } public static alreadyReported ( data ? , meta ? ) { return this . create ( HttpStatusCodes . AlreadyReported , data , meta ) ; } public static imUsed ( data ? , meta ? ) { return this . create ( HttpStatusCodes . ImUsed , data , meta ) ; } format ( ) { if ( this . statusCode === HttpStatusCodes . NoContent ) { return ; } return this . data ; } }