Jean-Baptiste-Lasselle / grapejs-server

A bare grapesjs Instance served by asimple node/express static webserver
7 stars 1 forks source link

REFACTORING #5

Open Jean-Baptiste-Lasselle opened 5 years ago

Jean-Baptiste-Lasselle commented 5 years ago

private content in : https://gitlab.com/second-bureau/pegasus/recup

Some Refactoring will happen, so now i need tests before big moves. Tests are security for big plans.

So this issue is :

So Ok, Here i a little architecture/product roadmap :+1: , where i'll split server into multiple micro-services (having David Pageot's execellent presentation of K8S Istio in 2018 devoxx) :

{
  html: `<div>...</div>`,
  css: null,
  style: '.someclassbasedrule { background-color: #FEFEFE }  ; div section h2 {font-family: "Montserrat", sans-serif;}',
}

About that structure, see for example :

My GrapesJS Storage Manager

On the official GrapsJS documentation, You wll read in the Storage Manager guide :

const LandingPage = {
  html: `<div>...</div>`,
  css: null,
  components: null,
  style: null,
};
// see https://grapesjs.com/docs/modules/Storage.html#store-and-load-templates

What you have to understand here, is that the HTML the GrapesJs editor user is working on, is what the GrapesJS author calls The Canvas. And that the canvas is all set by three properties, namely html, css, style. I know it because I tested it my self, wih release 0.0.x, x being 1, 2, 3 4, 5, 6, and 7.

With seven things, I end up here , deciding that I will develop my own implementation of a "Storage Manager", and that it will send a request to a backend REST API (API that I will implement too), request with a JSON object

That REST API endpoint will be service 1, it will know how to persist a template modification persistance request, sent with a JSON Object as the payload to persist. The edited HTML/CSS will be persisted :

Jean-Baptiste-Lasselle commented 5 years ago

i'll probably use a streaming processing model like jacksons' in java for XMLand JSON, to parse the HTML in an event driven way, relyng on the "marks" left by the attributes data-omega-loader-href and data-omega-loader-src on tags. That way, we do only streaming on parsing HTML / XML (the mechnaism is extensible to MJML), instead of trying to remembervalues with such things as pmongo db, or even just a big JSON kept in RAM by NodeJS inside the os process context.

I found https://www.npmjs.com/package/parse5-sax-parser , which is both purposed specifically for HTML, not just XML (loike the one i'm currently using), and is a SAX style parser, based on event emission

Jean-Baptiste-Lasselle commented 5 years ago

Workflow

Actors

Initial Context

Jean-Baptiste-Lasselle commented 5 years ago

then :

How are signature checked?

So all in all a registry is something people give you a gaurantee about : "Yes this thing that I provide, does workk properly with that other thing"