From 7df1e9d2beca76ad639cd8a0aa3f5a8c35d0d8a0 Mon Sep 17 00:00:00 2001 From: Yaapa Hage Date: Thu, 27 Aug 2020 12:39:16 +0530 Subject: [PATCH] chore: feedback Feedback Signed-off-by: Yaapa Hage --- docs/site/Component.md | 61 +++++++++++-------- packages/cli/generators/extension/index.js | 15 ++--- .../extension/templates/src/component.ts.ejs | 3 +- .../extension/templates/src/types.ts.ejs | 8 +++ 4 files changed, 55 insertions(+), 32 deletions(-) diff --git a/docs/site/Component.md b/docs/site/Component.md index 0f631a48ce80..17dcc9e11f85 100644 --- a/docs/site/Component.md +++ b/docs/site/Component.md @@ -88,31 +88,44 @@ app.component(AuthenticationComponent); Here is a list of components officially created and maintained by the LoopBack team. -- [@loopback/apiconnect](https://github.com/strongloop/loopback-next/tree/master/extensions/apiconnect) - An extension for IBM API Connect -- [@loopback/authentication](https://github.com/strongloop/loopback-next/tree/master/packages/authentication) - A LoopBack component for authentication support -- [@loopback/authentication-jwt](https://github.com/strongloop/loopback-next/tree/master/extensions/authentication-jwt) - Extension for the prototype of JWT - authentication -- [@loopback/authentication-passport](https://github.com/strongloop/loopback-next/tree/master/extensions/authentication-passport) - A package creating adapters between the - passport module and @loopback/authentication -- [@loopback/authorization](https://github.com/strongloop/loopback-next/tree/master/packages/authorization) - A LoopBack component for authorization support -- [@loopback/boot](https://github.com/strongloop/loopback-next/tree/master/packages/boot) - A collection of Booters for LoopBack 4 Applications -- [@loopback/booter-lb3app](https://github.com/strongloop/loopback-next/tree/master/packages/booter-lb3app) - A booter component for LoopBack 3 applications to - expose their REST API via LoopBack 4 -- [@loopback/context-explorer](https://github.com/strongloop/loopback-next/tree/master/extensions/context-explorer) - Visualize context hierarchy, bindings, - configurations, and dependencies -- [@loopback/cron](https://github.com/strongloop/loopback-next/tree/master/extensions/cron) - Schedule tasks using cron-like syntax -- [@loopback/extension-health](https://github.com/strongloop/loopback-next/tree/master/extensions/health) - An extension exposes health check related - endpoints with LoopBack 4 -- [@loopback/extension-logging](https://github.com/strongloop/loopback-next/tree/master/extensions/logging) - An extension exposes logging for Winston and - Fluentd with LoopBack 4 -- [@loopback/extension-metrics](https://github.com/strongloop/loopback-next/tree/master/extensions/metrics) - An extension exposes metrics for Prometheus with +- [@loopback/apiconnect](https://github.com/strongloop/loopback-next/tree/master/extensions/apiconnect) - + An extension for integrating with + [IBM API Connect](https://www.ibm.com/cloud/api-connect) +- [@loopback/authentication](https://github.com/strongloop/loopback-next/tree/master/packages/authentication) - + A LoopBack component for authentication support +- [@loopback/authentication-jwt](https://github.com/strongloop/loopback-next/tree/master/extensions/authentication-jwt) - + Extension for JWT authentication +- [@loopback/authentication-passport](https://github.com/strongloop/loopback-next/tree/master/extensions/authentication-passport) - + A package creating adapters between the passport module and + @loopback/authentication +- [@loopback/authorization](https://github.com/strongloop/loopback-next/tree/master/packages/authorization) - + A LoopBack component for authorization support +- [@loopback/boot](https://github.com/strongloop/loopback-next/tree/master/packages/boot) - + A collection of Booters for LoopBack 4 Applications +- [@loopback/booter-lb3app](https://github.com/strongloop/loopback-next/tree/master/packages/booter-lb3app) - + A booter component for LoopBack 3 applications to expose their REST API via LoopBack 4 -- [@loopback/pooling](https://github.com/strongloop/loopback-next/tree/master/extensions/pooling) - Resource pooling service for LoopBack 4 -- [@loopback/rest](https://github.com/strongloop/loopback-next/tree/master/packages/rest) - Expose controllers as REST endpoints and route REST API - requests to controller methods -- [@loopback/rest-crud](https://github.com/strongloop/loopback-next/tree/master/packages/rest-crud) - REST API controller implementing default CRUD semantics -- [@loopback/rest-explorer](https://github.com/strongloop/loopback-next/tree/master/packages/rest-explorer) - LoopBack's API Explorer -- [@loopback/typeorm](https://github.com/strongloop/loopback-next/tree/master/extensions/typeorm) - Adds support for TypeORM in LoopBack +- [@loopback/context-explorer](https://github.com/strongloop/loopback-next/tree/master/extensions/context-explorer) - + Visualize context hierarchy, bindings, configurations, and dependencies +- [@loopback/cron](https://github.com/strongloop/loopback-next/tree/master/extensions/cron) - + Schedule tasks using cron-like syntax +- [@loopback/extension-health](https://github.com/strongloop/loopback-next/tree/master/extensions/health) - + An extension exposes health check related endpoints with LoopBack 4 +- [@loopback/extension-logging](https://github.com/strongloop/loopback-next/tree/master/extensions/logging) - + An extension exposes logging for Winston and Fluentd with LoopBack 4 +- [@loopback/extension-metrics](https://github.com/strongloop/loopback-next/tree/master/extensions/metrics) - + An extension exposes metrics for Prometheus with LoopBack 4 +- [@loopback/pooling](https://github.com/strongloop/loopback-next/tree/master/extensions/pooling) - + Resource pooling service for LoopBack 4 +- [@loopback/rest](https://github.com/strongloop/loopback-next/tree/master/packages/rest) - + Expose controllers as REST endpoints and route REST API requests to controller + methods +- [@loopback/rest-crud](https://github.com/strongloop/loopback-next/tree/master/packages/rest-crud) - + REST API controller implementing default CRUD semantics +- [@loopback/rest-explorer](https://github.com/strongloop/loopback-next/tree/master/packages/rest-explorer) - + LoopBack's API Explorer +- [@loopback/typeorm](https://github.com/strongloop/loopback-next/tree/master/extensions/typeorm) - + Adds support for TypeORM in LoopBack ## Creating components diff --git a/packages/cli/generators/extension/index.js b/packages/cli/generators/extension/index.js index 7afa0c00998f..e4cc91f8696d 100644 --- a/packages/cli/generators/extension/index.js +++ b/packages/cli/generators/extension/index.js @@ -69,13 +69,14 @@ module.exports = class ExtensionGenerator extends ProjectGenerator { } scaffold() { - const titleCase = - this.projectInfo.name.charAt(0).toUpperCase() + - this.projectInfo.name.slice(1); - this.projectInfo.optionsInterface = `${titleCase}Options`; - this.projectInfo.bindingsNamespace = `${titleCase}Bindings`; - this.projectInfo.defaultOptions = `DEFAULT_${this.projectInfo.name.toUpperCase()}_OPTIONS`; - + if (this.projectInfo) { + const titleCase = + this.projectInfo.name.charAt(0).toUpperCase() + + this.projectInfo.name.slice(1); + this.projectInfo.optionsInterface = `${titleCase}Options`; + this.projectInfo.bindingsNamespace = `${titleCase}Bindings`; + this.projectInfo.defaultOptions = `DEFAULT_${this.projectInfo.name.toUpperCase()}_OPTIONS`; + } return super.scaffold(); } diff --git a/packages/cli/generators/extension/templates/src/component.ts.ejs b/packages/cli/generators/extension/templates/src/component.ts.ejs index e2d7097bd9e6..5dad27db7b04 100644 --- a/packages/cli/generators/extension/templates/src/component.ts.ejs +++ b/packages/cli/generators/extension/templates/src/component.ts.ejs @@ -12,12 +12,13 @@ import { import {<%= project.bindingsNamespace %>} from './keys' import {<%= project.defaultOptions %>, <%= project.optionsInterface %>} from './types'; +// Configure the binding for <%= project.componentName %> @bind({tags: {[ContextTags.KEY]: <%= project.bindingsNamespace %>.COMPONENT}}) export class <%= project.componentName %> implements Component { constructor( @inject(CoreBindings.APPLICATION_INSTANCE) private application: Application, @config() - options: <%= project.optionsInterface %> = <%= project.defaultOptions %>, + private options: <%= project.optionsInterface %> = <%= project.defaultOptions %>, ) {} } diff --git a/packages/cli/generators/extension/templates/src/types.ts.ejs b/packages/cli/generators/extension/templates/src/types.ts.ejs index 81afe574b9b0..d95266b98bb7 100644 --- a/packages/cli/generators/extension/templates/src/types.ts.ejs +++ b/packages/cli/generators/extension/templates/src/types.ts.ejs @@ -1,7 +1,15 @@ +/** +* Interface defining the component's options object +*/ export interface <%= project.optionsInterface %> { + // Add the definitions here } +/** +* Default options for the component +*/ export const <%= project.defaultOptions %>: <%= project.optionsInterface %> = { + // Specify the values here };