staticbackendhq / core

Backend server API handling user mgmt, database, storage and real-time component
https://staticbackend.com
MIT License
682 stars 66 forks source link

Extract less common features into plugins #117

Closed dstpierre closed 1 month ago

dstpierre commented 1 month ago

Since the size of the CLI is around 170 MB because of the chromedp package allowing for HTML to PDF, and HTML to PNG, it might be worth having that funtionality into a plugin.

Go's plugin package would be great for this. The core package could load this plugin when a call is made to the endpoint to render a PDF.

The down-side is that the compiled plugin will need to be manually copied with the server binary file. But it will decrease the size of the CLI significantly.

Having a plugin architecture will open all sorts of enhancement without affecting the core package, which should keep simple and lightweight.

For now only the conversion to PDF will be extracted and available from a plugin.

This will not break the v1 API as the endpoint will not change, but will require two steps when deploying:

  1. Add an environment variable PLUGINS_PATH which points to the directory where the *.so plugins are available.
  2. The *.so files will need to be copied to that location.

This might even be opening writing server-side function into Go instead of JavaScript. But this is not planned yet.