Code Monkey home page Code Monkey logo

rest-fs's Introduction

rest-fs

restful interface to a filesystem

usage

npm install rest-fs

to install

npm start

starts fileserver on port 3000

npm test

runs various file and folder test

npm start

starts server on port 3000 of your entire system

LOG=true for access log

DEBUG=* for debug info

app = require('express')();
restfs = require('rest-fs')
restfs(app);
app.listen(3000)

To use programmatically, pass in the app into restfs and it will add the routes. you can attach a function to modifyOut to manipulate file output. the function has one argument which is the full filepath and should return path to return

API

GET /path/to/dir/

list contents of directory

optional
?recursive = list recursively default false

returns: list of full file or folder paths (trailing slash tells if dir)

res.body = [ { "fullDirPath" }, ... ]

GET /path/to/file

returns contents of file
if dir, redirect to dir path

optional
?encoding = default utf8

returns: res.body = { "file content" }

POST /path/to/file/or/dir

creates or overwrites file
creates dir if it does not exist.
renames or moves file if newPath exists

optional
body.newpath = if exist, move/rename file to this location.
body.clobber = if true will overwrite dest files (default false)
body.mkdirp = if true will create path to new location (default false)
body.mode = permissions of file (defaults: file 438(0666) dir 511(0777))
body.encoding = default utf8

optional for stream
query.clobber = overwrite if exist query.mode = permissions of file (defaults: file 438(0666) dir 511(0777))
query.encoding = default utf8

returns: modified resource. (trailing slash tells if dir)

req.body = { "fullFileOrDirPath" }

PUT /path/to/file

creates file

optional
body.mode = permissions of file (438 default 0666 octal)
body.encoding = default utf8

returns: modified resource (trailing slash tells if dir)

req.body = { "fullFilePath" }

DEL /path/to/dir/

deletes folder
if file returns error

returns:

req.body = {}

DEL /path/to/file

deletes file
if folder returns error

returns:

req.body = {}

rest-fs's People

Contributors

anandkumarpatel avatar rrthomas avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.