2.0.0 • Published 1 year ago

use-storage-node v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

this could be used in both the browser and node.js

📦 Getting Started

npm i use-storage-node

⭐️ Test

npm run test

Usage

import storage from "use-storage-node";

const person = {
  name: "jhon doe",
  location: "tunisia",
  job: "fullstak",
};

const token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

const private_key = "xlqsdeidhe";
// should be in .env

const store = storage(private_key);

// ADD ITEM TO STORAGE
store.setItem("person", person);
store.setItem("token", token);

// GET ITEM FROM STORAGE
const item = store.getItem("person");

// REMOVE ITEM FROM STORAGE
store.removeItem("token");

// CLEAR STORAGE
store.clear();

💎 API

This package provides the following utility functions:

store(cryptoKey:string) -> {}

const store = store(private_key); // returns {}
// prepare an empty object to store key/value pair
// private key used to encrypte data
// private key should be stored in .env

addItem(key:string,value:any) -> undefined

store.addItem(key,value);
// store now container key / value pair with encrypted value
// value could be of any type

getItem(key:string) -> value

store.getItem(key,value);
// return decrypted value

removeItem(key:string) -> store

store.removeItem(key);
// store now container key / value pair with encrypted value

clear() -> undefined

store.clear();
// clear all key/value pair

Author

adnen rebai

License

This package is released under the MIT license.

2.0.0

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago