fx-fotos
fx-fotos copied to clipboard
AWS backend implementation
Had a cool chat with @Roman-Uholnikov about an AWS backend implementation.
Below is my general suggestion on the structure for adding multiple backends, @ehsan6sha please chime in and advice if any of it doesn't make sense:
- Having a top level folder,
photos/backend
- A seperate folder for each backend stack:
photos/backend/icp
,photos/backend/aws
for the time being - A top level TypeScript interface with function signatures for all needed backend funnctionalities, all stacks implement this interface. Goes in:
photos/backend/apis.ts
- UI in settings page so that the user can choose between available backend stacks, I believe @emadbaqeri is working on an initial settings UI as part of #33
- Each implementation exports an object implementing the interface as its default root export, so when the backend is changed in settings we can do something like:
async function getBackend(selectedBackendKey: string) {
const { default: { uploadPicture, downloadPicture, ... } } = await import(`../backend/${selectedBackendKey}`)
return {
// demo only, actual signatures in "Backend" interface at ../backend/apis.ts
uploadPicture,
downloadPicture,
...
};
And then the UI will use APIs that are imported in the above line from ./backend/apis.ts
What do you guys think?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
To me it looks good. We can optimize line "const { default: { uploadPicture, downloadPicture, ... } } = await import(../backend/${selectedBackendKey}
)" though.