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

refactor: move non-core booters to their own packages #5618

Closed
wants to merge 8 commits into from
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@
# - Primary owner(s): @jannyHou
# - Standby owner(s): n/a
/packages/boot @jannyHou
/packages/booter @raymondfeng @jannyHou

#
# Migration from LB3
Expand Down
1 change: 1 addition & 0 deletions docs/site/MONOREPO.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ one in the monorepo: `npm run update-monorepo-file`
| [packages/authentication](https://github.com/strongloop/loopback-next/tree/master/packages/authentication) | @loopback/authentication | A LoopBack component for authentication support. |
| [packages/authorization](https://github.com/strongloop/loopback-next/tree/master/packages/authorization) | @loopback/authorization | A LoopBack component for authorization support. |
| [packages/boot](https://github.com/strongloop/loopback-next/tree/master/packages/boot) | @loopback/boot | A collection of Booters for LoopBack 4 Applications |
| [packages/booter](https://github.com/strongloop/loopback-next/tree/master/packages/booter) | @loopback/booter | @loopback/booter |
| [packages/booter-lb3app](https://github.com/strongloop/loopback-next/tree/master/packages/booter-lb3app) | @loopback/booter-lb3app | A booter component for LoopBack 3 applications to expose their REST API via LoopBack 4 |
| [packages/build](https://github.com/strongloop/loopback-next/tree/master/packages/build) | @loopback/build | A set of common scripts and default configurations to build LoopBack 4 or other TypeScript modules |
| [packages/cli](https://github.com/strongloop/loopback-next/tree/master/packages/cli) | @loopback/cli | Yeoman generator for LoopBack 4 |
Expand Down
3 changes: 2 additions & 1 deletion extensions/graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
"type-graphql": "^1.1.0"
},
"peerDependencies": {
"@loopback/boot": "^3.0.2",
"@loopback/booter": "^1.0.0",
"@loopback/core": "^2.11.0"
},
"devDependencies": {
"@loopback/booter": "^1.0.0",
"@loopback/boot": "^3.0.2",
"@loopback/build": "^6.2.5",
"@loopback/core": "^2.11.0",
Expand Down
6 changes: 3 additions & 3 deletions extensions/graphql/src/booters/resolver.booter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import {
ArtifactOptions,
BaseArtifactBooter,
BootBindings,
booter,
} from '@loopback/boot';
BooterBindings,
} from '@loopback/booter';
import {
Application,
config,
Expand Down Expand Up @@ -41,7 +41,7 @@ export class GraphQLResolverBooter extends BaseArtifactBooter {
constructor(
@inject(CoreBindings.APPLICATION_INSTANCE)
public app: Application,
@inject(BootBindings.PROJECT_ROOT) projectRoot: string,
@inject(BooterBindings.PROJECT_ROOT) projectRoot: string,
@config()
public interceptorConfig: ArtifactOptions = {},
) {
Expand Down
3 changes: 3 additions & 0 deletions extensions/graphql/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
{
"path": "../../packages/boot/tsconfig.json"
},
{
"path": "../../packages/booter/tsconfig.json"
},
{
"path": "../../packages/core/tsconfig.json"
},
Expand Down
3 changes: 2 additions & 1 deletion extensions/typeorm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"access": "public"
},
"peerDependencies": {
"@loopback/boot": "^3.0.2",
"@loopback/booter": "^1.0.0",
"@loopback/core": "^2.11.0",
"@loopback/rest": "^8.0.0"
},
Expand All @@ -31,6 +31,7 @@
"typeorm": "^0.2.28"
},
"devDependencies": {
"@loopback/booter": "^1.0.0",
"@loopback/boot": "^3.0.2",
"@loopback/build": "^6.2.5",
"@loopback/core": "^2.11.0",
Expand Down
6 changes: 3 additions & 3 deletions extensions/typeorm/src/typeorm-connection.booter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import {
ArtifactOptions,
BaseArtifactBooter,
BootBindings,
booter,
} from '@loopback/boot';
BooterBindings,
} from '@loopback/booter';
import {config, CoreBindings, inject} from '@loopback/core';
import debugFactory from 'debug';
import {ApplicationUsingTypeOrm, ConnectionOptions} from './';
Expand All @@ -28,7 +28,7 @@ export class TypeOrmConnectionBooter extends BaseArtifactBooter {
constructor(
@inject(CoreBindings.APPLICATION_INSTANCE)
public app: ApplicationUsingTypeOrm,
@inject(BootBindings.PROJECT_ROOT) projectRoot: string,
@inject(BooterBindings.PROJECT_ROOT) projectRoot: string,
@config()
public entityConfig: ArtifactOptions = {},
) {
Expand Down
3 changes: 3 additions & 0 deletions extensions/typeorm/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
{
"path": "../../packages/boot/tsconfig.json"
},
{
"path": "../../packages/booter/tsconfig.json"
},
{
"path": "../../packages/core/tsconfig.json"
},
Expand Down
10 changes: 3 additions & 7 deletions packages/boot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
"@loopback/core": "^2.11.0"
},
"dependencies": {
"@loopback/model-api-builder": "^2.1.16",
"@loopback/repository": "^3.1.0",
"@loopback/service-proxy": "^3.0.2",
"@types/debug": "^4.1.5",
"@types/glob": "^7.1.3",
"@loopback/booter": "^1.0.0",
"debug": "^4.2.0",
"glob": "^7.1.6",
"tslib": "^2.0.3"
Expand All @@ -40,9 +36,9 @@
"@loopback/build": "^6.2.5",
"@loopback/core": "^2.11.0",
"@loopback/eslint-config": "^10.0.1",
"@loopback/rest": "^8.0.0",
"@loopback/rest-crud": "^0.8.16",
"@loopback/testlab": "^3.2.7",
"@types/debug": "^4.1.5",
"@types/glob": "^7.1.3",
"@types/node": "^10.17.35"
},
"files": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {
createRestAppClient,
givenHttpServerConfig,
TestSandbox,
} from '@loopback/testlab';
import {expect, givenHttpServerConfig, TestSandbox} from '@loopback/testlab';
import {resolve} from 'path';
import {BooterApp} from '../fixtures/application';

Expand All @@ -18,17 +14,10 @@ describe('controller booter acceptance tests', () => {
beforeEach('reset sandbox', () => sandbox.reset());
beforeEach(getApp);

afterEach(stopApp);

it('binds controllers using ControllerDefaults and REST endpoints work', async () => {
it('binds controllers using ControllerDefaults', async () => {
await app.boot();
await app.start();

const client = createRestAppClient(app);

// Default Controllers = /controllers with .controller.js ending (nested = true);
await client.get('/one').expect(200, 'ControllerOne.one()');
await client.get('/two').expect(200, 'ControllerTwo.two()');
const bindings = app.find('controllers.*');
expect(bindings.length).to.eql(2);
});

async function getApp() {
Expand All @@ -44,8 +33,4 @@ describe('controller booter acceptance tests', () => {
rest: givenHttpServerConfig(),
});
}

async function stopApp() {
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 app.stop()?

await app?.stop();
}
});
13 changes: 2 additions & 11 deletions packages/boot/src/__tests__/fixtures/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,10 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {ApplicationConfig} from '@loopback/core';
import {RepositoryMixin} from '@loopback/repository';
import {RestApplication} from '@loopback/rest';
import {ServiceMixin} from '@loopback/service-proxy';
import {Application, ApplicationConfig} from '@loopback/core';
import {BootMixin} from '../..';

// Force package.json to be copied to `dist` by `tsc`
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import * as pkg from './package.json';

export class BooterApp extends BootMixin(
ServiceMixin(RepositoryMixin(RestApplication)),
) {
export class BooterApp extends BootMixin(Application) {
constructor(options?: ApplicationConfig) {
super(options);
this.projectRoot = __dirname;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright IBM Corp. 2019. All Rights Reserved.
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
// Node module: @loopback/boot
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright IBM Corp. 2019. All Rights Reserved.
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
// Node module: @loopback/boot
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright IBM Corp. 2018. All Rights Reserved.
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
// Node module: @loopback/boot
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
Expand Down
4 changes: 0 additions & 4 deletions packages/boot/src/__tests__/fixtures/multiple.artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {get} from '@loopback/rest';

export class ArtifactOne {
@get('/one')
one() {
return 'ControllerOne.one()';
}
}

export class ArtifactTwo {
@get('/two')
two() {
return 'ControllerTwo.two()';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright IBM Corp. 2019. All Rights Reserved.
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
// Node module: @loopback/boot
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright IBM Corp. 2019. All Rights Reserved.
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
// Node module: @loopback/boot
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright IBM Corp. 2019. All Rights Reserved.
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
// Node module: @loopback/boot
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
Expand Down
16 changes: 0 additions & 16 deletions packages/boot/src/__tests__/unit/boot.component.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {
BootMixin,
Bootstrapper,
ControllerBooter,
DataSourceBooter,
RepositoryBooter,
ServiceBooter,
} from '../../';

Expand All @@ -34,20 +32,6 @@ describe('boot.component unit tests', () => {
expect(booterInst).to.be.an.instanceOf(ControllerBooter);
});

it('RepositoryBooter is bound as a booter by default', async () => {
const booterInst = await app.get(
`${BootBindings.BOOTERS}.RepositoryBooter`,
);
expect(booterInst).to.be.an.instanceOf(RepositoryBooter);
});

it('DataSourceBooter is bound as a booter by default', async () => {
const booterInst = await app.get(
`${BootBindings.BOOTERS}.DataSourceBooter`,
);
expect(booterInst).to.be.an.instanceOf(DataSourceBooter);
});

it('ServiceBooter is bound as a booter by default', async () => {
const booterInst = await app.get(`${BootBindings.BOOTERS}.ServiceBooter`);
expect(booterInst).to.be.an.instanceOf(ServiceBooter);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Copyright IBM Corp. 2019. All Rights Reserved.
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/boot
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {BaseArtifactBooter} from '@loopback/booter';
import {
Application,
BindingKey,
Expand All @@ -13,7 +14,6 @@ import {
} from '@loopback/core';
import {expect} from '@loopback/testlab';
import {BootBindings, BootMixin} from '../../';
import {BaseArtifactBooter} from '../../booters';
import {InstanceWithBooters} from '../../types';

describe('boot.component unit tests', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// License text available at https://opensource.org/licenses/MIT

import {Application} from '@loopback/core';
import {ApplicationWithServices, ServiceMixin} from '@loopback/service-proxy';
import {expect, sinon, TestSandbox} from '@loopback/testlab';
import {resolve} from 'path';
import {ServiceBooter, ServiceDefaults} from '../../..';
Expand All @@ -15,7 +14,7 @@ describe('service booter unit tests', () => {
const SERVICES_PREFIX = 'services';
const SERVICES_TAG = 'service';

class AppWithRepo extends ServiceMixin(Application) {}
class AppWithRepo extends Application {}

let app: AppWithRepo;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -32,10 +31,7 @@ describe('service booter unit tests', () => {
resolve(__dirname, '../../fixtures/service-provider.artifact.js'),
);

const booterInst = new ServiceBooter(
normalApp as ApplicationWithServices,
sandbox.path,
);
const booterInst = new ServiceBooter(normalApp, sandbox.path);

booterInst.discovered = [
resolve(sandbox.path, 'service-provider.artifact.js'),
Expand Down
7 changes: 2 additions & 5 deletions packages/boot/src/__tests__/unit/bootstrapper.unit.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
// Copyright IBM Corp. 2019. All Rights Reserved.
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
// Node module: @loopback/boot
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {Application} from '@loopback/core';
import {RepositoryMixin} from '@loopback/repository';
import {expect, sinon} from '@loopback/testlab';
import {BootBindings, Booter, BootMixin, Bootstrapper} from '../..';

describe('boot-strapper unit tests', () => {
// RepositoryMixin is added to avoid warning message printed logged to console
// due to the fact that RepositoryBooter is a default Booter loaded via BootMixin.
class BootApp extends BootMixin(RepositoryMixin(Application)) {}
class BootApp extends BootMixin(Application) {}

let app: BootApp;
let bootstrapper: Bootstrapper;
Expand Down
2 changes: 1 addition & 1 deletion packages/boot/src/__tests__/unit/mixins/boot.mixin.unit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright IBM Corp. 2019. All Rights Reserved.
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
// Node module: @loopback/boot
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
Expand Down
Loading