-
Couldn't load subscription status.
- Fork 0
Global Middleware Considerations
Similar to service middleware, you can use the container to access the registered services. This enables you to have full control for implementing the necessary logic in your global middleware, but it has the same limitation. If you call any service within the global middleware, you will get an infinite loop in your global middleware.
To avoid the infinite loop, you can use the proxyMiddleware option to disable the middleware proxy, but you need to
do this for each service that you want to use in the global middleware.
container.middleware.addGlobal((next, context, args) => {
const { container } = context;
// Get the services
const services = container.getAll({ proxyMiddleware: false });
// Now we can use the services without the infinite loop
const random = services.Service1().getRandom();
const uniqId = services.Service2().getUniqId();
return next(args);
})We welcome contributions from the community! Whether it's reporting a bug, suggesting a feature, or contributing code, your involvement is key to making Packet.js better. Please check out this section for more details.
If you encounter any issues or bugs while using packetjs, or if you have any feature requests, please feel free to
open an issue in our GitHub repository. You can report issues, track progress, and engage in discussions with the
community via the following link:
If you have any questions or need further assistance, feel free to reach out via the discussion board.