QuorumDMS / ftp-srv

📮 Modern FTP Server
MIT License
387 stars 116 forks source link

Missing documentation / examples / interfaces #277

Open MickL opened 2 years ago

MickL commented 2 years ago

I want to integrate my own filesystem that does not actually save files to the disk but I face the problem of having no examples or further documentation.

Another problem is that all the interfaces of FileSystem class return any, so I have no idea what they should return.

For example the first problem I run into also is "Cannot read properties of undefined (reading 'isDirectory')". Seems like the listen() function should return fs.Stats, but I am not sure.

It would really help if there is no use of any within the interfaces/classes and more information in the readme what the functions should return. Also some example usage's would be great.

matt-forster commented 2 years ago

There is no typescript typing here - this is just a javascript project, so we can't control the types with any fidelity at the moment. They are maintained in a separate file, and we welcome contributions to those types until the project is rewritten in typescript.

https://github.com/autovance/ftp-srv/blob/master/src/fs.js Shows the default file system - it is easy to extend and all of the functions you need are exposed there. That is already in the readme - it should be enough to create filesystem functions that use a remote state like S3 or a database.

I'd like more information on your error. The server listen function has nothing to do with the filesystem - it looks like your program is trying to call the isDirectory function on an undefined object, which is indeed needed and a part of the stats structure you linked. One of your FS overrides is returning undefined.

Consider using a package like https://github.com/streamich/memfs to approximate these structures easily in your overrides.

I agree that the documentation can be improved, and that would be an awesome first contribution!

matt-forster commented 2 years ago

Relevant discussion: #260