svc-fbr

0.2.0 • Public • Published

svc-fbr

File Browser Service

node npm Travis Gemnasium Coveralls

This module can be used in different ways:

  1. As a standalone service: running the module's server in the background allows different processes to use this service through a REST API. This allows user to traverse an accessible network file system (NFS). The terminal interface is useful in controlling the service on the host. Note: you can import the module in your Node.js applications to abstract the REST api.

  2. As an imported module: you can simply require the module in Node.js applications thus using the module API. This should be used by application accessing file systems attached to the system.

⇒ npm install svc-fbr --global

Module API:

const fbr = require("svc-fbr");

fbr.start([options [, callback]])

Start the service.

fbr.ping([options [, callback]])

Ping the service.

  • options (service options)
  • callback (Function):
    • signature: callback(err, response)
    • response (Object): passed on success
    • response.running (Boolean)

fbr.stop([options [, callback]])

Stop the service.

fbr.query(params, callback)

Query service.

service options

An Object of options as configurations of the service.

Properties:

  • ip (String): ip of server
  • port (Number): port of the server
  • home: (String) path to home directory. This is default path used if path parameter is not passed.

Prescedence (from Left-To-Right):

  • ip: arguments, ${FBRS_IP}, "127.0.0.1"
  • port: arguments, ${FBRS_PORT}, 9432
  • home: arguments, ${FBRS_HOME}, process.env.HOME

parameters

An Object of query parameters.

Properties:

  • path (String): path to look up
  • ignoreDotFiles (Boolean=false): ignore files with names starting with a . (dot).
  • ignoreCurDir (Boolean=false): ignore the current directory, ., from results.
  • ignoreUpDir (Boolean=false): ignore the upper directory, .., from results.
  • statEach (Boolean=true): stat each of the contained files if path is a directory.

REST API:

Available endpoints once the service is started.

traversal of file-system:

GET /

The parameters should be sent as query string.

Success response:

  • status: 200 OK
  • body:
{
  "content": <content>,
  "<type>": true
}

where <content> would be:

  • String[]: array of fs.Stats, if path points to directory
  • String: file content, if path points to file and <type> would be the name of a fs.Stats function e.g. "isDirectory", that returns true.

ping service:

GET /ping

Success response:

  • status: 200 OK

stopping service:

GET /stop

Success response:

  • status: 200 OK

terminal usage:

⇒ svc-fbr help
svc-fbr: file browser service
 
    ?, status      check status of service
    H, help        show this help information
    V, version     show version information
    s, start       start service
    x, stop        stop service
 
See https://github.com/forfutureLLC/svc-fbr for feature-requests and bug-reports

tips:

To start the service as daemon, use forever:

$ forever start svc-fbr start    # note the TWO <start>s 

license:

The MIT License (MIT)

Copyright (c) 2015 Forfuture LLC we@forfuture.co.ke

Readme

Keywords

Package Sidebar

Install

npm i svc-fbr

Weekly Downloads

0

Version

0.2.0

License

MIT

Last publish

Collaborators

  • gochomugo
  • forfuture