Skip to content

Commit

Permalink
rename to central storage
Browse files Browse the repository at this point in the history
  • Loading branch information
christianmat committed Jan 3, 2024
1 parent 4e39a75 commit 82e7fbe
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 3,601 deletions.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": [
"global-storage-server"
"central-storage-server"
]
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<H3 align="center"><strong>globalStorage</strong></H3>
<div align="center">globalStorage is an open source library and server with the same API as localStorage that allows you to store data in a centralized storage.</div>
<H3 align="center"><strong>centralStorage</strong></H3>
<div align="center">centralStorage is an open source library and server with the same API as localStorage that allows you to store data in a centralized storage.</div>
<br />
<div align="center">
<a href="https://frigade.com">Website</a>
Expand Down
5 changes: 3 additions & 2 deletions apps/server/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "global-storage-server",
"name": "central-storage-server",
"version": "0.0.1",
"description": "",
"author": "",
"license": "MIT",
"private": true,
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
Expand Down Expand Up @@ -31,7 +32,7 @@
"@nestjs/platform-fastify": "^9.3.8",
"@nestjs/schedule": "^3.0.2",
"@nestjs/swagger": "^6.1.4",
"global-storage": "*",
"central-storage": "*",
"husky": "^8.0.3",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/entities/entities.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { EntitiesService } from './entities.service'
import { NotFoundInterceptor } from '../middlewares/not-found.interceptor'

import { Actor, Entity } from './entities.interface'
import { HEADER_GLOBAL_STORAGE_INSTANCE_ID, HEADER_GLOBAL_STORAGE_USER_ID } from 'global-storage'
import { HEADER_GLOBAL_STORAGE_INSTANCE_ID, HEADER_GLOBAL_STORAGE_USER_ID } from 'central-storage'

const publicApiPrefix = '/entities/'

Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as fs from 'fs'
import * as process from 'process'
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'
import { AppClusterService } from './appCluster.service'
import { HEADER_GLOBAL_STORAGE_INSTANCE_ID, HEADER_GLOBAL_STORAGE_USER_ID } from 'global-storage'
import { HEADER_GLOBAL_STORAGE_INSTANCE_ID, HEADER_GLOBAL_STORAGE_USER_ID } from 'central-storage'

const CORS_OPTIONS = {
origin: '*',
Expand Down Expand Up @@ -44,7 +44,7 @@ async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(AppModule, fastifyAdapter)

if (process.env.NODE_ENV === 'development') {
const options = new DocumentBuilder().setTitle('globalStorage API').setVersion('1.0').build()
const options = new DocumentBuilder().setTitle('centralStorage API').setVersion('1.0').build()
const document = SwaggerModule.createDocument(app, options)

fs.writeFileSync('./swagger-spec.json', JSON.stringify(document))
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@frigadehq/global-storage",
"name": "@frigadehq/central-storage",
"version": "0.0.1",
"license": "MIT",
"description": "globalStorage is an open source library and server with the same API as localStorage that allows you to store data in a centralized storage.",
"description": "centralStorage is an open source library and server with the same API as localStorage that allows you to store data in a centralized storage.",
"workspaces": [
"apps/*",
"packages/*"
Expand Down
2 changes: 1 addition & 1 deletion packages/js-client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# global-storage
# central-storage

## 0.0.3

Expand Down
18 changes: 7 additions & 11 deletions packages/js-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,13 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/FrigadeHQ/javascript.git"
"url": "git+https://github.com/FrigadeHQ/central-storage.git"
},
"keywords": [
"Onboarding",
"Tutorial",
"Intro",
"Checklist",
"Welcome",
"Tooltips",
"Tour",
"Walkthrough",
"localStorage",
"centralStorage",
"central",
"storage",
"Javascript"
],
"devDependencies": {
Expand All @@ -57,9 +53,9 @@
"author": "Frigade Inc.",
"license": "MIT",
"bugs": {
"url": "https://github.com/FrigadeHQ/global-storage/issues"
"url": "https://github.com/FrigadeHQ/central-storage/issues"
},
"homepage": "https://github.com/FrigadeHQ/global-storage",
"homepage": "https://github.com/FrigadeHQ/central-storage",
"dependencies": {
"cross-fetch": "^4.0.0"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetch from 'cross-fetch'

export class GlobalStorage {
export class CentralStorage {
private readonly serverAddress: string
private readonly instanceId: string
private readonly userId: string
Expand Down Expand Up @@ -28,7 +28,7 @@ export class GlobalStorage {
// Throw error if not initialized
if (!this.serverAddress || !this.instanceId || !this.userId) {
throw new Error(
'globalStorage has not been initialized. Please call globalStorage.init() first.'
'centralStorage has not been initialized. Please call centralStorage.init() first.'
)
}

Expand Down
4 changes: 2 additions & 2 deletions packages/js-client/src/core/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const HEADER_GLOBAL_STORAGE_INSTANCE_ID = 'x-global-storage-instance-id'
export const HEADER_GLOBAL_STORAGE_USER_ID = 'x-global-storage-user-id'
export const HEADER_GLOBAL_STORAGE_INSTANCE_ID = 'x-central-storage-instance-id'
export const HEADER_GLOBAL_STORAGE_USER_ID = 'x-central-storage-user-id'
2 changes: 1 addition & 1 deletion packages/js-client/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { GlobalStorage } from './core/global-storage'
export { CentralStorage } from './core/central-storage'
export * from './core/constants'
29 changes: 29 additions & 0 deletions packages/js-client/test/central-storage.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { CentralStorage } from '../src'

describe('global storage', () => {
// it('should be able to set and get an item', async () => {
// const centralStorage = new CentralStorage('http://localhost:3000', 'instanceId', 'userId')
// await centralStorage.setItem('key', 'value')
// const value = await centralStorage.getItem('key')
// expect(value).toEqual('value')
// })
//
// it('should be able to set and remove an item', async () => {
// const centralStorage = new CentralStorage('http://localhost:3000', 'instanceId', 'userId')
// await centralStorage.setItem('key', 'value')
// await centralStorage.removeItem('key')
// const value = await centralStorage.getItem('key')
// expect(value).toEqual(null)
// })

it('should throw an error if not initialized', async () => {
const centralStorage = new CentralStorage('', '', '')
try {
await centralStorage.setItem('key', 'value')
} catch (error: any) {
expect(error.message).toEqual(
'centralStorage has not been initialized. Please call centralStorage.init() first.'
)
}
})
})
29 changes: 0 additions & 29 deletions packages/js-client/test/global-storage.test.ts

This file was deleted.

Loading

0 comments on commit 82e7fbe

Please sign in to comment.