24 lines
749 B
JavaScript
24 lines
749 B
JavaScript
const { Errors } = require('../../shared')
|
|
|
|
module.exports = exports = async (message, di) => {
|
|
const Node = di.models.get('fs:Node')
|
|
const { path } = message.data()
|
|
|
|
if ( path !== '/' ) {
|
|
// If the path isn't the root of the workspace, then make
|
|
// sure that the parent node actually exists
|
|
const node = await Node.get_path(path, message.socket.session.overlay_name || 'mainline')
|
|
if ( !node ) {
|
|
return message.send_response(
|
|
message.fresh().error(Errors.NodeDoesNotExist)
|
|
)
|
|
}
|
|
}
|
|
|
|
const nodes = await Node.list_path(path, message.socket.session.overlay_name || 'mainline')
|
|
|
|
message.send_response(
|
|
message.fresh().data({ nodes })
|
|
)
|
|
}
|