Ezhilarasi | ebbafca | 2019-04-11 21:09:26 +0530 | [diff] [blame] | 1 | import {getService} from '@loopback/service-proxy'; |
| 2 | import {inject, Provider} from '@loopback/core'; |
| 3 | import {ResourceDictionaryDataSource} from '../datasources'; |
| 4 | |
| 5 | export interface ResourceDictionaryService { |
| 6 | getByName(name: string, authtoken: string): Promise<JSON>; |
| 7 | getSourceMapping(authtoken: string): Promise<JSON>; |
| 8 | getByTags(tags: string, authtoken: string): Promise<JSON>; |
| 9 | save(authtoken: string, resourceDictionary: JSON): Promise<JSON>; |
| 10 | searchbyNames(authtoken: string, resourceDictionaryList: JSON): Promise<JSON>; |
| 11 | } |
| 12 | |
| 13 | export class ResourceDictionaryServiceProvider implements Provider<ResourceDictionaryService> { |
| 14 | constructor( |
| 15 | // resourceDictionary must match the name property in the datasource json file |
| 16 | @inject('datasources.resourceDictionary') |
| 17 | protected dataSource: ResourceDictionaryDataSource = new ResourceDictionaryDataSource(), |
| 18 | ) {} |
| 19 | |
| 20 | value(): Promise<ResourceDictionaryService> { |
| 21 | return getService(this.dataSource); |
| 22 | } |
| 23 | } |