parent
6ddc0dd5b5
commit
c424980bb7
5 changed files with 63 additions and 0 deletions
@ -0,0 +1,43 @@ |
|||||||
|
import buildGetRequestHandler from '../buildGetRequestHandler'; |
||||||
|
|
||||||
|
export const getNetworkInterface = buildGetRequestHandler( |
||||||
|
(request, buildQueryOptions) => { |
||||||
|
if (buildQueryOptions) { |
||||||
|
buildQueryOptions.afterQueryReturn = (queryStdout) => { |
||||||
|
let result = queryStdout; |
||||||
|
|
||||||
|
if (queryStdout instanceof Array) { |
||||||
|
result = queryStdout.map<NetworkInterfaceOverview>( |
||||||
|
([ |
||||||
|
networkInterfaceUUID, |
||||||
|
networkInterfaceMACAddress, |
||||||
|
networkInterfaceName, |
||||||
|
networkInterfaceState, |
||||||
|
networkInterfaceSpeed, |
||||||
|
networkInterfaceOrder, |
||||||
|
]) => ({ |
||||||
|
networkInterfaceUUID, |
||||||
|
networkInterfaceMACAddress, |
||||||
|
networkInterfaceName, |
||||||
|
networkInterfaceState, |
||||||
|
networkInterfaceSpeed, |
||||||
|
networkInterfaceOrder, |
||||||
|
}), |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
return result; |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
return ` |
||||||
|
SELECT |
||||||
|
network_interface_uuid, |
||||||
|
network_interface_mac_address, |
||||||
|
network_interface_name, |
||||||
|
network_interface_operational, |
||||||
|
network_interface_speed, |
||||||
|
ROW_NUMBER() OVER(ORDER BY modified_date ASC) AS network_interface_order |
||||||
|
FROM network_interfaces;`;
|
||||||
|
}, |
||||||
|
); |
@ -0,0 +1 @@ |
|||||||
|
export { getNetworkInterface } from './getNetworkInterface'; |
@ -0,0 +1,9 @@ |
|||||||
|
import express from 'express'; |
||||||
|
|
||||||
|
import { getNetworkInterface } from '../lib/request_handlers/network-interface'; |
||||||
|
|
||||||
|
const router = express.Router(); |
||||||
|
|
||||||
|
router.get('/', getNetworkInterface); |
||||||
|
|
||||||
|
export default router; |
@ -0,0 +1,8 @@ |
|||||||
|
type NetworkInterfaceOverview = { |
||||||
|
networkInterfaceUUID: string; |
||||||
|
networkInterfaceMACAddress: string; |
||||||
|
networkInterfaceName: string; |
||||||
|
networkInterfaceState: string; |
||||||
|
networkInterfaceSpeed: number; |
||||||
|
networkInterfaceOrder: number; |
||||||
|
}; |
Loading…
Reference in new issue