in tree config and updates to config model optional fields #196
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is it?
A new module,
src/config/index.ts
, exports a function that generates anIConfig
orundefined
.By default, it returns
undefined
, and is ignored.If you change it to return an object implementing
IConfig
(such as the included example), RESTool will use that as the active configuration.Justification
RESTool is easy to use and can be updated just by deploying a configuration file, but complex configurations are difficult to manage by hand, and cannot be linted by a code editor.
This module allows:
This requires using RESTool in dev mode, and deploying updates. See "How to develop", below.
Other changes
Some config interfaces in
src/common/models/config.model.ts
have been updated to reflect that some fields are optional. Some other source files have had their function signatures updated to reflect that they are already capable of dealing with optional parameters.Looking forward
The updates to the
IConfig
model could later facilitate the use of RESTool as a react component library, after a not too extensive refactor. In order to do this, it will be necessary to have the App component accept a configuration as props. This is not implemented, but would not be too difficult.How to develop
How to deploy:
Then deploy the generated
build
directory.Q&A
If I use in tree config, do I have to redeploy the whole app instead of just a configuration file, to make changes?
Yes
Should I keep my own copy of RESTool in version control to use in-tree-config
Yes. To update RESTool, you can use git to merge upstream changes into your repository.
Can't I just use RESTool as a react component library, and include it in my own react application?
Not yet. I intend to make a future PR which enables this, later on. At this point, you will be able to upgrade to the latest RESTool by modifying your package.json or typing:
Why is this better than just willy nilly updating the already existing RESTool codebase?
This update implements the loader that makes sure RESTool uses your config if available. It also makes it simple to contain your modifications in a directory, so they will be very easy to port when RESTool exports the config model.
Can I just use the config model in my own repository, and use typescript to compile that config down to a javascript config?
Not at this time. That will be possible after RESTool exports the config model. I am looking into doing that in an upcoming feature submission.
Can I use RESTool as a component in my own app
Not at this time. It is possible to refactor RESTool so that it would be available as a component library, but that has not been done yet.