From e0b440889a359c798d6bb4a241bcc98acf4b6446 Mon Sep 17 00:00:00 2001 From: restuwahyu13 Date: Thu, 9 Jun 2022 11:49:53 +0700 Subject: [PATCH] update readme add new method for check key exist --- Dockerfile | 6 ++-- README.md | 92 +++++++++++++++++++++++++++++++++--------------------- 2 files changed, 60 insertions(+), 38 deletions(-) diff --git a/Dockerfile b/Dockerfile index feaa2ac..12e91e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ## BUILD STAGE ONE -FROM node:14-alpine as node-dist-storage +FROM node:14-alpine as node-disk-storage COPY package*.json \ .coveralls.yml \ .editorconfig \ @@ -20,8 +20,8 @@ RUN apk add make \ ## BUILD STAGE TWO -FROM node-dist-storage +FROM node-disk-storage WORKDIR /usr/src/app -COPY --from=node-dist-storage ./ /usr/src/app +COPY --from=node-disk-storage ./ /usr/src/app RUN make build CMD docker images \ No newline at end of file diff --git a/README.md b/README.md index 1d6887e..8f68900 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,15 @@ # Node Disk Storage (NDS) -[![Build Status](https://scrutinizer-ci.com/g/restuwahyu13/node-disk-storage/badges/build.png?b=main)](https://scrutinizer-ci.com/g/restuwahyu13/node-disk-storage/build-status/main) [![Coverage Status](https://coveralls.io/repos/github/restuwahyu13/node-disk-storage/badge.svg?branch=main)](https://coveralls.io/github/restuwahyu13/node-disk-storage?branch=main) [![CodeFactor](https://www.codefactor.io/repository/github/restuwahyu13/node-disk-storage/badge)](https://www.codefactor.io/repository/github/restuwahyu13/node-disk-storage) [![codebeat badge](https://codebeat.co/badges/5611b53e-e00a-40c1-bab2-b9a8f5592b33)](https://codebeat.co/projects/github-com-restuwahyu13-node-disk-storage-main) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/d74af409b71641fb96484df3dc582365)](https://www.codacy.com/gh/restuwahyu13/node-disk-storage/dashboard?utm_source=github.com&utm_medium=referral&utm_content=restuwahyu13/node-disk-storage&utm_campaign=Badge_Grade)![node-current](https://img.shields.io/node/v/node-disk-storage?style=flat-square) ![npm](https://img.shields.io/npm/dm/node-disk-storage) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/restuwahyu13/node-disk-storage/blob/main/CONTRIBUTING.md) +[![Build Status](https://scrutinizer-ci.com/g/restuwahyu13/node-disk-storage/badges/build.png?b=main)](https://scrutinizer-ci.com/g/restuwahyu13/node-disk-storage/build-status/main) +[![Coverage Status](https://coveralls.io/repos/github/restuwahyu13/node-disk-storage/badge.svg?branch=main)](https://coveralls.io/github/restuwahyu13/node-disk-storage?branch=main) +[![CodeFactor](https://www.codefactor.io/repository/github/restuwahyu13/node-disk-storage/badge)](https://www.codefactor.io/repository/github/restuwahyu13/node-disk-storage) +[![codebeat badge](https://codebeat.co/badges/5611b53e-e00a-40c1-bab2-b9a8f5592b33)](https://codebeat.co/projects/github-com-restuwahyu13-node-disk-storage-main) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/d74af409b71641fb96484df3dc582365)](https://www.codacy.com/gh/restuwahyu13/node-disk-storage/dashboard?utm_source=github.com&utm_medium=referral&utm_content=restuwahyu13/node-disk-storage&utm_campaign=Badge_Grade)![node-current](https://img.shields.io/node/v/node-disk-storage?style=flat-square) +![npm](https://img.shields.io/npm/dm/node-disk-storage) +[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/restuwahyu13/node-disk-storage/blob/main/CONTRIBUTING.md) -**node-disk-storage** a simple fast and secure `local storage` for `nodejs`, you can store any data using key and value, and then your data will be **encrypt** to be like this `�+�)data|ZGF0YXxqb2huK2RvZV5eXiQwfDFd^^^$0|1`. +**node-disk-storage** a simple fast and secure `local storage` for `nodejs`, you can store any data using key and value, and then your data will be **encrypt** +to be like this `�+�)data|ZGF0YXxqb2huK2RvZV5eXiQwfDFd^^^$0|1`. example-nds-work @@ -20,23 +27,32 @@ ```bash $ npm install node-disk-storage -S or yarn add node-disk-storage -S ``` + ## API Reference - #### Node Disk Storage Options Property - + **minSize** limit data size, before saving into disk, default value to **1MB** - + **maxSize** limit data size, before saving into disk, default value to **25MB** + - **minSize** limit data size, before saving into disk, default value to **1MB** + - **maxSize** limit data size, before saving into disk, default value to **25MB** - #### set(key: string, value: any): Promise + set data using key and value, into disk - #### get(key: string): Promise + get specific data using key, after saving data into disk +- #### key(key: string): Promise + + get specific key, after saving data into disk + - #### remove(key: string): Promise + remove specific data already exist using key, after saving data into disk - #### clear(): Promise + clear all keys exist, after saving data into disk - #### keys(): Promise @@ -47,37 +63,39 @@ $ npm install node-disk-storage -S or yarn add node-disk-storage -S - ##### Example Usage Using CommonJs With JavaScript ```javascript - const { NodeDiskStorage } = require('node-disk-storage') - - const nds = new NodeDiskStorage() - - ;(async () => { - await nds.set("user", { - id: 1, - name: 'Leanne Graham', - username: 'Bret', - email: 'Sincere@april.biz', - address: { - street: 'Kulas Light', - suite: 'Apt. 556', - city: 'Gwenborough', - zipcode: '92998-3874', - geo: { lat: '-37.3159', lng: '81.1496' } - }, - phone: '1-770-736-8031 x56442', - website: 'hildegard.org', - company: { - name: 'Romaguera-Crona', - catchPhrase: 'Multi-layered client-server neural-net', - bs: 'harness real-time e-markets' - } - }) - await nds.get("user") - await nds.keys() - await nds.remove("user") - await nds.clear() - })() + const { NodeDiskStorage } = require('node-disk-storage') + + const nds = new NodeDiskStorage() + + ;(async () => { + await nds.set('user', { + id: 1, + name: 'Leanne Graham', + username: 'Bret', + email: 'Sincere@april.biz', + address: { + street: 'Kulas Light', + suite: 'Apt. 556', + city: 'Gwenborough', + zipcode: '92998-3874', + geo: { lat: '-37.3159', lng: '81.1496' } + }, + phone: '1-770-736-8031 x56442', + website: 'hildegard.org', + company: { + name: 'Romaguera-Crona', + catchPhrase: 'Multi-layered client-server neural-net', + bs: 'harness real-time e-markets' + } + }) + await nds.get('user') + await nds.key('user') + await nds.keys() + await nds.remove('user') + await nds.clear() + })() ``` + - ##### Example Usage Using CommonJs With JavaScript And Options ```javascript @@ -107,6 +125,7 @@ $ npm install node-disk-storage -S or yarn add node-disk-storage -S } }) await nds.get("user") + await nds.key('user') await nds.keys() await nds.remove("user") await nds.clear() @@ -141,6 +160,7 @@ $ npm install node-disk-storage -S or yarn add node-disk-storage -S } }) await nds.get("user") + await nds.key('user') await nds.keys() await nds.remove("user") await nds.clear() @@ -175,6 +195,7 @@ $ npm install node-disk-storage -S or yarn add node-disk-storage -S } }) await nds.get("user") + await nds.key('user') await nds.keys() await nds.remove("user") await nds.clear() @@ -206,7 +227,8 @@ For information on bugs related to package libraries, please visit [here](https: ## Contributing -Want to make **node-disk-storage** more perfect ? Let's contribute and follow the [contribution guide.](https://github.com/restuwahyu13/node-disk-storage/blob/main/CONTRIBUTING.md) +Want to make **node-disk-storage** more perfect ? Let's contribute and follow the +[contribution guide.](https://github.com/restuwahyu13/node-disk-storage/blob/main/CONTRIBUTING.md) ## License