-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): improve storage API, move store & http from app to global
- Loading branch information
1 parent
c97c5f0
commit 8c3fa75
Showing
6 changed files
with
70 additions
and
10 deletions.
There are no files selected for viewing
Submodule cli
updated
from ba6084 to f1d681
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,13 +1,9 @@ | ||
import type { AppHttp } from './http'; | ||
import type { AppLogger } from './logger'; | ||
import type { AppPrompt } from './prompt'; | ||
import type { AppStorage } from './storage'; | ||
import type { AppUtils } from './utils'; | ||
|
||
export type App = { | ||
log: AppLogger; | ||
http: AppHttp; | ||
prompt: AppPrompt; | ||
store: AppStorage; | ||
utils: AppUtils; | ||
}; |
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,7 +1,9 @@ | ||
import { App } from './app'; | ||
import { AppStorage } from './storage'; | ||
import { AppHttp } from './http'; | ||
|
||
declare global { | ||
const app: App; | ||
const storage: AppStorage; | ||
const http: AppHttp; | ||
} |
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,8 @@ | ||
export type AppStorage = { | ||
state: Record<string, any>; | ||
getState: <T = any>(cookiesKey?: string | null) => Promise<T>; | ||
setState: <T = Record<string, any>>(data?: T) => Promise<void>; | ||
}; | ||
export type AppStorage<T = Record<string, any>> = { | ||
load(): Promise<void>; | ||
get(key: string): Promise<any>; | ||
set(key: string, value: any): Promise<void>; | ||
delete(key: string): Promise<void>; | ||
clear(): Promise<void>; | ||
save(items: T): Promise<void>; | ||
} & T; |
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