Passed
Pull Request — master (#25)
by Alejandro
06:29
created

server.js ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
nop 1
1
import { curry } from 'ramda';
2
import serversService from '../services/ServersService';
3
4
export const FETCH_SERVERS = 'shlink/servers/FETCH_SERVERS';
5
6
export default function reducer(state = {}, action) {
7
  switch (action.type) {
8
    case FETCH_SERVERS:
9
      return action.servers;
10
    default:
11
      return state;
12
  }
13
}
14
15
export const _listServers = (serversService) => ({
16
  type: FETCH_SERVERS,
17
  servers: serversService.listServers(),
18
});
19
20
export const listServers = () => _listServers(serversService);
21
22
export const _createServer = (serversService, server) => {
23
  serversService.createServer(server);
24
25
  return _listServers(serversService);
26
};
27
28
export const createServer = curry(_createServer)(serversService);
29
30
export const _deleteServer = (serversService, server) => {
31
  serversService.deleteServer(server);
32
33
  return _listServers(serversService);
34
};
35
36
export const deleteServer = curry(_deleteServer)(serversService);
37
38
export const _createServers = (serversService, servers) => {
39
  serversService.createServers(servers);
40
41
  return _listServers(serversService);
42
};
43
44
export const createServers = curry(_createServers)(serversService);
45