Skip to content

Commit

Permalink
chore: rename *.config.json to *.datasource.config.json
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondfeng committed Nov 11, 2019
1 parent 51d8f7b commit 036bcc8
Show file tree
Hide file tree
Showing 29 changed files with 53 additions and 53 deletions.
2 changes: 1 addition & 1 deletion docs/site/DataSource-generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Once all the prompts have been answered, the CLI will do the following:
- Install `@loopback/repository` and the connector package (if it's not a custom
connector).
- Create a file with the connector configuration as follows:
`/src/datasources/${dataSource.dataSourceName}.config.json`
`/src/datasources/${dataSource.dataSourceName}.datasource.config.json`
- Create a DataSource class which recieves the connector config using
[Dependency Injection](Dependency-injection.md) as follows:
`/src/datasources/${dataSource.dataSourceName}.datasource.ts`
Expand Down
4 changes: 2 additions & 2 deletions docs/site/DataSources.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ It is recommended to use the [`lb4 datasource` command](DataSource-generator.md)
provided by the CLI to generate a DataSource. The CLI will prompt for all
necessary connector information and create the following files:

- `${dataSource.dataSourceName}.config.json` containing the connector
- `${dataSource.dataSourceName}.datasource.config.json` containing the connector
configuration
- `${dataSource.dataSourceName}.datasource.ts` containing a class extending
`juggler.DataSource`. This class can be used to override the default
Expand All @@ -37,7 +37,7 @@ Example DataSource Class:
```ts
import {inject} from '@loopback/core';
import {juggler} from '@loopback/repository';
import * as config from './db.config.json';
import * as config from './db.datasource.config.json';

export class DbDataSource extends juggler.DataSource {
static dataSourceName = 'db';
Expand Down
4 changes: 2 additions & 2 deletions docs/site/Inside-Loopback-Application.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ We need appropriate drivers to connect with the backend datasources.
> to provide easy to use CRUD operations and connection configurations.
In the example,
[Redis datasource definition](https://github.com/strongloop/loopback4-example-shopping/blob/master/packages/shopping/src/datasources/redis.config.json)
[Redis datasource definition](https://github.com/strongloop/loopback4-example-shopping/blob/master/packages/shopping/src/datasources/redis.datasource.config.json)
uses the LoopBack `kv-redis` connector and
[MongoDB datasource definition](https://github.com/strongloop/loopback4-example-shopping/blob/master/packages/shopping/src/datasources/mongo.config.json)
[MongoDB datasource definition](https://github.com/strongloop/loopback4-example-shopping/blob/master/packages/shopping/src/datasources/mongo.datasource.config.json)
uses the LoopBack `mongodb` connector.

## Application startup
Expand Down
10 changes: 5 additions & 5 deletions docs/site/Repositories.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ better flexibility, we split the datasource definition into two files. The json
file captures the configuration properties and it can be possibly overridden by
dependency injection.

1. redis.config.json
1. redis.datasource.config.json

```json
{
Expand All @@ -328,14 +328,14 @@ dependency injection.
2. redis.datasource.ts

The class uses a configuration object to set up a datasource for the Redis
instance. By default, the configuration is loaded from `redis.config.json`. We
can override it by binding a new object to `datasources.config.redis` for a
context.
instance. By default, the configuration is loaded from
`redis.datasource.config.json`. We can override it by binding a new object to
`datasources.config.redis` for a context.

```ts
import {inject} from '@loopback/core';
import {juggler, AnyObject} from '@loopback/repository';
import * as config from './redis.config.json';
import * as config from './redis.datasource.config.json';

export class RedisDataSource extends juggler.DataSource {
static dataSourceName = 'redis';
Expand Down
2 changes: 1 addition & 1 deletion docs/site/Testing-your-application.md
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ instance:

```ts
import {merge} from 'lodash';
import * as GEO_CODER_CONFIG from '../datasources/geo.config.json';
import * as GEO_CODER_CONFIG from '../datasources/geo.datasource.config.json';

function givenGeoService() {
const config = merge({}, GEO_CODER_CONFIG, {
Expand Down
10 changes: 5 additions & 5 deletions docs/site/deployment/Deploying-to-IBM-Cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ Cloudant connector, so data is persisted.

### Step 3: Updating your DataSource

Update `db.config.json` to use the Cloudant connector. The value for the `url`
property is just a placeholder and does not need to have the correct credential
because we will be binding the app with the Cloudant service once it's pushed to
IBM Cloud.
Update `db.datasource.config.json` to use the Cloudant connector. The value for
the `url` property is just a placeholder and does not need to have the correct
credential because we will be binding the app with the Cloudant service once
it's pushed to IBM Cloud.

```js
{
Expand Down Expand Up @@ -106,7 +106,7 @@ $ npm i loopback-connector-cloudant
import {TodoListApplication} from './application';
import {ApplicationConfig} from '@loopback/core';
// --------- ADD THIS SNIPPET ---------
const datasourceDb = require('./datasources/db.config.json');
const datasourceDb = require('./datasources/db.datasource.config.json');
const cfenv = require('cfenv');
const appEnv = cfenv.getAppEnv();
// --------- ADD THIS SNIPPET ---------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ JSON configuration file and a .ts file with the Datasource name and added an
entry inside the index.ts file.

```sh
create src/datasources/calculator.config.json
create src/datasources/calculator.datasource.config.json
create src/datasources/calculator.datasource.ts
update src/datasources/index.ts

Expand Down Expand Up @@ -103,10 +103,10 @@ bind the Node.js method _Multiply_.
}
```

Edit the file `src/datasources/calculator.config.json` and add the following
configuration after the `remoteEnabled: true,` property as follows:
Edit the file `src/datasources/calculator.datasource.config.json` and add the
following configuration after the `remoteEnabled: true,` property as follows:

{% include code-caption.html content="src/datasources/calculator.config.json" %}
{% include code-caption.html content="src/datasources/calculator.datasource.config.json" %}

```ts
"operations": {
Expand Down
2 changes: 1 addition & 1 deletion docs/site/tutorials/todo/todo-tutorial-datasource.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ lb4 datasource
? window.localStorage key to use for persistence (browser only):
? Full path to file for persistence (server only): ./data/db.json

create src/datasources/db.config.json
create src/datasources/db.datasource.config.json
create src/datasources/db.datasource.ts
update src/datasources/index.ts

Expand Down
4 changes: 2 additions & 2 deletions docs/site/tutorials/todo/todo-tutorial-geocoding-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $ lb4 datasource
? Default options for the request:
? An array of operation templates:
? Use default CRUD mapping: No
create src/datasources/geocoder.config.json
create src/datasources/geocoder.datasource.config.json
create src/datasources/geocoder.datasource.ts
# npm will install dependencies now
update src/datasources/index.ts
Expand All @@ -59,7 +59,7 @@ Edit the newly created datasource configuration to configure Geocoder API
endpoints. Configuration options provided by REST Connector are described in our
docs here: [REST connector](/doc/en/lb3/REST-connector.html).

{% include code-caption.html content="/src/datasources/geocoder.config.json" %}
{% include code-caption.html content="/src/datasources/geocoder.datasource.config.json" %}

```json
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import {inject} from '@loopback/core';
import {juggler} from '@loopback/repository';
import * as config from './ds.config.json';
import * as config from './ds.datasource.config.json';

export class DsDataSource extends juggler.DataSource {
static dataSourceName = 'ds';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import {inject} from '@loopback/core';
import {juggler} from '@loopback/repository';
import * as config from './calculator.config.json';
import * as config from './calculator.datasource.config.json';

export class CalculatorDataSource extends juggler.DataSource {
static dataSourceName = 'calculator';
Expand Down
2 changes: 1 addition & 1 deletion examples/todo-list/src/datasources/db.datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import {inject} from '@loopback/core';
import {juggler} from '@loopback/repository';
import * as config from './db.config.json';
import * as config from './db.datasource.config.json';

export class DbDataSource extends juggler.DataSource {
static dataSourceName = 'db';
Expand Down
2 changes: 1 addition & 1 deletion examples/todo/src/__tests__/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import {HttpCachingProxy} from '@loopback/http-caching-proxy';
import {merge} from 'lodash';
import * as path from 'path';
import * as GEO_CODER_CONFIG from '../datasources/geocoder.config.json';
import * as GEO_CODER_CONFIG from '../datasources/geocoder.datasource.config.json';
import {Todo} from '../models/index';
import {GeocoderService, GeoPoint} from '../services/geocoder.service';

Expand Down
2 changes: 1 addition & 1 deletion examples/todo/src/datasources/db.datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import {inject} from '@loopback/core';
import {juggler} from '@loopback/repository';
import * as config from './db.config.json';
import * as config from './db.datasource.config.json';

export class DbDataSource extends juggler.DataSource {
static dataSourceName = 'db';
Expand Down
2 changes: 1 addition & 1 deletion examples/todo/src/datasources/geocoder.datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import {inject} from '@loopback/core';
import {AnyObject, juggler} from '@loopback/repository';
import * as config from './geocoder.config.json';
import * as config from './geocoder.datasource.config.json';

export class GeocoderDataSource extends juggler.DataSource {
static dataSourceName = 'geocoder';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/generators/datasource/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ module.exports = class DataSourceGenerator extends ArtifactGenerator {
this.artifactInfo.className = utils.toClassName(this.artifactInfo.name);
this.artifactInfo.fileName = utils.toFileName(this.artifactInfo.name);
// prettier-ignore
this.artifactInfo.jsonFileName = `${this.artifactInfo.fileName}.config.json`;
this.artifactInfo.jsonFileName = `${this.artifactInfo.fileName}.datasource.config.json`;
// prettier-ignore
this.artifactInfo.outFile = `${this.artifactInfo.fileName}.datasource.ts`;

Expand Down
3 changes: 2 additions & 1 deletion packages/cli/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ exports.getDataSourceName = function(datasourcesDir, dataSourceClass) {

exports.dataSourceToJSONFileName = function(dataSourceClass) {
return path.join(
toFileName(dataSourceClass.replace('Datasource', '')) + '.config.json',
toFileName(dataSourceClass.replace('Datasource', '')) +
'.datasource.config.json',
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
ValueOrPromise,
} from '@loopback/core';
import {juggler} from '@loopback/repository';
import * as config from './ds.config.json';
import * as config from './ds.datasource.config.json';
@lifeCycleObserver('datasource')
export class DsDataSource extends juggler.DataSource
Expand Down Expand Up @@ -56,7 +56,7 @@ import {
ValueOrPromise,
} from '@loopback/core';
import {juggler} from '@loopback/repository';
import * as config from './ds.config.json';
import * as config from './ds.datasource.config.json';
@lifeCycleObserver('datasource')
export class DsDataSource extends juggler.DataSource
Expand Down Expand Up @@ -97,7 +97,7 @@ import {
ValueOrPromise,
} from '@loopback/core';
import {juggler} from '@loopback/repository';
import * as config from './ds.config.json';
import * as config from './ds.datasource.config.json';
@lifeCycleObserver('datasource')
export class DsDataSource extends juggler.DataSource
Expand Down Expand Up @@ -138,7 +138,7 @@ import {
ValueOrPromise,
} from '@loopback/core';
import {juggler} from '@loopback/repository';
import * as config from './ds.config.json';
import * as config from './ds.datasource.config.json';
@lifeCycleObserver('datasource')
export class DsDataSource extends juggler.DataSource
Expand Down Expand Up @@ -179,7 +179,7 @@ import {
ValueOrPromise,
} from '@loopback/core';
import {juggler} from '@loopback/repository';
import * as config from './ds.config.json';
import * as config from './ds.datasource.config.json';
@lifeCycleObserver('datasource')
export class DsDataSource extends juggler.DataSource
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/test/fixtures/relation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ exports.SANDBOX_FILES = [
},
{
path: DATASOURCE_APP_PATH,
file: 'dbkv.config.json',
file: 'dbkv.datasource.config.json',
content: JSON.stringify({
name: 'dbkv',
connector: 'kv-redis',
Expand All @@ -121,15 +121,15 @@ exports.SANDBOX_FILES = [
},
{
path: DATASOURCE_APP_PATH,
file: 'dbmem.config.json',
file: 'dbmem.datasource.config.json',
content: JSON.stringify({
name: 'dbmem',
connector: 'memory',
}),
},
{
path: DATASOURCE_APP_PATH,
file: 'my-ds.config.json',
file: 'my-ds.datasource.config.json',
content: JSON.stringify({
name: 'MyDS',
connector: 'memory',
Expand All @@ -142,15 +142,15 @@ exports.SANDBOX_FILES = [
},
{
path: DATASOURCE_APP_PATH,
file: 'restdb.config.json',
file: 'restdb.datasource.config.json',
content: JSON.stringify({
name: 'restdb',
connector: 'rest',
}),
},
{
path: DATASOURCE_APP_PATH,
file: 'sqlite3.config.json',
file: 'sqlite3.datasource.config.json',
content: JSON.stringify({
name: 'sqlite3',
connector: 'loopback-connector-sqlite3',
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/test/fixtures/repository/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exports.SANDBOX_FILES = [
},
{
path: DATASOURCE_APP_PATH,
file: 'dbkv.config.json',
file: 'dbkv.datasource.config.json',
content: JSON.stringify({
name: 'dbkv',
connector: 'kv-redis',
Expand All @@ -34,15 +34,15 @@ exports.SANDBOX_FILES = [
},
{
path: DATASOURCE_APP_PATH,
file: 'dbmem.config.json',
file: 'dbmem.datasource.config.json',
content: JSON.stringify({
name: 'dbmem',
connector: 'memory',
}),
},
{
path: DATASOURCE_APP_PATH,
file: 'my-ds.config.json',
file: 'my-ds.datasource.config.json',
content: JSON.stringify({
name: 'MyDS',
connector: 'memory',
Expand All @@ -55,15 +55,15 @@ exports.SANDBOX_FILES = [
},
{
path: DATASOURCE_APP_PATH,
file: 'restdb.config.json',
file: 'restdb.datasource.config.json',
content: JSON.stringify({
name: 'restdb',
connector: 'rest',
}),
},
{
path: DATASOURCE_APP_PATH,
file: 'sqlite3.config.json',
file: 'sqlite3.datasource.config.json',
content: JSON.stringify({
name: 'sqlite3',
connector: 'loopback-connector-sqlite3',
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/test/fixtures/service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ exports.SANDBOX_FILES = [
},
{
path: DATASOURCE_APP_PATH,
file: 'myds.config.json',
file: 'myds.datasource.config.json',
content: JSON.stringify({
name: 'myds',
connector: 'soap',
}),
},
{
path: DATASOURCE_APP_PATH,
file: 'map-ds.config.json',
file: 'map-ds.datasource.config.json',
content: JSON.stringify({
name: 'MapDS',
connector: 'soap',
Expand All @@ -47,7 +47,7 @@ exports.SANDBOX_FILES = [
},
{
path: DATASOURCE_APP_PATH,
file: 'dbmem.config.json',
file: 'dbmem.datasource.config.json',
content: JSON.stringify({
name: 'dbmem',
connector: 'memory',
Expand All @@ -60,7 +60,7 @@ exports.SANDBOX_FILES = [
},
{
path: DATASOURCE_APP_PATH,
file: 'restdb.config.json',
file: 'restdb.datasource.config.json',
content: JSON.stringify({
name: 'restdb',
connector: 'rest',
Expand Down
Loading

0 comments on commit 036bcc8

Please sign in to comment.