A minimalistic Typescript plugin for web storage
yarn add @nixjs23n6/web-storage
import { LocalStorage, SessionStorage, WebStorage } from '@nixjs23n6/web-storage'
const localStorage = new LocalStorage();
// const sessionStorage = new SessionStorage();
localStorage.setItem("ACCESS_TOKEN_KEY", "ACCESS_TOKEN")
localStorage.getItem<string>("ACCESS_TOKEN_KEY")
import { LocalStorage } from '@nixjs23n6/web-storage'
class LocalStore extends LocalStorage {
authorize (token: string): this {
return this.setItem('ACCESS_TOKEN', token);
}
deAuthorize (): this {
return this.removeItem('ACCESS_TOKEN');
}
}
const store = new LocalStore();
import { LocalStorageStatic } from '@nixjs23n6/web-storage'
LocalStorageStatic.setItem("ACCESS_TOKEN_KEY", "ACCESS_TOKEN")
LocalStorageStatic.getItem<string>("ACCESS_TOKEN_KEY")