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

file-commander

v0.1.12

Published

File manager for express

Downloads

7

Readme

FileCommander

FileCommander is Express-compatible file manager middleware for Node.js.

Supported platforms

All platforms supported by Node.js with Linux-like file system path format. MS Windows support will be added soon. Please note, that the application was tested on Mac OS X 10.9 and Linux Ubuntu 12.04 only.

Install

$ npm install file-commander

Run tests

Go to the root directory of the file-commander module, make sure dependencies are installed and run the tests.

$ cd node_modules/file-commander
$ npm install
$ npm test

Simple examples

There are four simple examples of file-commander middleware usage. Each of the examples implements separate part of the interface, that is read-only or read-write access with html or rest interface.

Run example with read-only access with html interface like this:

$ cd examples/plain_read-only
$ node server.js

Demo application

This example uses all the parts of the file-commander interface. You may see it running on file-commander.com.

To install the application go to root directory of the file-commander installation and do:

$ cd examples/full
$ npm install

Run the application using default configuration like this (see default.json file):

$ node index.js

To run the application using production configuration update production.json file with settings for your database and authentication strategies and run the application like this:

$ NODE_ENV=production node index.js

Authentication

For default configuration, there are two default users for testing purposes. You may log in as "test" or "user" with password the same as the user name. There is no support for registration of new users.

For production usage, Google and GitHub authentication strategies based on Passport are supported.

Public interface

Commander class

The Commander class is an entry point to the file-commander module. Create instance of the class, call serverBased or restBased method on the created instance and it returns a middleware. There are two base settings - read-only (GET method only provided) and read-write (GET, POST and DELETE methods provided). See examples for details.

Request body properties used by the file-commander middleware:

Body

  • name - new name (optional)
  • local - path to source (optional)
  • force - not empty string => true (optional)
  • preserve - not empty string => true (optional)

Output of the serverBased middleware:

The result is stored in the request object using fcmder property. If the fcmder property is falsy, then the middleware was not able to serve the request, usually because the resources had not been found. Request-response cycle is not finished (no response sent).

GET request

  • req.fcmder.fs.path.name - current path
  • req.fcmder.fs.files.names - array of file names contained in the current directory
  • req.fcmder.fs.files.stats - stats for the each file in a form of an object using file names as keys

POST or DELETE request

  • req.fcmder.state.code - proposed http status code
  • req.fcmder.state.err - error flag
  • req.fcmder.state.msg - short message
  • req.fcmder.state.desc - detail description of current state (may be an error message if an error occurred or an object otherwise)
  • req.fcmder.state.desc.loc - proposed value to be set as http location header field (supplied for 201 statuses only)

Built-in REST API (restBased middleware):

Accessible via url prefix /rest-api. Finishes request-response cycle if possible (resources found). See examples for details.

Read directory

GET request

  • url - "/path/to/directory"

Make default directory

POST request

  • url - "/path/to/parent/directory"
  • body - empty

Make named directory

POST request

  • url - "/path/to/parent/directory"
  • body - { name: "my_new_directory" }

Move

POST request

  • url - "/path/to/destination/directory"
  • body - { local: "/path/to/resources/to/be/moved" }

Move and rename

POST request

  • url - "/path/to/destination/directory"
  • body - { name: "my_moved_resources", local: "/path/to/resources/to/be/moved" }

Copy

POST request

  • url - "/path/to/destination/directory"
  • body - { preserve: "preserve", local: "/path/to/resources/to/be/copied" }

Copy and rename

POST request

  • url - "/path/to/destination/directory"
  • body - { name: "my_copied_resources", preserve: "preserve", local: "/path/to/resources/to/be/copied" }

Delete

DELETE request

  • url - "/path/to/file/or/empty/directory/to/be/removed"
  • body - empty

Force delete

DELETE request

  • url - "/path/to/resorces/to/be/removed"
  • body - { force: "force" }

Upload

  • url - "/path/to/destination/directory"
  • encoding - multipart/form-data