You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Serva is interface-less, meaning that there is no way for developers to use the application instance. We need a way for files that mount to be able to plugin into the application without the developer knowing. This becomes more apparent when exploring hooks. We want routes to be able to define specific hooks for that route. Currently there is no way to do so as we expect the default export to be a callback.
Proposal
Factories will help perform some kind of "on mount" action before it mounts it to the application. The signature of a factory could be as follows:
import{factory}from"https://serva.land/serva@latest/mod.ts";exportdefaultfactory(async(api,meta)=>{awaitapi.task();// return what should be mountedreturn()=>{};});
Factories should accept two arguments. An api that the factory provides to consumers to increase the functionality of the current mount. meta, which will be any additional values or information that may come useful to the developer when using factories.
It should be noted that factories are not required, we should always be able to mount the default export.
The application should have some mechanism to identify that the default export is a factory and handle it accordingly. For example, if we were to use a route factory the application should be able to mount the route it returns/resolves.
The text was updated successfully, but these errors were encountered:
Problem
Serva is interface-less, meaning that there is no way for developers to use the application instance. We need a way for files that mount to be able to plugin into the application without the developer knowing. This becomes more apparent when exploring hooks. We want routes to be able to define specific hooks for that route. Currently there is no way to do so as we expect the default export to be a callback.
Proposal
Factories will help perform some kind of "on mount" action before it mounts it to the application. The signature of a factory could be as follows:
Factories should accept two arguments. An
api
that the factory provides to consumers to increase the functionality of the current mount.meta
, which will be any additional values or information that may come useful to the developer when using factories.It should be noted that factories are not required, we should always be able to mount the default export.
The application should have some mechanism to identify that the default export is a factory and handle it accordingly. For example, if we were to use a route factory the application should be able to mount the route it returns/resolves.
The text was updated successfully, but these errors were encountered: