Description
sftp-fs is intended to allow for easy implementation of a SFTP server where the server file system can be anything. You can implement an ordinary file system as is done in FileSystem.js. But for any other type of filesystem-like backends you can just extend the FileSystemInterface class and do something cool.
Technical stuff
Is built ontop of ssh2 as most SSH stuff in node.js is. I have elected to use yarn for this project but using npm will work just as well.
Running tests
$ yarn
...
$ yarn lint
...
$ yarn test
...
Examples
Starting the standard file serving SFTP server
$ yarn
...
$ yarn server
...
"use strict";
const { FileSystemInterface, Server } = require("sftp-fs");
class MyFS extends FileSystemInterface {
}
const keyFile = "./id_rsa";
const port = 8022;
const server = new Server(new MyFS());
process.on("SIGINT", () => server.stop());
const run = async () => {
server.on("client-connected", () => console.log("Client connected!"));
server.on("client-disconnected", () => console.log("Client disconnected!"));
server.on("error", (error) => console.error(error));
await server.start(keyFile, port);
};
run();