From 61c15e6942dacef3714c65f91a96636a8447fec7 Mon Sep 17 00:00:00 2001 From: Neil Campbell Date: Fri, 5 Jan 2024 22:29:32 +0800 Subject: [PATCH] feat: add a pinata implementation without cache --- src/ipfs.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/ipfs.ts b/src/ipfs.ts index 0814172..ff3197f 100644 --- a/src/ipfs.ts +++ b/src/ipfs.ts @@ -296,3 +296,24 @@ export class PinataStorageWithCache implements IPFS { } } } + +class NoOpCache implements ObjectCache { + getAndCache( + _cacheKey: string, + generator: (existing: T | undefined) => Promise, + _staleAfterSeconds?: number | undefined, + _returnStaleResult?: boolean | undefined, + _isBinary?: boolean | undefined, + ): Promise { + return generator(undefined) + } + put(_cacheKey: string, _data: T): Promise { + return Promise.resolve() + } +} + +export class PinataStorage extends PinataStorageWithCache { + constructor(pinataToken: string) { + super(pinataToken, new NoOpCache()) + } +}