Total Complexity | 1 |
Complexity/F | 0 |
Lines of Code | 24 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import Elasticsearch from '../services/elasticsearch' |
||
2 | import Redis from '../services/redis' |
||
3 | import Service from '../services/service' |
||
4 | |||
5 | const getOptionalServiceByname = (serviceName: string): Service => { |
||
6 | let service: Service |
||
7 | |||
8 | switch (serviceName) { |
||
9 | case (new Redis).service: |
||
10 | service = new Redis() |
||
11 | break |
||
12 | case (new Elasticsearch).service: |
||
13 | service = new Elasticsearch() |
||
14 | break |
||
15 | default: |
||
16 | throw Error('Invalid service: ' + serviceName) |
||
17 | } |
||
18 | |||
19 | return service |
||
20 | } |
||
21 | |||
22 | export { |
||
23 | getOptionalServiceByname |
||
24 | } |