import { CSVRow } from "./../../common/Objects/CSVRow" ; /**
 * This class manages the nginx configuration file creation
 * process from a CSVRow[]
 */ export class NginxConverter { private csvArray : CSVRow [ ] ; private subdir : string ; constructor param { CSVRow [ ] } csvArray param { string } subdir constructor ( csvArray , subdir ) { this . csvArray = csvArray ; this . subdir = subdir ; } returns public makeNginxConfFile ( ) { let data = "" ; for ( const row of this . csvArray ) { if ( row . isValidAndEnabled ( ) ) { data += this . getRewriteRule ( row ) + "\n" ; } } return data ; } param { CSVRow } row returns private getRewriteRule ( row ) { if ( row . pid === "" || row . url === "" ) { return "" ; } let redir = "" ; if ( this . subdir !== "" ) { redir = `${ this . subdir }/` ; } if ( row . docType !== "" ) { redir = `${ redir }${ row . docType }/` ; } redir = `${ redir }${ row . pid }` ; return `rewrite /${ redir }$ ${ row . url } redirect ;` ; } }