Get Started
As an app grows, you will want to break it up into separate files. Zeta is built purposefully to support this.
There are two types of apps:
listen() on and add child apps to.
"/health",new Response"OK"
apiApp
3000;
By default, app state is isolated from any children and vise-versa. Any modifications made to the child app are not available in the top-level app:
"/child/**",;
childApp
"/**",;
And modifications made to the top-level app are not available in child apps:
;
childApp
"/**",;
Isolation is enforced by the type-system. In both cases, you'll get a type error saying example is not available.
Sometimes, you need to reuse logic between child and top-level apps. To do this, you create a "plugin", and add it to any app that needs it.
A "plugin" is just an app, but one that calls export() to break the isolation apps have by default:
;
plugin
"/child/**",;
childApp
"/**",;
Note that the child app is still isolating it's own state from the top-level app. That's why the example property is still not available in the top-level app.
You need to also use the plugin on the top-level app, or any other child app that needs it:
plugin
childApp
"/**",;
Zeta automatically deduplicates plugins when they are used multiple times. There is no runtime performance impact to using the same plugin multiple times in different apps that are eventually composed together.
When you use a plugin/child app, add a hook, or decorate the request context, order matters. Modifications like these are only applied to subsequent routes and operations after they are added to the app.
For example, when decorating the context with an example property, the value will only be available in routes defined after decorate() is called.
"/before",;
"/after",;
Once again, the type-system will help you catch these errors before running your app.
Note that order DOES NOT break isolation. Order only matters within the same app.
;
childApp
"/**",;
In this example, even though the child app is added after the context is decorated, the example property is not available in the child app.