Skip to content

Convert configs to classes instead of interfaces#5114

Open
strawburster wants to merge 2 commits intoDSpace:mainfrom
strawburster:config-refactor
Open

Convert configs to classes instead of interfaces#5114
strawburster wants to merge 2 commits intoDSpace:mainfrom
strawburster:config-refactor

Conversation

@strawburster
Copy link
Contributor

@strawburster strawburster commented Feb 14, 2026

References

Add references/links to any related issues or PRs. These may include:

Description

Refactor app configuration to use class instances instead of interfaces. The benefit is that decorators can be used to specify metadata about config properties.

The decorators supplied in this PR for config properties are @Config.publish() @Config.env(name: string, loader?: (val: string) => any) and @Config.arrayOf(configClass)

  • publish

This will mark a config property as 'public', which is used in the 'toPublic' method to filter only properties which should be available publicly.

  • env

This will mark a config property as being able to be overridden by an environment variable with a specific name, and optionally a loader function which takes the string environment variable as its only parameter and returns the correct type for the property.

  • arrayOf

This will mark a property as being an array of a specific type of config, so that when merging the config with a plain object, array properties are instantiated correctly.

Instructions for Reviewers

Please add a more detailed description of the changes made by your PR. At a minimum, providing a bulleted list of changes in your PR is helpful to reviewers.

List of changes in this PR:

  • First, ...
  • Second, ...

Include guidance for how to test or review your PR. This may include: steps to reproduce a bug, screenshots or description of a new feature, or reasons behind specific changes.

Checklist

This checklist provides a reminder of what we are going to look for when reviewing your PR. You do not need to complete this checklist prior creating your PR (draft PRs are always welcome).
However, reviewers may request that you complete any actions in this list if you have not done so. If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes ESLint validation using npm run lint
  • My PR doesn't introduce circular dependencies (verified via npm run check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • My PR aligns with Accessibility guidelines if it makes changes to the user interface.
  • My PR uses i18n (internationalization) keys instead of hardcoded English text, to allow for translations.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

@strawburster strawburster force-pushed the config-refactor branch 2 times, most recently from eac17b3 to a5482b2 Compare February 16, 2026 10:06
@github-actions
Copy link

Hi @strawburster,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

@tdonohue tdonohue moved this to 🙋 Needs Reviewers Assigned in DSpace 10.0 Release Feb 20, 2026
@strawburster
Copy link
Contributor Author

The server failed to start, and I need the e2e results to move forward. Please re run this either once the server image is fixed or if you believe it was a fluke.

@github-actions
Copy link

Hi @strawburster,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

Within class definitions, decorators defined in src/config/config.ts
can set environment variables, whether or not a property should be
publicly available, and what the type of a property is.

The class definitions also allow default values to be set for each
property.

Removes BuildConfig, DefaultAppConfig, and ServerConfig in favor of
using a single class, AppConfig, everywhere.
@strawburster strawburster changed the title WIP: Convert configs to objects instead of interfaces Convert configs to objects instead of interfaces Mar 12, 2026
@strawburster strawburster changed the title Convert configs to objects instead of interfaces Convert configs to classes instead of interfaces Mar 12, 2026
@strawburster
Copy link
Contributor Author

Many more env and deepEnv decorators are needed in order to fully duplicate all currently available environment variables, I've only added the ones necessary to pass the tests so far. I would like some feedback on the approach. The core of it all is src/config/config.ts, which I feel is well documented. You can see it in use all throughout the folder. Most changes outside the src/config folder are just dropping the '-interface' in the filename for each config. The DefaultAppConfig, the config.server file, and the BuildConfig are all gone; instead AppConfig is the only type used throughout the project, and visibility is limited based on the decorators. The default values for config properties are defined, when possible, in the same file within the class definitions they are a part of. The comments within these need to be trimmed down because I copied a lot of duplicate things out of the DefaultAppConfig.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 🙋 Needs Reviewers Assigned

Development

Successfully merging this pull request may close these issues.

Limit configuration available publicly in config.json

2 participants