Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {def} from './CustomerController.api';
import {api, inject} from 'loopback-next/packages/loopback';
let DataSource = require('../../loopback-datasource-juggler').DataSource;
let ds = new DataSource('CustomerDB', {
"connector": "memory",
"file": "data.json"
});
@api(def)
export class CustomerController {
constructor() {
var Customer = ds.define('Customer', {
name: String,
});
}
public async query() : Promise{
var Customer = ds.define('Customer', {
name: String,
});
var data = await Customer.find();
console.log(data[0].customerNumber);
return JSON.stringify({customerNumber: data[0].customerNumber, firstName: data[0].firstName});
}
}
import {api} from 'loopback-next/packages/loopback';
import {def} from './FacadeController.api';
import {AccountRepository} from '../repositories/accounts';
import {CustomerRepository} from '../repositories/customer';
import {TransactionRepository} from '../repositories/transaction';
const bluebird = require('bluebird');
@api(def)
export class FacadeController {
async getSummary(accountNumber) : Promise {
const accountRepository = new AccountRepository();
const customerRepository = new CustomerRepository();
const transactionRepository = new TransactionRepository();
const accounts = await accountRepository.find(accountNumber);
const summary = await bluebird.props ({
account: accounts,
customer: customerRepository.find(accounts.customerNumber),
transaction: transactionRepository.find(accountNumber)
});
return Promise.resolve(JSON.stringify(summary));
}
}
constructor(@inject('app.info') private _info: VitalsResponse) {
this._info = {uptime: 1000};
}