import { Config, StorageType } from '../config' import { Local } from './local' export interface Storage { read(path: string): Promise write(path: string, data: Buffer): Promise exists(path: string): Promise delete(path: string): Promise readStream(path: string): Promise writeStream(path: string): Promise // list(path: string): Promise } export let storage: Storage export function init() { if (!storage) { switch (Config.storage) { case StorageType.Local: storage = new Local(Config.assets) break default: throw new Error(`Unknown storage type: ${Config.storage}`) } } }