NextChat
NextChat copied to clipboard
[Feature Request]: Switching to unified sync protocol and using tauri http package for native client
Let's turn it into a RPC, here is a proposal:
type WebDavConfig = {
type: 'webdav',
endpoint: string,
username: string,
password: string
}
type UpstashConfig = {
type: 'upstash',
endpoint: string,
username: STORAGE_KEY,
apiKey: string
}
type SyncAction = {
type: 'check'
} | {
type: 'get',
key: string,
} | {
type: 'set',
key: string,
value: string
}
type SyncPayload = {
config: WebDavConfig | UpstashConfig,
action: SyncAction
}
// client side
function createUpstashClient() {
return async check() {
return await call('/api/sync', { /* webdav config */ })
},
// get(key), set(key, value)
}
// server side, /api/sync/route.ts
async function handle(req) {
const payload = JSON.parse(await req.json()) as SyncPayload;
// dispatch payload to server side check/get/set actions
}
The main idea is to move all the sync actions that were previously done on the client side to the server side. The downside is that the desktop app can no longer use the sync feature unless we keep the official sync endpoint built in.
Originally posted by @Yidadaa in https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/issues/4285#issuecomment-1995145175
Also, For Tauri/desktop applications
, it is more secure and safe, plus developers can easily leverage its features (e.g, laverage feature that not possible for web version
), especially since it is written in Rust.
feature that not possible for web version