Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {DataSourceConstructor} from '@loopback/repository';
// mixin of data source into service is not yet available, swagger.json needs to
// be loaded synchronously (ie. can't instantiate in the class constructor)
let SwaggerClient = require('swagger-client');
const ds = new DataSourceConstructor('TransactionService', {
connector: 'swagger',
spec: 'repositories/transaction/swagger.json',
});
export class TransactionRepository {
model;
constructor() {
this.model = ds.createModel('TransactionService', {});
}
async find(accountNumber) {
const response = await this.model.findById({id: accountNumber});
return (response && response.obj) || [];
}
}
// Copyright IBM Corp. 2018. All Rights Reserved.
// Node module: loopback4-example-microservices
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
import {DataSourceConstructor, DataSourceType} from '@loopback/repository';
import {customerDefinition} from './customer.repository.api';
export const dataSource: DataSourceType = new DataSourceConstructor(
'CustomerService',
{
connector: 'loopback-connector-swagger',
spec: customerDefinition,
},
);
// Copyright IBM Corp. 2018. All Rights Reserved.
// Node module: loopback4-example-microservices
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
import {DataSourceConstructor, DataSourceType} from '@loopback/repository';
import * as path from 'path';
export const dataSource: DataSourceType = new DataSourceConstructor(
'local-fs',
{
connector: 'memory',
file: path.resolve(__dirname, './data.json'),
},
);
// Copyright IBM Corp. 2018. All Rights Reserved.
// Node module: loopback4-example-microservices
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
import {DataSourceConstructor, DataSourceType} from '@loopback/repository';
import {transactionDefinition} from './transaction.repository.api';
export const dataSource: DataSourceType = new DataSourceConstructor(
'TransactionService',
{
connector: 'loopback-connector-swagger',
spec: transactionDefinition,
},
);
// Copyright IBM Corp. 2018. All Rights Reserved.
// Node module: loopback4-example-microservices
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
import {DataSourceConstructor, DataSourceType} from '@loopback/repository';
import * as path from 'path';
export const dataSource: DataSourceType = new DataSourceConstructor('memory', {
connector: 'memory',
file: path.resolve(__dirname, './data.json'),
});
// Copyright IBM Corp. 2018. All Rights Reserved.
// Node module: loopback4-example-microservices
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
import {DataSourceConstructor, DataSourceType} from '@loopback/repository';
import {accountDefinition} from './account.repository.api';
export const dataSource: DataSourceType = new DataSourceConstructor(
'AccountService',
{
connector: 'loopback-connector-swagger',
spec: accountDefinition,
},
);
constructor() {
super();
const app = this;
let ds = datasources['ds'];
// Controller bindings
app.controller(TodoController);
let datasource = new DataSourceConstructor('ds', ds);
app.bind('datasources.ds').to(datasource);
// Server protocol bindings
app.bind('servers.http.enabled').to(true);
app.bind('servers.https.enabled').to(true);
}
// Copyright IBM Corp. 2018. All Rights Reserved.
// Node module: loopback4-example-microservices
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
import {DataSourceConstructor, DataSourceType} from '@loopback/repository';
import * as path from 'path';
export const dataSource: DataSourceType = new DataSourceConstructor('memory', {
connector: 'memory',
file: path.resolve(__dirname, './data.json'),
});
import {DataSourceConstructor} from '@loopback/repository';
// mixin of data source into service is not yet available, swagger.json needs to
// be loaded synchronously (ie. can't instantiate in the class constructor)
let SwaggerClient = require('swagger-client');
const ds = new DataSourceConstructor('CustomerService', {
connector: 'swagger',
spec: 'repositories/customer/swagger.json',
});
export class CustomerRepository {
model;
constructor() {
this.model = ds.createModel('CustomerService', {});
}
async find(customerNumber) {
const response = await this.model.findById({id: customerNumber});
return (response && response.obj) || [];
}
}
constructor() {
const ds = new DataSourceConstructor('local-fs', {
connector: 'memory',
file: './repositories/transaction/datasources/local-fs/data.json',
});
this.model = ds.createModel('Transaction', modelDefinition);
}