import { Config, StorageType } from '../config' import { Local } from './local' export abstract class Storage { abstract read(path: string): Promise abstract write(path: string, data: Buffer): Promise abstract exists(path: string): Promise abstract delete(path: string): Promise abstract readStream(path: string): Promise abstract writeStream(path: string): Promise // list(path: string): Promise abstract init(): Promise } export let storage: Storage export async 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}`) } await storage.init() } }