import * as IScheme from './service.storage.scheme' ; import { StateFile } from '../classes/class.statefile' ; import { IService } from '../interfaces/interface.service' ; import Logger from '../tools/env.logger' ; export { IScheme as IStorageScheme } ; const SETTINGS_FILE = 'storage.application.json' ; class description class ServiceStorage implements IService { private _settings : StateFile < IScheme . IStorage > | undefined ; private _logger : Logger = new Logger ( 'ServiceStorage' ) ; public init ( ) { return new Promise ( ( resolve , reject ) => { this . _settings = new StateFile < IScheme . IStorage > ( this . getName ( ) , IScheme . defaults , SETTINGS_FILE ) ; this . _settings . init ( ) . then ( ( ) => { resolve ( ) ; } ) . catch ( reject ) ; } ) ; } public destroy ( ) { return new Promise ( ( resolve ) => { if ( this . _settings === undefined ) { return resolve ( ) ; } this . _settings . destroy ( ) . then ( resolve ) ; } ) ; } public getName ( ) { return 'ServiceStorage' ; } public get ( ) { return this . _settings as StateFile < IScheme . IStorage > ; } } export default ( new ServiceStorage ( ) ) ;