Skip to content
This repository has been archived by the owner on Feb 7, 2021. It is now read-only.

Commit

Permalink
fix: rename inMemoryDb to inMemoryDB (#109)
Browse files Browse the repository at this point in the history
Correct typo
  • Loading branch information
jordanpowell88 authored and wesleygrimes committed Oct 8, 2019
1 parent b3470ef commit ed00b42
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Now we can make use of our new `interface` when injecting the `InMemoryDBService

In order to use the `InMemoryDBService<T>` we need to do the following:

- Add `private readonly inMemoryDb: InMemoryDBService<T>` to the `constructor` of each controller and/or service that you would like to use it in.
- Add `private readonly inMemoryDB: InMemoryDBService<T>` to the `constructor` of each controller and/or service that you would like to use it in.
- Begin using `InMemoryDBService` as expected.

An example of injecting `InMemoryDBService` into a `UserController` for the `UserEntity` we defined earlier would look something like this:
Expand Down Expand Up @@ -171,15 +171,15 @@ Using this decorator ensures that the correct instance is injected.

## Entity Controller

In order to prevent code duplication and boilerplate for each controller, we have created two base entity controllers `InMemoryDbEntityController` and `InMemoryDbEntityAsyncController`. This allows you to quickly provide endpoints to make requests without having to manually implement each action.
In order to prevent code duplication and boilerplate for each controller, we have created two base entity controllers `InMemoryDBEntityController` and `InMemoryDBEntityAsyncController`. This allows you to quickly provide endpoints to make requests without having to manually implement each action.


To use the controllers, simply create a new controller and extend it with one of the provided base controllers.


```typescript
@Controller('api/users')
class UsersController extends InMemoryDbController<UserEntity> {
class UsersController extends InMemoryDBEntityController<UserEntity> {

constructor(protected dbService: InMemoryDBService<UserEntity>) {
super(dbService);
Expand All @@ -193,7 +193,7 @@ In order to have an Entity Controller use a feature-specific instance of the ser

```typescript
@Controller('api/users')
class UsersController extends InMemoryDbController<UserEntity> {
class UsersController extends InMemoryDBEntityController<UserEntity> {

constructor(@InjectInMemoryDBService('customer') protected readonly inMemoryDBService: InMemoryDBService<UserEntity>) {
super(inMemoryDBService);
Expand Down
4 changes: 2 additions & 2 deletions e2e/test-app/src/customer/customer.controller.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Controller } from '@nestjs/common';
import { InMemoryDBService, InjectInMemoryDBService, InMemoryDbEntityController } from '../../../../lib';
import { InMemoryDBService, InjectInMemoryDBService, InMemoryDBEntityController as InMemoryDBEntityController } from '../../../../lib';
import { Customer } from './customer';

@Controller('api/customers')
export class CustomerController extends InMemoryDbEntityController<Customer> {
export class CustomerController extends InMemoryDBEntityController<Customer> {

constructor(
@InjectInMemoryDBService('customer') protected readonly inMemoryDBService: InMemoryDBService<Customer>
Expand Down
6 changes: 3 additions & 3 deletions lib/controllers/in-memory-db-async.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { InMemoryDBEntity } from '../interfaces';
import { inMemoryDBServiceFactory } from '../factories';
import { InMemoryDbEntityAsyncController } from './in-memory-db-async.controller';
import { InMemoryDBEntityAsyncController } from './in-memory-db-async.controller';
import { InMemoryDBService } from '../services';

describe('In Memory DB Async Controller', () => {
interface TestEntity extends InMemoryDBEntity {
someField: string;
}

let controller: InMemoryDbEntityAsyncController<TestEntity>;
let controller: InMemoryDBEntityAsyncController<TestEntity>;
let service: InMemoryDBService<TestEntity>;

const sampleRecords: TestEntity[] = [
Expand All @@ -17,7 +17,7 @@ describe('In Memory DB Async Controller', () => {
{ id: 3, someField: 'CCC' },
];

class MockController extends InMemoryDbEntityAsyncController<TestEntity> {
class MockController extends InMemoryDBEntityAsyncController<TestEntity> {
constructor(protected dbService: InMemoryDBService<TestEntity>) {
super(dbService);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/controllers/in-memory-db-async.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Observable } from 'rxjs';
*
* ```ts
* @Controller('api/user')
* class UsersController extends InMemoryDbEntityAsyncController<User> {
* class UsersController extends InMemoryDBEntityAsyncController<User> {
*
* constructor(protected dbService: InMemoryDBService<User>) {
* super(dbService);
Expand All @@ -18,7 +18,7 @@ import { Observable } from 'rxjs';
*
* ```
*/
export abstract class InMemoryDbEntityAsyncController<
export abstract class InMemoryDBEntityAsyncController<
T extends InMemoryDBEntity
> {
constructor(protected readonly dbService: InMemoryDBService<T>) {}
Expand Down
6 changes: 3 additions & 3 deletions lib/controllers/in-memory-db.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { InMemoryDBEntity } from '../interfaces';
import { inMemoryDBServiceFactory } from '../factories';
import { InMemoryDbEntityController } from './in-memory-db.controller';
import { InMemoryDBEntityController } from './in-memory-db.controller';
import { InMemoryDBService } from '../services';

describe('In Memory DB Controller', () => {
interface TestEntity extends InMemoryDBEntity {
someField: string;
}

let controller: InMemoryDbEntityController<TestEntity>;
let controller: InMemoryDBEntityController<TestEntity>;
let service: InMemoryDBService<TestEntity>;

const sampleRecords: TestEntity[] = [
Expand All @@ -17,7 +17,7 @@ describe('In Memory DB Controller', () => {
{ id: 3, someField: 'CCC' },
];

class MockController extends InMemoryDbEntityController<TestEntity> {
class MockController extends InMemoryDBEntityController<TestEntity> {
constructor(protected dbService: InMemoryDBService<TestEntity>) {
super(dbService);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/controllers/in-memory-db.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { InMemoryDBEntity } from '../interfaces';
*
* ```ts
* @Controller('api/user')
* class UsersController extends InMemoryDbController<User> {
* class UsersController extends InMemoryDBController<User> {
*
* constructor(protected dbService: InMemoryDBService<User>) {
* super(dbService);
Expand All @@ -17,7 +17,7 @@ import { InMemoryDBEntity } from '../interfaces';
*
* ```
*/
export abstract class InMemoryDbEntityController<T extends InMemoryDBEntity> {
export abstract class InMemoryDBEntityController<T extends InMemoryDBEntity> {
constructor(protected readonly dbService: InMemoryDBService<T>) {}

@Post()
Expand Down

0 comments on commit ed00b42

Please sign in to comment.