Skip to content

Conversation

@bajtos
Copy link
Member

@bajtos bajtos commented Feb 6, 2018

  • Move any REST-related setup from app.start() back to app constructor.
  • Update the project template to use RestApplication too
  • Update authentication README to use RestApplication

This is a follow-up for #955, a part of #846

Checklist

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • Related API Documentation was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in packages/example-* were updated

@bajtos bajtos added this to the February 2018 milestone Feb 6, 2018
@bajtos bajtos self-assigned this Feb 6, 2018
@bajtos bajtos requested review from kjdelisle and shimks February 6, 2018 13:57
@bajtos bajtos requested a review from raymondfeng as a code owner February 6, 2018 13:57
@bajtos bajtos changed the title refactor: simplify app setup via RestApplication refactor: simplify app setup via RestApplication (part II) Feb 6, 2018
Copy link
Contributor

@shimks shimks left a comment

Choose a reason for hiding this comment

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

Thanks for the help in finishing my task!
Aside from the comments I've made below, the package example-hello-world also has an unnecessary import (Application) that needs to be deleted.
Otherwise, LGTM
EDIT: the README from example-log-extension can also use RestApplication to simplify some process

} from '@loopback/authentication';
import {RestComponent, RestServer} from '@loopback/rest';
import {MyAuthStrategyProvider} from './providers/auth-strategy';
import {MyController} from './controllers/my-controller';
Copy link
Contributor

Choose a reason for hiding this comment

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

at lines 148 and 153, Application and RestComponent aren't needed anymore

// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {Application, ApplicationConfig} from '@loopback/core';
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to import Application anymore

`@loopback/rest`:

```ts
import {Application} from '@loopback/core';
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused import

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to install @loopback/core as a dependency anymore

Copy link
Contributor

Choose a reason for hiding this comment

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

This might be one of those cases where the import is required for the compiler to make sense of another required type's dependencies. The easiest way would be to attempt to compile it without this line and find out!

Copy link
Contributor

Choose a reason for hiding this comment

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

It's definitely an unused import. I've used RestApplication without installing / using @loopback/core.

Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting. I copied this example into a standalone file and compiled it using the following command:

tsc x.ts --target es2017 -m CommonJS

However, I received a bunch of errors about missing type information for Node.js. To fix that, I had to add @types/node to regular dependencies of @loopback/rest. With that change in place, the example compiles fine.

 - Move any REST-related setup from app.start() back to app constructor.
 - Update the project template to use RestApplication too
 - Update authentication README to use RestApplication
@bajtos bajtos force-pushed the refactor/simplify-app-setup branch from 28645ac to a48b72d Compare February 9, 2018 07:36
@bajtos bajtos force-pushed the refactor/simplify-app-setup branch from a48b72d to c1ad7cb Compare February 9, 2018 07:37
@bajtos
Copy link
Member Author

bajtos commented Feb 9, 2018

Thank you for the feedback. I have rebase this patch on top of the latest master and resolved your comments in c1ad7cb.

@kjdelisle @shimks @virkt25 LGTY now?

Copy link
Contributor

@shimks shimks left a comment

Choose a reason for hiding this comment

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

LGTM

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.

5 participants