mirror of
https://github.com/chaos-zhu/easynode.git
synced 2026-06-23 11:28:14 +08:00
25 lines
721 B
JavaScript
25 lines
721 B
JavaScript
const { HostListDB, CredentialsDB, FavoriteSftpDB } = require('../utils/db-class')
|
|
|
|
const favoriteSftpDB = new FavoriteSftpDB().getInstance()
|
|
|
|
async function getSftpFavorites({ params, request, res }) {
|
|
try {
|
|
const hostId = params?.hostId || request.query?.hostId
|
|
if (!hostId) {
|
|
return res.fail({ msg: 'missing hostId' })
|
|
}
|
|
const favorites = await favoriteSftpDB.findAsync(
|
|
{ hostId },
|
|
{ sort: { createTime: -1 } }
|
|
)
|
|
return res.success({ data: favorites, msg: 'success' })
|
|
} catch (error) {
|
|
logger.error('getSftpFavorites error:', error.message)
|
|
return res.fail({ msg: error.message || 'mobile sftp favorites failed' })
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
getSftpFavorites
|
|
}
|