Skip to content

Commit

Permalink
fix: change file names to fit advocated naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
shimks committed Apr 11, 2018
1 parent 3f085fe commit 0331df8
Show file tree
Hide file tree
Showing 170 changed files with 341 additions and 277 deletions.
2 changes: 1 addition & 1 deletion docs/site/Application.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ as a part of your setup:
- Perform some asynchronous wireup before application start
- Perform some graceful cleanup on application stop

{% include code-caption.html content="src/widget-application.ts" %}
{% include code-caption.html content="src/widget.application.ts" %}

```ts
import {Application} from '@loopback/core';
Expand Down
2 changes: 1 addition & 1 deletion docs/site/Controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ The example below shows the previous controller revamped with `HttpErrors` along
with a test to verify that the error is thrown properly.

```ts
// test/integration/controllers/hello.controller.test.ts
// test/integration/controllers/hello.controller.integration.ts
import {HelloController} from '../../../src/controllers';
import {HelloRepository} from '../../../src/repositories';
import {testdb} from '../../fixtures/datasources/testdb.datasource';
Expand Down
18 changes: 9 additions & 9 deletions docs/site/Creating-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ summary:
As explained in [Using Components](Using-components.md), a typical LoopBack component is an npm package exporting a Component class.

```ts
import {MyController} from './controllers/my-controller';
import {MyValueProvider} from './providers/my-value-provider';
import {MyController} from './controllers/my.controller';
import {MyValueProvider} from './providers/my-value.provider';
import {Component} from '@loopback/core';

export class MyComponent implements Component {
constructor() {
this.controllers = [MyController];
this.providers = {
'my.value': MyValueProvider,
'my-value': MyValueProvider,
};
}
}
Expand All @@ -32,7 +32,7 @@ class is created and then:
- Each Provider is bound to its key in `providers` object.

The example `MyComponent` above will add `MyController` to application's API and
create a new binding `my.value` that will be resolved using `MyValueProvider`.
create a new binding `my-value` that will be resolved using `MyValueProvider`.

## Providers

Expand All @@ -54,7 +54,7 @@ Notice that the provider class itself does not specify any binding key, the key
is assigned by the component class.

```ts
import {MyValueProvider} from './providers/my-value-provider';
import {MyValueProvider} from './providers/my-value.provider';

export class MyComponent implements Component {
constructor() {
Expand Down Expand Up @@ -307,9 +307,9 @@ Suppose an app has multiple components with repositories bound to each of them.
You can use function `RepositoryMixin()` to mount those repositories to application level context.

The following snippet is an abbreviated function
[`RepositoryMixin`](https://github.com/strongloop/loopback-next/blob/master/packages/repository/src/repository-mixin.ts):
[`RepositoryMixin`](https://github.com/strongloop/loopback-next/blob/master/packages/repository/src/mixins/repository.mixin.ts):

{% include code-caption.html content="mixins/src/repository-mixin.ts" %}
{% include code-caption.html content="src/mixins/repository.mixin.ts" %}

```ts
export function RepositoryMixin<T extends Class<any>>(superClass: T) {
Expand Down Expand Up @@ -347,9 +347,9 @@ Then you can extend the app with repositories in a component:
{% include code-caption.html content="index.ts" %}

```ts
import {RepositoryMixin} from 'mixins/src/repository-mixin';
import {RepositoryMixin} from 'src/mixins/repository.mixin';
import {Application} from '@loopback/core';
import {FooComponent} from 'components/src/Foo';
import {FooComponent} from 'src/foo.component';
class AppWithRepoMixin extends RepositoryMixin(Application) {}
let app = new AppWithRepoMixin();
Expand Down
10 changes: 5 additions & 5 deletions docs/site/Decorators.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class MyController {

### Parameter Decorator

Syntax: see [API documentation](https://github.com/strongloop/loopback-next/blob/0739ffcfe3ef50e0bfd86055c0f4e29fd6925be0/packages/openapi-v3/src/parameter-decorator.ts#L17-L29)
Syntax: see [API documentation](https://github.com/strongloop/loopback-next/tree/master/packages/openapi-v3/src/decorators/parameter.decorator.ts#L17-L29)

`@param` is applied to controller method parameters to generate OpenAPI parameter specification for them.

Expand Down Expand Up @@ -208,7 +208,7 @@ You can find specific use cases in [Writing Controller methods](Controllers.md#w

### RequestBody Decorator

Syntax: see [API documentation](https://github.com/strongloop/loopback-next/blob/0739ffcfe3ef50e0bfd86055c0f4e29fd6925be0/packages/openapi-v3/src/request-body-decorator.ts#L20-L79)
Syntax: see [API documentation](https://github.com/strongloop/loopback-next/tree/master/packages/openapi-v3/src/decorators/request-body.decorator.ts#L20-L79)

`@requestBody()` is applied to a controller method parameter to generate OpenAPI requestBody specification for it.

Expand Down Expand Up @@ -251,7 +251,7 @@ This allows type information of the model to be visible to the spec generator so

```ts
// in file '/src/controllers/user.controller.ts'
import {User} from '../models/user'
import {User} from '../models/user.model'
import {put} from '@loopback/rest'

class UserController {
Expand Down Expand Up @@ -305,7 +305,7 @@ class MyController {
- override the schema specification

```ts
import {UserSchema, User} from '../model/user-schema';
import {UserSchema, User} from '../model/user.schema';

class MyController {
@put('/Users/{id}')
Expand Down Expand Up @@ -364,7 +364,7 @@ Now that we've bound the 'config.widget' key to our configuration object, and
WidgetController:

```ts
// widget-controller.ts
// src/controllers/widget.controller.ts
import {inject} from '@loopback/context';

export class WidgetController {
Expand Down
24 changes: 12 additions & 12 deletions docs/site/Mixin.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mixed to it.
For example you have a simple controller which only has a greeter function
prints out 'hi!':

{% include code-caption.html content="Controllers/myController.ts" %}
{% include code-caption.html content="src/controllers/using-mixin.controller.ts" %}

```ts
class SimpleController {
Expand All @@ -49,14 +49,14 @@ Now let's add mixins to it:

- A logger mixin to provide logging tools.

Define mixin `timeStampMixin`:
Define mixin `TimeStampMixin`:

{% include code-caption.html content="Mixins/timeStampMixin.ts" %}
{% include code-caption.html content="src/mixins/time-stamp.mixin.ts" %}

```ts
import {Class} from '@loopback/repository';

export function timeStampMixin<T extends Class<any>>(baseClass: T) {
export function TimeStampMixin<T extends Class<any>>(baseClass: T) {
return class extends baseClass {
// add a new property `createdAt`
public createdAt: Date;
Expand All @@ -71,14 +71,14 @@ export function timeStampMixin<T extends Class<any>>(baseClass: T) {
}
```

And define mixin `loggerMixin`:
And define mixin `LoggerMixin`:

{% include code-caption.html content="Mixins/loggerMixin.ts" %}
{% include code-caption.html content="src/mixins/logger.mixin.ts" %}

```ts
import {Class} from '@loopback/repository';

function loggerMixin<T extends Class<any>>(baseClass: T) {
function LoggerMixin<T extends Class<any>>(baseClass: T) {
return class extends baseClass {
// add a new method `log()`
log(str: string) {
Expand All @@ -90,11 +90,11 @@ function loggerMixin<T extends Class<any>>(baseClass: T) {

Now you can extend `SimpleController` with the two mixins:

{% include code-caption.html content="Controllers/myController.ts" %}
{% include code-caption.html content="src/controllers/using-mixin.controller.ts" %}

```ts
import {timeStampMixin} from 'Mixins/timeStampMixin.ts';
import {loggerMixin} from 'Mixins/loggerMixin.ts';
import {timeStampMixin} from '../mixins/time-stamp.mixin.ts';
import {loggerMixin} from '../mixins/logger.mixin.ts';

class SimpleController {
constructor() {}
Expand All @@ -103,8 +103,8 @@ class SimpleController {
}
}

class AdvancedController extends loggerMixin(
timeStampMixin(SimpleController),
class AdvancedController extends LoggerMixin(
TimeStampMixin(SimpleController),
) {}

// verify new method and property are added to `AdvancedController`:
Expand Down
6 changes: 3 additions & 3 deletions docs/site/Repositories.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ usage.
```ts
import {Application} from '@loopback/core';
import {RepositoryMixin} from '@loopback/repository';
import {AccountRepository, CategoryRepository} from './repository';
import {AccountRepository, CategoryRepository} from './repositories';

// Using the Mixin
class MyApplication extends RepositoryMixin(Application) {}
Expand Down Expand Up @@ -292,8 +292,8 @@ You can look at
```ts
import {CrudRepositoryImpl} from '@loopback/repository';
import {MySQLDs} from './datasources/mysqlds';
import {Account} from './models/Account';
import {MySQLDs} from './datasources/mysqlds.datasource';
import {Account} from './models/account.model';

export class NewRepository extends CrudRepositoryImpl<Account, string> {
constructor() {
Expand Down
8 changes: 4 additions & 4 deletions docs/site/Testing-Your-Extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class PingController {
}
```

**`test/unit/controllers/ping.controller.ts`**
**`test/unit/controllers/ping.controller.unit.ts`**

```ts
import {PingController} from '../../..';
Expand Down Expand Up @@ -144,7 +144,7 @@ export function getTestMetadata(
}
```

**`test/unit/decorators/test.decorator.ts`**
**`test/unit/decorators/test.decorator.unit.ts`**

```ts
import {test, getTestMetadata} from '../../..';
Expand Down Expand Up @@ -193,7 +193,7 @@ export class RandomNumberProvider implements Provider<number> {
}
```

**`test/unit/providers/random-number.unit.test.ts`**
**`test/unit/providers/random-number.provider.unit.ts`**

```ts
import {RandomNumberProvider} from '../../..';
Expand Down Expand Up @@ -254,7 +254,7 @@ export function TimeMixin<T extends Constructor<any>>(superClass: T) {
}
```

**`test/integration/mixins/time.intg.test.ts`**
**`test/integration/mixins/time.mixin.integration.ts`**

```ts
import {expect} from '@loopback/testlab';
Expand Down
16 changes: 8 additions & 8 deletions docs/site/Testing-your-application.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export async function givenEmptyDatabase() {
}
```

{% include code-caption.html content="test/integration/controllers/product.controller.test.ts" %}
{% include code-caption.html content="test/integration/controllers/product.controller.integration.ts" %}

```ts
// in your test file
Expand Down Expand Up @@ -394,7 +394,7 @@ repository's `find()` method with a correct query, and returns back the query
results. See [Create a stub repository](#create-a-stub-repository) for a
detailed explanation.

{% include code-caption.html content="test/unit/controllers/product.controller.test.ts" %}
{% include code-caption.html content="test/unit/controllers/product.controller.unit.ts" %}

```ts
import {expect, sinon} from '@loopback/testlab';
Expand Down Expand Up @@ -438,7 +438,7 @@ unit tests to verify the implementation of this additional method.
Remember to use [Test data builders](#use-test-data-builders) whenever you need
valid data to create a new model instance.

{% include code-caption.html content="test/unit/models/person.model.test.ts" %}
{% include code-caption.html content="test/unit/models/person.model.unit.ts" %}

```ts
import {Person} from '../../../src/models';
Expand Down Expand Up @@ -538,7 +538,7 @@ Integration tests are one of the places to put the best practices in
Here is an example showing how to write an integration test for a custom
repository method `findByName`:

{% include code-caption.html content="test/integration/repositories/category.repository.test.ts" %}
{% include code-caption.html content="test/integration/repositories/category.repository.integration.ts" %}

```ts
import {
Expand Down Expand Up @@ -573,7 +573,7 @@ commands and queries produce expected results when executed on a real database.
These tests are similar to repository tests with controllers added as another
ingredient.

{% include code-caption.html content="test/integration/controllers/product.controller.test.ts" %}
{% include code-caption.html content="test/integration/controllers/product.controller.integration.ts" %}

```ts
import {expect} from '@loopback/testlab';
Expand Down Expand Up @@ -635,7 +635,7 @@ provides a helper method `validateApiSpec` that builds on top of the popular

Example usage:

{% include code-caption.html content= "test/acceptance/api-spec.test.ts" %}
{% include code-caption.html content= "test/acceptance/api-spec.acceptance.ts" %}

```ts
// test/acceptance/api-spec.test.ts
Expand Down Expand Up @@ -678,7 +678,7 @@ developers consuming your API will find them useful too.

Here is an example showing how to run Dredd to test your API against the spec:

{% include code-caption.html content= "test/acceptance/api-spec.test.ts" %}
{% include code-caption.html content= "test/acceptance/api-spec.acceptance.ts" %}

```ts
import {expect} from '@loopback/testlab';
Expand Down Expand Up @@ -750,7 +750,7 @@ two tests (one test for each user role).

Here is an example of an acceptance test:

{% include code-caption.html content= "test/acceptance/product.test.ts" %}
{% include code-caption.html content= "test/acceptance/product.acceptance.ts" %}

```ts
import {HelloWorldApplication} from '../..';
Expand Down
5 changes: 3 additions & 2 deletions docs/site/todo-tutorial-scaffolding.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ src/
test/
README.md
mocha.opts
ping.controller.test.ts
acceptance/
ping.controller.acceptance.ts
node_modules/
***
LICENSE
Expand Down Expand Up @@ -91,7 +92,7 @@ tslint.json
| src/repositories/README.md | Provides information about the repositories directory, how to generate new repositories, and where to find more information. |
| test/README.md | Please place your tests in this folder. |
| test/mocha.opts | [Mocha](https://mochajs.org/) configuration for running your application's tests. |
| test/ping.controller.test.ts | An example test to go with the ping controller in `src/controllers`. |
| test/acceptance/ping.controller.acceptance.ts | An example test to go with the ping controller in `src/controllers`. |

### Navigation

Expand Down
3 changes: 1 addition & 2 deletions examples/log-extension/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

import {Component, ProviderMap} from '@loopback/core';
import {EXAMPLE_LOG_BINDINGS} from './keys';
import {LogActionProvider} from './providers/log-action.provider';
import {TimerProvider} from './providers/timer.provider';
import {LogActionProvider, TimerProvider} from './providers';

export class LogComponent implements Component {
providers?: ProviderMap = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright IBM Corp. 2018. All Rights Reserved.
// Node module: @loopback/example-rpc-server
// Node module: @loopback/example-log-extension
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

export * from './rpc-router';
export * from './rpc-server';
export * from './log.decorator';
7 changes: 3 additions & 4 deletions examples/log-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

export * from './decorators/log.decorator';
export * from './mixins/log.mixin';
export * from './providers/log-action.provider';
export * from './providers/timer.provider';
export * from './decorators';
export * from './mixins';
export * from './providers';
export * from './component';
export * from './types';
export * from './keys';
6 changes: 6 additions & 0 deletions examples/log-extension/src/mixins/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright IBM Corp. 2018. All Rights Reserved.
// Node module: @loopback/example-log-extension
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

export * from './log.mixin';
7 changes: 7 additions & 0 deletions examples/log-extension/src/providers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright IBM Corp. 2018. All Rights Reserved.
// Node module: @loopback/example-log-extension
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

export * from './log-action.provider';
export * from './timer.provider';
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import {inject, Provider, Constructor, Getter} from '@loopback/context';
import {CoreBindings} from '@loopback/core';
import {OperationArgs, ParsedRequest} from '@loopback/rest';
import {getLogMetadata} from '../decorators/log.decorator';
import {getLogMetadata} from '../decorators';
import {EXAMPLE_LOG_BINDINGS, LOG_LEVEL} from '../keys';
import {
LogFn,
Expand Down
Loading

0 comments on commit 0331df8

Please sign in to comment.