src/helpers/endpoints/all.js   A
last analyzed

Complexity

Total Complexity 3
Complexity/F 3

Size

Lines of Code 23
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 3
c 1
b 0
f 0
nc 1
mnd 2
bc 3
fnc 1
dl 0
loc 23
rs 10
bpm 3
cpm 3
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A all.js ➔ listAll 0 16 3
1
'use strict'
2
3
import Table from 'cli-table'
4
import assert from 'assert-plus'
5
6
function listAll (server) {
7
  assert.object(server)
8
9
  const routes = server.router.getRoutes()
10
  const table = new Table({ head: ['', 'name', 'path'] })
11
12
  for (let key in routes) {
13
    if (routes.hasOwnProperty(key)) {
14
      const val = routes[key]
15
      const _o = {}
16
      _o[val.method] = [val.name, val.path]
17
      table.push(_o)
18
    }
19
  }
20
  return table.toString()
21
}
22
23
module.exports = listAll
24