A modules is a standalone piece of code composed by a backend part and/or frontend part.
The frontend part of a module is executed on a users browser, but the backend part requires a server to run on.
STLSe gives you the option to run your backend module either on the STLSe infrastructure as a "internal" module, or you can connect your own server through GRPC and have an "exernal" module.
To summarize:
Internal Module is a module that is running on the STLSe infrastructure
External Module is a module that is running on your own server and connects to STLSe through GRPC calls
When a module is uploaded and handled by the STLSe infucrastrture it is executed in a sandbox environment that does not have many of the NodeJS default functions and packages. For example: "util", "fs", "http", ..etc.
For this reason when we create a module that we intend to upload and use as internal module we should add polyfills to the default functions of NodeJS that we intend to use and are not already present.
Out of the box, the following are already present:
Other Restrictions:
use_backend_action.stlse_request
hook insteadThese restriction are in place to allow everyone to deploy the module and run it completely for free.
There is the option to upgrade the account an remove/increase some of the limits.
Benefits:
When to use:
Internal module are a viable solution for 80%-90% of tasks that a webapp/website may do, it should be the default option and if you need specific requirements from your module that are not possible due to the restriction, then you can switch to the external module deployment
How to deploy:
You need to create a zip file with the following structure:
frontend/ -- module-entry.js backend/ -- module-entry.js
module-entry.js
.After you've created this zip file, you can head over to the STLSe Admin Panel where you can upload an internal version by selecting the zip file specified.
An external module is hosted on server outside of STLSe and connected via GRPC, meaning that you are free to develop in whatever language/framework you prefer and use any api that are available. There is no difference to the user in how an internal module behaves compared to the external one.
Drawbacks of using external module:
Benefits:
When to use:
External modules have no restrictions of usage so when the Internal Modules restriction are limiting your use case, you should switch to the external module.
Some examples:
How to deploy:
You need to have:
Create the external deployment of the module with the following information:
my_module.stlse.com
39102
module-entry.js
file of the frontend part of the module, e.g. https://my_module.stlse.com/frontend/module-entry.js
Before building your module make sure that you have genearted a secret from the deployment that you've just created and you place this secret in the remote
field in your environment.prod.ts
file.
After you build your module you will have:
https://my_module.stlse.com/frontend/module-entry.js
node module-entry.js
If all is configured properly when you launch your backend part you should see a successfull GRPC connection, and if you open the frontend path you should see the module-entry.js file of your module. If that is the case then you can add your module to an application and start using it!
Note:
It is possible to host the backend module by using the free tunnel subdomain .tunnel.local
, but this approach is heavily discourage due to potential network issues and other factors that may make the tunnel unreliable, for this reason we recommend to use tunnelling only for development and testing purposes!