Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hazratgs/online-storage
⚡️Online implementation of localStorage
https://github.com/hazratgs/online-storage
cloud key-value localstorage mongodb nodejs online-storage online-store storage-api storage-service
Last synced: about 2 months ago
JSON representation
⚡️Online implementation of localStorage
- Host: GitHub
- URL: https://github.com/hazratgs/online-storage
- Owner: hazratgs
- Created: 2018-02-02T10:46:57.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-16T15:38:17.000Z (over 6 years ago)
- Last Synced: 2024-10-15T04:32:45.618Z (4 months ago)
- Topics: cloud, key-value, localstorage, mongodb, nodejs, online-storage, online-store, storage-api, storage-service
- Language: JavaScript
- Homepage: https://storage.hazratgs.com/
- Size: 66.4 KB
- Stars: 6
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## online-storage
[![npm](https://img.shields.io/npm/v/npm.svg)](https://www.npmjs.com/package/online-storage-client)This is a cloud-key data store with a REST API interface, the database uses the NoSQL MongoDB database.
**Get rid of all the complex configurations, installation scenarios and maintenance for storing your data!**
### Features
- Create token
- Refresh token
- Get value of a property from the storage
- Get all storage data
- Set key/value
- Remove element it storage
- Delete storage
- Create backup
- Get backup list
- Restoring the vault from a backup## Getting Started
Demand:
- Node: v9.3.0+
- MongoDB: v3.6.2+Clone this repository:
git clone [email protected]:hazratgs/online-storage.git
Go to the directory:cd online-storage
Install all dependencies:npm install
Then start MongoDB:
###### Installation instructions for your system can be found on the [the official website of MongoDB](https://docs.mongodb.com/manual/tutorial/#installation)
Mac OSmongod
Ubuntusudo service mongod start
After that you can run the repository on your working machine with the command:
node index.js
For the background work of the repository, you need to install the npm package [pm2](https://www.npmjs.com/package/pm2), you can read more about it in the corresponding repository, if you have it installed, run the command:
npm run start
That's all!
For convenience in working with the repository, you can use the kurtub-client library [online-storage-client](https://www.npmjs.com/package/online-storage-client)
## API
*All examples are given using the axios JavaScript library*
#### Creating a token
All parameters (domains, backup, password) are optional:| param | description |
|--|--|
| domains | list of domains that can receive data from the storage, use http header "Origin" as verification |
| backup | the function of storing backup copies of the storage with the subsequent possibility to return to one of the points |
| password | set a password if you need to protect the storage from being written by third-party users |```js
axios.post('https://storage.hazratgs.com/create', {
domains: ['example.com', 'google.com'],
backup: true,
password: 'qwerty'
})
```
View Response```js
{
"status": true,
"data":{
"token": "002cac23-aa8b-4803-a94f-3888020fa0df",
"refreshToken": "5bf365e0-1fc0-11e8-85d2-3f7a9c4f742e"
}
}
```#### Writing data to storage
To write data to the storage, you need to transfer the data object:
```js
axios.post('https://storage.hazratgs.com/{token}', {
name: 'hazratgs',
age: 25,
city: 'Derbent'
skills: ['javascript', 'react+redux', 'nodejs', 'mongodb']
})
```
View Response```js
{
"status": true,
"message": "Successfully added"
}
```#### Get property
```js
axios.get('https://storage.hazratgs.com/{token}/name')
```
View Response```js
{
"status": true,
"data": "hazratgs"
}
```#### Get all storage
```js
axios.get('https://storage.hazratgs.com/{token}')
```
View Response```js
{
"status": true,
"data": {
name: 'hazratgs',
age: 25,
city: 'Derbent'
skills: ['javascript', 'react+redux', 'nodejs', 'mongodb']
}
}
```#### Remove property
```js
axios.delete('https://storage.hazratgs.com/{token}/city')
```
View Response```js
{
"status": true,
"message": "Successfully deleted"
}
```#### Delete storage
```js
axios.delete('https://storage.hazratgs.com/{token}')
```
View Response```js
{
"status": true,
"message": "Storage deleted"
}
```#### Get backup list storage
If you passed a parameter `backup` when creating a token, then your repository will have backup copies, which are created every 2 hours and stored during the day.
In order to get a list of active copies of the repository, send the request:
```js
axios.get('https://storage.hazratgs.com/{token}/backup/list')
```
View Response```js
{
"status": true,
"data": [
'Sun Mar 04 2018 19:39:42 GMT+0300 (MSK)',
'Sun Mar 04 2018 20:39:42 GMT+0300 (MSK)'
]
}
```#### Create backup
Backups are automatically created every 2 hours, but if you need to make a copy immediately, then this method will work for you.
The method has limitations, there should not be more than 999 backups, and by default 1 backup can be done within 1 minute, when trying to do more, you get an error.
```js
axios.post('https://storage.hazratgs.com/{token}/backup')
```
View Response```js
{
"status": true
}
```#### Restoring the vault from a backup
To return the store to a specific checkpoint, pass the date of the checkpoint:
```js
axios.post('https://storage.hazratgs.com/{token}/backup/Sun Mar 04 2018 19:39:42 GMT+0300 (MSK)')
```
View Response```js
{
"status": true,
"message": "Successfully restored"
}
```## Test
Tests are written using Chai & Mocha and to run them use the npm script:npm run test
## License
Code released under the MIT License.