npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hasnat/rest-fs

v0.2.0

Published

restful fileserver

Downloads

5

Readme

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

ETags

rest-fs supports ETags by default. Each api endpoint will return a strict ETag header that clients can utilize when making subsequent requests. Please see [http://en.wikipedia.org/wiki/HTTP_ETag](this article) for more information on using ETags.

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" }, ... ]

File Stats

?stats = Return file stats for the directory instead of file listing.

res.body = {
  dev: 16777220,
  mode: 16877,
  nlink: 31,
  uid: 501,
  gid: 20,
  rdev: 0,
  blksize: 4096,
  ino: 604862,
  size: 1054,
  blocks: 0,
  atime: Thu Mar 05 2015 11:38:47 GMT-0800 (PST),
  mtime: Thu Mar 05 2015 10:52:41 GMT-0800 (PST),
  ctime: Thu Mar 05 2015 10:52:41 GMT-0800 (PST)
}

GET /path/to/file

returns contents of file if dir, redirect to dir path

optional ?encoding = default utf8

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

File Stats

?stats = Return file stats for the file instead of file's contents.

res.body = {
  dev: 16777220,
  mode: 16877,
  nlink: 31,
  uid: 501,
  gid: 20,
  rdev: 0,
  blksize: 4096,
  ino: 604862,
  size: 1054,
  blocks: 0,
  atime: Thu Mar 05 2015 11:38:47 GMT-0800 (PST),
  mtime: Thu Mar 05 2015 10:52:41 GMT-0800 (PST),
  ctime: Thu Mar 05 2015 10:52:41 GMT-0800 (PST)
}

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 = {}