You can put away your safety goggles, this post does not involve nuclear fusion. Instead, this will be a brief overview of some of the features in Fusion.js and its plugins.
Some operations are required only by specific environments, such as dealing with file systems or accessing browser APIs. For these use cases, the entry point file offers two variables to delineate client and server logic: __NODE__ and __BROWSER__.
This means that when the app is built, the compiler will only bundle the code required for that environment, __NODE__ for server, and __BROWSER__ for the client.
Plugins act as a service, a middleware, or both at once, handling requests and processing data for the client to consume. They can be chained together and used to handle API routes, add logging, and many other operations.
Plugins are created using the createPlugin function and are composed of three simple elements:
Here is a simple example of a plugin that calculates the area of certain shapes and passes the area to a logger.
Creating an HTTP endpoint and displaying the results of a request using the services created in another plugin can be accomplished by passing the plugin as a dependency to the middleware.
Straight out of the box, Fusion.js offers support for a suite of modern testing utilities, including Jest, Enzyme, and Puppeteer. When writing tests, a plugin and its dependencies is easily simulated, thanks to the nature of dependency injection.
These are just a few of the features available with Fusion.js. Check out the Fusion documentation for more information.
We’d love to learn more about your project.
Engagements start at $50,000.