Skip to content

Commit

Permalink
chore: raymond feedback
Browse files Browse the repository at this point in the history
Feedback

Signed-off-by: Yaapa Hage <[email protected]>
  • Loading branch information
Yaapa Hage committed Jul 8, 2020
1 parent ce8032d commit 182ee62
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 31 deletions.
7 changes: 4 additions & 3 deletions extensions/typeorm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ supported databases and the underlying drivers.
### Creating Entities

[Entities](https://typeorm.io/#/entities) are equivalent to LoopBack's Models.
Define the entities as usual and keep them in a directory named `entities`.
Define the entities as usual and keep them in a directory named
`typeorm-entities`.

```ts
// src/entities/book.entity.ts
// src/typeorm-entities/book.entity.ts
import {Entity, Column, PrimaryColumn} from 'typeorm';
@Entity()
export class Photo {
Expand All @@ -102,7 +103,7 @@ repository API is 100% TypeORM
// src/controllers/book.controller.ts
import {get, post, Request, requestBody} from '@loopback/rest';
import {getModelSchema, Repository, typeorm} from '@loopback/typeorm';
import {Book} from '../entities';
import {Book} from '../typeorm-entities';

export class BookController {
@typeorm.repository(Book) private bookRepo: Repository<Book>;
Expand Down
2 changes: 1 addition & 1 deletion extensions/typeorm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
"repository": {
"type": "git",
"url": "https://github.com/strongloop/loopback-next.git",
"directory": "packages/typeorm"
"directory": "extensions/typeorm"
}
}
4 changes: 2 additions & 2 deletions extensions/typeorm/src/__tests__/fixtures/application.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright IBM Corp. 2019. All Rights Reserved.
// Node module: @loopback/boot
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/typeorm
// 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,11 +1,11 @@
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/rest
// Node module: @loopback/typeorm
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {get, param, post, requestBody} from '@loopback/rest';
import {getModelSchema, Repository, typeorm} from '../../../';
import {Book} from '../entities/book.entity';
import {Book} from '../typeorm-entities/book.entity';

export class BookController {
constructor() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/boot
// Node module: @loopback/typeorm
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import path from 'path';
import {ConnectionOptions} from '../../../';
import {Book} from '../entities/book.entity';
import {Book} from '../typeorm-entities/book.entity';

export const SqliteConnection: ConnectionOptions = {
name: 'my-db',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
// Node module: @loopback/boot
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/typeorm
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

Expand Down Expand Up @@ -33,8 +33,8 @@ describe('TypeORM connection booter integration tests', () => {
'typeorm-connections/sqlite.connection.js',
);
await sandbox.copyFile(
resolve(__dirname, '../fixtures/entities/book.entity.js'),
'entities/book.entity.js',
resolve(__dirname, '../fixtures/typeorm-entities/book.entity.js'),
'typeorm-entities/book.entity.js',
);
const MyApp = require(resolve(sandbox.path, 'application.js')).TypeOrmApp;
app = new MyApp();
Expand Down
11 changes: 6 additions & 5 deletions extensions/typeorm/src/__tests__/integration/rest.integration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
// Node module: @loopback/boot
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/typeorm
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

Expand All @@ -22,7 +22,8 @@ describe('REST with TypeORM (integration)', () => {
beforeEach('reset sandbox', () => sandbox.reset());
beforeEach(getAppAndClient);
afterEach(async () => {
await app.stop();
if (app) await app.stop();
(app as unknown) = undefined;
});

it('creates an entity', async () => {
Expand Down Expand Up @@ -56,8 +57,8 @@ describe('REST with TypeORM (integration)', () => {
'typeorm-connections/sqlite.connection.js',
);
await sandbox.copyFile(
resolve(__dirname, '../fixtures/entities/book.entity.js'),
'entities/book.entity.js',
resolve(__dirname, '../fixtures/typeorm-entities/book.entity.js'),
'typeorm-entities/book.entity.js',
);
await sandbox.copyFile(
resolve(__dirname, '../fixtures/controllers/book.controller.js'),
Expand Down
12 changes: 6 additions & 6 deletions extensions/typeorm/src/__tests__/unit/booter.unit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
// Node module: @loopback/boot
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/typeorm
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

Expand Down Expand Up @@ -38,8 +38,8 @@ describe('TypeORM connection booter unit tests', () => {
'typeorm-connections/sqlite.connection.js',
);
await sandbox.copyFile(
resolve(__dirname, '../fixtures/entities/book.entity.js'),
'entities/book.entity.js',
resolve(__dirname, '../fixtures/typeorm-entities/book.entity.js'),
'typeorm-entities/book.entity.js',
);
const booterInst = new TypeOrmConnectionBooter(
normalApp as ApplicationUsingTypeOrm,
Expand Down Expand Up @@ -85,8 +85,8 @@ describe('TypeORM connection booter unit tests', () => {
'typeorm-connections/sqlite.connection.js',
);
await sandbox.copyFile(
resolve(__dirname, '../fixtures/entities/book.entity.js'),
'entities/book.entity.js',
resolve(__dirname, '../fixtures/typeorm-entities/book.entity.js'),
'typeorm-entities/book.entity.js',
);
const booterInst = new TypeOrmConnectionBooter(app, sandbox.path);
const NUM_CONNECTIONS = 1; // 1 connection in above file.
Expand Down
4 changes: 2 additions & 2 deletions extensions/typeorm/src/__tests__/unit/mixin.unit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
// Node module: @loopback/boot
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/typeorm
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

Expand Down
4 changes: 2 additions & 2 deletions extensions/typeorm/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright IBM Corp. 2017,2020. All Rights Reserved.
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/typeorm
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

export * from './typeorm.booter';
export * from './typeorm-connection.booter';
export * from './typeorm.decorators';
export * from './typeorm.keys';
export * from './typeorm.mixin';
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion extensions/typeorm/src/typeorm.mixin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/typeorm
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
Expand Down
2 changes: 1 addition & 1 deletion extensions/typeorm/src/typeorm.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright IBM Corp. 2017,2020. All Rights Reserved.
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/typeorm
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
Expand Down

0 comments on commit 182ee62

Please sign in to comment.