Skip to content

Adding Properties

Francisco Ruiz edited this page Aug 27, 2024 · 1 revision

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.

1. Getting Started

2. Core Concepts

3. Middleware

4. Caching and Memoization

5. Typescript

6. Considerations

7. API Reference

8. Examples and Use Cases

9. Contributing

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.

10. Support

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:

11. FAQ

If you have any questions or need further assistance, feel free to reach out via the discussion board.

12. License

Clone this wiki locally