import { Injectable } from '@angular/core' ; import { InMemoryDbService , RequestInfoUtilities , ParsedRequestUrl , STATUS , } from 'angular-in-memory-web-api' ; import { DaffProduct } from '@daffodil/product' ; import { DaffProductImageFactory , DaffProductExtensionFactory , } from '@daffodil/product/testing' ; Param Param Param @ Injectable ( { providedIn : 'root' , } ) export class DaffInMemoryBackendProductService implements InMemoryDbService { protected _products : DaffProduct [ ] = [ ] ; /**
     * The collection of products in the backend.
     */ get products ( ) : DaffProduct [ ] { return this . _products ; } ; constructor ( private productFactory , private productImageFactory ) { this . _products = [ '1001' , '1002' , '1003' , '1004' , '1005' , '1006' , '1007' , '1008' , '1009' , '1010' , '1011' , '1012' , '1013' , '1014' , '1015' , '1016' , '1017' , '1018' , '1019' , '1020' , '1021' , '1022' , '1023' , '1024' , '1025' , '1026' , '1027' , '1028' , '1029' , '1030' , '1031' , '1032' , '1033' , '1034' , '1035' , ] . map ( id => this . productFactory . create ( { id , url : `/${ id }` , images : this . productImageFactory . createMany ( 5 ) } ) ) ; } param url param utils returns docs-private parseRequestUrl ( url , utils ) { return utils . parseRequestUrl ( url ) ; } returns docs-private createDb ( ) { return { products : this . _products , } ; } param reqInfo returns get ( reqInfo ) { if ( reqInfo . id === 'best-sellers' ) { return reqInfo . utils . createResponse$ ( ( ) => ( { body : this . _products . slice ( 0 , 4 ) , status : STATUS . OK , } ) ) ; } return undefined ; } }