Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in tree config and updates to config model optional fields #196

Merged
merged 5 commits into from
Jan 8, 2022

Conversation

richard-fairthorne
Copy link
Contributor

@richard-fairthorne richard-fairthorne commented Jan 6, 2022

What is it?

A new module, src/config/index.ts, exports a function that generates an IConfig or undefined.

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:

  • linting and editor hinting
  • use of externally provided data transforms written in typescript
  • automatic generation of configuration using arbitrary external functions

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

npm run start

How to deploy:

npm run build

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:

npm i restool

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.

@richard-fairthorne richard-fairthorne changed the title F in tree configuration n tree configuration - feature branch Jan 6, 2022
@richard-fairthorne richard-fairthorne changed the title n tree configuration - feature branch in tree configuration - feature branch Jan 6, 2022
@richard-fairthorne richard-fairthorne changed the title in tree configuration - feature branch in tree config and updates to config model optional fields Jan 6, 2022
@dsternlicht dsternlicht merged commit 42662f3 into dsternlicht:master Jan 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants