-
Couldn't load subscription status.
- Fork 0
Adding Properties
You can add configuration properties, which are useful for service registration or making settings available throughout the application.
To add properties from a file in JSON format, use the following code:
// Add properties from some file in json format
const properties = require('./index.json');
container.addProps(properties);To retrieve the properties, use the code below:
const properties = container.getProps();You can also get the properties when registering a new service as follows:
container.add('Service', ({ props }) => {
return new Service(props.someProperty);
});To add new properties to existing ones:
container.addProps({
newProperty: { foo: 'bar' }
});The
addProps()method will overwrite any existing properties that have the same name.
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.