-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fbf9e00
commit 5859379
Showing
15 changed files
with
73 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
'central-storage': patch | ||
'remote-storage': patch | ||
--- | ||
|
||
Bump to new version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
[![npm version](https://img.shields.io/npm/v/central-storage)](https://www.npmjs.com/package/global-storage) | ||
[![npm version](https://img.shields.io/npm/v/remote-storage)](https://www.npmjs.com/package/global-storage) | ||
[![npm version](https://github.com/FrigadeHQ/react-native-onboard/actions/workflows/tests.yml/badge.svg)](https://github.com/FrigadeHQ/react-native-onboard/actions/workflows/tests.yml) | ||
[![npm license](https://img.shields.io/npm/l/react-native-onboard)](https://www.npmjs.com/package/react-native-onboard) | ||
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier) | ||
|
||
|
||
<H3 align="center"><strong>centralStorage</strong></H3> | ||
<div align="center">centralStorage is a simple, open source library that combines the localStorage API with a single centralized location to store data.</div> | ||
<H3 align="center"><strong>remoteStorage</strong></H3> | ||
<div align="center">remoteStorage is a simple, open source library that combines the localStorage API with a single centralized location to store data.</div> | ||
<br /> | ||
<div align="center"> | ||
<a href="https://frigade.com">Website</a> | ||
|
@@ -24,7 +24,7 @@ Storing data in localStorage is useful, but it's not a good solution when you st | |
|
||
For instance, let's say you want to hide an announcement of a new feature after a user has seen it already. If use localStorage to solve this, then if a user switches browsers or devices they will continue to get the experience over and over again. | ||
|
||
That's where centralStorage comes in. Similar to localStorage, centralStorage allows you to easily store new data on the fly, but as a centralized storage solution it is persistent for users across browsers and devices in order to provide a better end user experience. | ||
That's where remoteStorage comes in. Similar to localStorage, remoteStorage allows you to easily store new data on the fly, but as a centralized storage solution it is persistent for users across browsers and devices in order to provide a better end user experience. | ||
|
||
## Features | ||
|
||
|
@@ -40,22 +40,22 @@ That's where centralStorage comes in. Similar to localStorage, centralStorage al | |
Install the library: | ||
|
||
```bash | ||
npm install central-storage | ||
npm install remote-storage | ||
``` | ||
|
||
Import the library and use it like you would localStorage: | ||
|
||
```javascript | ||
import { CentralStorage } from 'central-storage' | ||
import { RemoteStorage } from 'remote-storage' | ||
|
||
|
||
const centralStorage = new CentralStorage({ serverUrl: 'https://server.centralstorage.dev' }) | ||
const remoteStorage = new RemoteStorage({ serverUrl: 'https://server.centralstorage.dev' }) | ||
|
||
|
||
const hasSeenNewFeature = await centralStorage.getItem('hasSeenNewFeature') | ||
const hasSeenNewFeature = await remoteStorage.getItem('hasSeenNewFeature') | ||
|
||
if (!hasSeenNewFeature) { | ||
await centralStorage.setItem('hasSeenNewFeature', true) | ||
await remoteStorage.setItem('hasSeenNewFeature', true) | ||
} | ||
``` | ||
|
||
|
@@ -65,25 +65,25 @@ That's it! | |
|
||
### User IDs | ||
|
||
centralStorage uses user IDs to identify users. A user ID is a string that uniquely identifies a user. It can be anything you want, but we recommend using a UUID. | ||
remoteStorage uses user IDs to identify users. A user ID is a string that uniquely identifies a user. It can be anything you want, but we recommend using a UUID. | ||
|
||
The User ID is set when you create a new instance of centralStorage: | ||
The User ID is set when you create a new instance of remoteStorage: | ||
|
||
```javascript | ||
const centralStorage = new CentralStorage({ | ||
const remoteStorage = new RemoteStorage({ | ||
serverUrl: 'https://server.centralstorage.dev', | ||
userId: '123e4567-e89b-12d3-a456-426614174000' | ||
}) | ||
``` | ||
|
||
### Instance IDs | ||
|
||
centralStorage uses instance IDs to identify the application instance that is making the request. An instance ID is a string that uniquely identifies an application instance. Typically you would use the same instance ID for all requests from the same application instance. | ||
remoteStorage uses instance IDs to identify the application instance that is making the request. An instance ID is a string that uniquely identifies an application instance. Typically you would use the same instance ID for all requests from the same application instance. | ||
|
||
The instance ID is set when you create a new instance of centralStorage: | ||
The instance ID is set when you create a new instance of remoteStorage: | ||
|
||
```javascript | ||
const centralStorage = new CentralStorage({ | ||
const remoteStorage = new RemoteStorage({ | ||
serverUrl: 'https://server.centralstorage.dev', | ||
userId: '123e4567-e89b-12d3-a456-426614174000', | ||
instanceId: 'my-cool-app' | ||
|
@@ -97,8 +97,8 @@ We offer a free hosted community server at `https://server.centraldstorage.dev`. | |
The server can be spun up using Docker in a few minutes. To get started, simply clone the repository and run `docker-compose up`: | ||
|
||
```bash | ||
git clone [email protected]:FrigadeHQ/central-storage.git | ||
cd central-storage/apps/server | ||
git clone [email protected]:FrigadeHQ/remote-storage.git | ||
cd remote-storage/apps/server | ||
docker-compose up | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"openapi":"3.0.0","paths":{"/":{"get":{"operationId":"AppController_root","parameters":[],"responses":{"200":{"description":""}}}},"/entities/{key}":{"get":{"operationId":"EntitiesController_get","summary":"Get a entity by key","parameters":[],"responses":{"200":{"description":"The entity has been successfully returned."},"404":{"description":"The entity was not found."}},"tags":["entities"],"security":[{"bearer":[]}]}}},"info":{"title":"centralStorage API","description":"","version":"1.0","contact":{}},"tags":[],"servers":[],"components":{"schemas":{}}} | ||
{"openapi":"3.0.0","paths":{"/":{"get":{"operationId":"AppController_root","parameters":[],"responses":{"200":{"description":""}}}},"/entities/{key}":{"get":{"operationId":"EntitiesController_get","summary":"Get a entity by key","parameters":[],"responses":{"200":{"description":"The entity has been successfully returned."},"404":{"description":"The entity was not found."}},"tags":["entities"],"security":[{"bearer":[]}]}}},"info":{"title":"remoteStorage API","description":"","version":"1.0","contact":{}},"tags":[],"servers":[],"components":{"schemas":{}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# central-storage | ||
# remote-storage | ||
|
||
## 0.0.3 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export const HEADER_GLOBAL_STORAGE_INSTANCE_ID = 'x-central-storage-instance-id' | ||
export const HEADER_GLOBAL_STORAGE_USER_ID = 'x-central-storage-user-id' | ||
export const HEADER_GLOBAL_STORAGE_INSTANCE_ID = 'x-remote-storage-instance-id' | ||
export const HEADER_GLOBAL_STORAGE_USER_ID = 'x-remote-storage-user-id' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { CentralStorage } from './core/central-storage' | ||
export { RemoteStorage } from './core/remote-storage' | ||
export * from './core/constants' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {RemoteStorage} from '../src' | ||
|
||
describe('global storage', () => { | ||
// it('should be able to set and get an item', async () => { | ||
// const remoteStorage = new RemoteStorage('http://localhost:3000', 'instanceId', 'userId') | ||
// await remoteStorage.setItem('key', 'value') | ||
// const value = await remoteStorage.getItem('key') | ||
// expect(value).toEqual('value') | ||
// }) | ||
// | ||
// it('should be able to set and remove an item', async () => { | ||
// const remoteStorage = new RemoteStorage('http://localhost:3000', 'instanceId', 'userId') | ||
// await remoteStorage.setItem('key', 'value') | ||
// await remoteStorage.removeItem('key') | ||
// const value = await remoteStorage.getItem('key') | ||
// expect(value).toEqual(null) | ||
// }) | ||
|
||
it('should throw an error if not initialized', async () => { | ||
const remoteStorage = new RemoteStorage('', '', '') | ||
try { | ||
await remoteStorage.setItem('key', 'value') | ||
} catch (error: any) { | ||
expect(error.message).toEqual( | ||
'remoteStorage has not been initialized. Please call remoteStorage.init() first.' | ||
) | ||
} | ||
}) | ||
}) |