NextChat icon indicating copy to clipboard operation
NextChat copied to clipboard

[Feature Request]: Switching to unified sync protocol and using tauri http package for native client

Open fred-bf opened this issue 11 months ago • 2 comments

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

fred-bf avatar Mar 13 '24 18:03 fred-bf

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.

H0llyW00dzZ avatar Mar 13 '24 18:03 H0llyW00dzZ

feature that not possible for web version

Amaan1532 avatar May 07 '24 13:05 Amaan1532