Skip to content

Conversation

achrinza
Copy link
Member

@achrinza achrinza commented Apr 18, 2021

This PR should be bundled with other breaking changes.

Dynamic Disable
The enhancer can now be dynamically enabled & disabled after being bound.

This feature is intended to provide flexibility for LoopBack applications to have more "instant" configuration control during runtime without requiring a blocking rebind.

Static Class Members
Class members that do not require knowledge of the class state are now static.

Signed-off-by: Rifa Achrinza [email protected]

Checklist

  • DCO (Developer Certificate of Origin) signed in all commits
  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

👉 Check out how to submit a PR 👈

@achrinza achrinza added feature breaking-change OpenAPI REST Issues related to @loopback/rest package and REST transport in general labels Apr 18, 2021
@achrinza achrinza force-pushed the feat/static-oas-consolidator branch from f5139bb to a3c4345 Compare April 18, 2021 14:04
BREAKING CHANGE: Certain class members are now static and `disabled` is
a potentially-async getter only.

**Dynamic Disable**
The enhancer can now be dynamically enabled & disabled after being bound.

**Static Class Members**
Class members that do not require knowledge of the class state are now static.

Signed-off-by: Rifa Achrinza <[email protected]>
@achrinza achrinza force-pushed the feat/static-oas-consolidator branch from a3c4345 to 798de8b Compare April 18, 2021 14:11
Comment on lines +84 to +85
@inject.view(filterByKey(CoreBindings.APPLICATION_CONFIG.key))
private _config: ContextView<ApplicationConfig>,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should move this to property injection.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you modifying the _config object afterwards?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ContextView would allow modification of the configuration after the ConsolidationEnhancer is initialised, which would give a better developer experience instead of having to re-bind the enhancer for those who need a more "dynamic" configuration.

@@ -152,22 +177,22 @@ export class ConsolidationEnhancer implements OASEnhancer {
return schema;
}

private patchRef(
private static patchRef(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static patchRef(
private static _patchRef(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why changing the name? Do we have a convention to use _ for private declaration names?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ctrl + Shift + F on vscode shows that this naming convention is being used across several packages:

private _scope?: BindingScope;
/**
* Scope of the binding to control how the value is cached/shared
*/
public get scope(): BindingScope {
// Default to TRANSIENT if not set
return this._scope ?? BindingScope.TRANSIENT;
}
/**
* Type of the binding value getter
*/
public get type(): BindingType | undefined {
return this._source?.type;
}
private _cache: WeakMap<Context, ValueOrPromise<T>>;
private _getValue?: ValueFactory<T>;

private _isShuttingDown = false;
private _shutdownOptions: ShutdownOptions;
private _signalListener: (signal: string) => Promise<void>;
private _initialized = false;
/**
* State of the application
*/
private _state = 'created';

private _listening = false;
private _protocol: HttpProtocol;
private _address: string | AddressInfo;
private requestListener: RequestListener;
readonly server: http.Server | https.Server;
private _stoppable: stoppable.StoppableServer;

@stale stale bot added the stale label Sep 11, 2021
@achrinza achrinza removed the stale label Sep 11, 2021
@stale stale bot added the stale label Nov 10, 2021
@loopbackio loopbackio deleted a comment from stale bot Dec 17, 2021
@loopbackio loopbackio deleted a comment from stale bot Dec 17, 2021
@achrinza achrinza removed the stale label Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change feature OpenAPI REST Issues related to @loopback/rest package and REST transport in general
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants