simplajs / simpla

Open, modular, and serverless content management for a modern web
https://www.simplajs.org
MIT License
527 stars 36 forks source link

Move storage to adapter #77

Open madeleineostoja opened 6 years ago

madeleineostoja commented 6 years ago

I'm submitting a

Feature request

Description

Right now Simpla is tightly coupled to using Github as a backend. Instead, we should split both Auth and Storage into adapters. Under this setup the auth adapter would handle everything to do with user management, rather than just authenticating an access token with github, and the storage adapter would just check with the auth adapter whether a change can be written, and then go ahead and write that change to where it's configured to.

Public API would stay relatively unchanged

Simpla.init({
  storage: new SimplaGithub({ repo: 'username/repo' }),
  auth: new SimplaNetlify({ site: 'mysite' }),
  ...
});
bedeoverend commented 6 years ago

It'd be great if we could land this earlier than 4, to unblock things like #84. We could just split out the current adapter, but keep it as a fallback for if people don't supply one. Only downside here is people using an external adapter would still cary the weight of the builtin one (~1.2kb gzip)

IMO this is a worthwhile tradeoff to get it in earlier, as it'd only affect people wanting to use an external adapter. Can then properly strip out in version 4.

madeleineostoja commented 6 years ago

Sounds like double handling for the sake of it to me. If we really want to get this out before implementing observables (main planned breaking change for 4), we can bake a major version now and call that stuff 5.

Personally I'd prefer to hold off until we can bundle several breaking changes though, especially since we literally just released 3/OSS. We already know the interface for observables (mostly), so it's just implementation and updating the el behavior (which can stay on WC v0).

Or alternatively can just push it to a v4 branch or even master and not bake a release at all yet, then just install straight from git to use/test it.