Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit 2e4fd85

Browse files
committed
Move from vfs to it's own repo
1 parent 339a2f0 commit 2e4fd85

File tree

6 files changed

+792
-3
lines changed

6 files changed

+792
-3
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2012 Ajax.org B.V
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+67-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,68 @@
1-
vfs-http-adapter
2-
================
1+
# HTTP Adapter
2+
3+
This module is a connect/stack middleware module that wraps a vfs instance and
4+
serves it via a HTTP RESTful interface.
5+
6+
The module is a setup function that creates a middleware instance.
7+
8+
```js
9+
var root = "http://localhost:8080/rest/";
10+
11+
var vfs = require('vfs-local')({
12+
root: process.cwd(),
13+
httpRoot: root,
14+
});
15+
16+
require('http').createServer(require('stack')(
17+
require('vfs-http-adapter')("/rest/", vfs)
18+
)).listen(8080);
19+
20+
console.log("RESTful interface at " + root);
21+
```
22+
23+
## `HEAD /any/path`
24+
25+
All HEAD requests are converted to GET requests internally and act identical,
26+
except there is an internal flag in the vfs layer telling it to not stream the body.
27+
28+
## `GET /path/to/file`
29+
30+
Serve a file to the client as a stream. Supports etags and range requests.
31+
32+
## `GET /directory/path/with/slash/`
33+
34+
Serve a directory listing as a JSON document.
35+
36+
This is served as a streaming json document with a weak etag (since the order
37+
of the entries is not defined.) It supports conditional GET requests
38+
39+
See `vfs.readdir` below for the format of the JSON.
40+
41+
## `PUT /path/to/file`
42+
43+
Recieve a file from the client and save it to the vfs. The file body is streamed.
44+
45+
## `PUT /directory/path/with/slash/`
46+
47+
Create a directory
48+
49+
## `DELETE /path/to/file`
50+
51+
Delete a file.
52+
53+
## `DELETE /directory/path/with/slash/`
54+
55+
Delete a directory (not recursive)
56+
57+
58+
## `POST /path/to/target`
59+
60+
POST is used for various adhoc commands that are useful but don't fit well into
61+
the RESTful paradigm. The client sends a JSON body containing the request information.
62+
63+
Currently this includes:
64+
65+
- {"renameFrom": from} - rename a file from `from` to `target`.
66+
- {"copyFrom": from} - copy a file from `from` to `target`.
67+
- {"linkTo": data} - create a symlink at `target` containing `data`.
368

4-
A Restful front-end to a vfs instance

0 commit comments

Comments
 (0)