27 lines
667 B
JavaScript
27 lines
667 B
JavaScript
|
const { Errors } = require('../../shared')
|
||
|
|
||
|
module.exports = exports = async (message, di) => {
|
||
|
const Node = di.models.get('fs:Node')
|
||
|
const { path } = message.data()
|
||
|
|
||
|
let data
|
||
|
if ( path === '/' ) {
|
||
|
const root = await Node.get_root()
|
||
|
data = root.to_api()
|
||
|
} else {
|
||
|
const node = await Node.get_path(path, message.socket.session.overlay_name || 'mainline')
|
||
|
|
||
|
if ( !node ) {
|
||
|
return message.send_response(
|
||
|
message.fresh().error(Errors.NodeDoesNotExist)
|
||
|
)
|
||
|
}
|
||
|
|
||
|
data = node.to_api()
|
||
|
}
|
||
|
|
||
|
message.send_response(
|
||
|
message.fresh().data({ node: data })
|
||
|
)
|
||
|
}
|