[英]JS web framework with transparent/autogenerated client-server data layer
我想知道是否存在具有透明/自動生成的數據層的JS Web框架? 為了節省時間,因此我不必自己編寫所有代碼。
假設我正在編寫React Blog應用,並使用REST API與服務器進行通信。
我需要在客戶端編寫兩個數據層,即服務器端和其客戶端。
類似於下面的代碼:
1業務邏輯本身位於服務器端:
class BlogAPI {
async getPosts() {
const records = await db.query('select * from posts')
return convertRecordsIntoPostObjects(records)
}
}
2將業務邏輯公開為REST API並在客戶端編寫其客戶端:
// REST API, this code also resides on the server side.
httpServer.get('/posts', () => blogApi.getPosts())
// And writing a client for it, that code resides on the client side.
class BlogAPIClient {
async getPosts() {
http.get('http://server-api-endpoint.com/posts')
}
}
我想知道是否存在以某種方式神奇地自動生成了第2部分的Web框架,因此我可以節省時間並只編寫業務邏輯。
PS:不要提GraphQL,這不是我要的。
流星看起來像您想要的東西: https : //www.meteor.com/tutorials/react/collections 。 另外,您可能希望了解一下Parse Server https://docs.parseplatform.org/parse-server/guide/#getting-started (也許還有Firebase,但它既不是可定制的也不是自托管的/開源的)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.