// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved. // Node module: @loopback/example-todo // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT import {inject, Provider} from '@loopback/core'; import {getService} from '@loopback/service-proxy'; import {GeocoderDataSource} from '../datasources'; export interface GeoPoint { /** * latitude */ y: number; /** * longitude */ x: number; } export interface Geocoder { geocode(address: string): Promise; } export class GeocoderProvider implements Provider { constructor( // geocoder must match the name property in the datasource json file @inject('datasources.geocoder') protected dataSource: GeocoderDataSource = new GeocoderDataSource(), ) {} value(): Promise { return getService(this.dataSource); } }