scrapper-tools
Version:
Its in development but I use it in all my web automation project.
42 lines (39 loc) • 795 B
text/typescript
import consoleMessage from './consoleMessage'
import node_ssh from 'node-ssh'
/// # Allows you to upload Via SSH
/// @Todo Lock
export default (() => {
let handler
return {
handler: async () => {
if (!handler) {
throw 'No SSH Handler found'
}
return handler
},
connect: async ({
host,
port,
username,
privatekeyPath,
}: {
host: string
port: string
privatekeyPath: string
username: string
}) => {
try {
let ssh = new node_ssh()
handler = await ssh.connect({
host,
port,
username,
privateKey: privatekeyPath,
})
return handler
} catch (e) {
consoleMessage.error('Error at ssh', e)
}
},
}
})()