In order to have the least boilerplate code possible between my Client - Server stack i would like to define my REST Api & Model layer just once.
So ideally i would like to have on the server side for example an endpoint that gets the user:
Server
Model
interface User { id: number; name: string;}
Endpoint (returns User)
/User/id {GET}
Client
On my ReactNative or React client i would like to be able to re-use the code from the server side in a simple manner like bellow:
import { MyRestAPI , User } from "../Server/API"; //(In case of mono repo shared code approach)function GetUserDetails() : User{ let user = await MyRestAPI.GetUser(currentUserId);}
Is there a simple way ?