forked from deic-dk-retired/ddosapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicmp.js
35 lines (33 loc) · 734 Bytes
/
icmp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// connect to db and then get the
// query handler method
var db = require('./db')
function getIcmps (req, res, next) {
var allTypesIcmp = db.miniQuery('.sql/misc/allTnCicmps.sql')
db.foddb.any(allTypesIcmp)
.then(function (data) {
// json api
res.status(200)
.json({
data: data.map(function (e) {
return {
type: 'icmps',
id: e.id,
attributes: {
name: e.name,
codeid: e.codeid,
code: e.code
}
}
}),
meta: {
total: data.length
}
})
})
.catch(function (err) {
return next(err.message)
})
}
module.exports = {
getIcmps: getIcmps
}