Skip to content

Commit

Permalink
update readme add new method for check key exist
Browse files Browse the repository at this point in the history
  • Loading branch information
restuwahyu13 committed Jun 9, 2022
1 parent 42354c0 commit e0b4408
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 38 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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
92 changes: 57 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -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`.

<img src="images/nds-work.png" alt="example-nds-work"/>

Expand All @@ -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<boolean | undefined>

set data using key and value, into disk

- #### get(key: string): Promise<any | undefined>

get specific data using key, after saving data into disk

- #### key(key: string): Promise<boolean | undefined>

get specific key, after saving data into disk

- #### remove(key: string): Promise<boolean | undefined>

remove specific data already exist using key, after saving data into disk

- #### clear(): Promise<boolean | undefined>

clear all keys exist, after saving data into disk

- #### keys(): Promise<string[] | undefined>
Expand All @@ -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: '[email protected]',
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: '[email protected]',
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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e0b4408

Please sign in to comment.