Browse Source

more docs

master
mortie 7 years ago
parent
commit
d12294cba4
2 changed files with 15 additions and 2 deletions
  1. 14
    1
      README.md
  2. 1
    1
      package.json

+ 14
- 1
README.md View File

@@ -107,11 +107,24 @@ Serve static files.
files in the `web` directory under `/static`, so `/static/script.js` will
serve `web/script.js`.

### Transformations - app.transform(extension, mime, function)
### Transformations - app.transform(extension, mime, func)

Webframe has a way to transform files of one file type to an other, for example
transforming typescript into javascript, or sass into CSS.

* `extension`: The file extension to transform.
* `mime`: The result mime type.
* `func`: function(path, writeStream). The transform function.
* `writeStream.headersSent`: Whether headers have been sent or not.
* `writeStream.status`: The status code. Default: 200 (or 500 for errors)
* `writeStream.headers`: An object containing the headers to be sent.
Default: `{ "content-type": <mime> }`
* `writeStream.write`: function(data). Write response data.
* `writeStream.end`: function([data]). End the request, optionally with
response data.
* `writeStream.error`: function(err). Log an error, respond with status
code 500 (or the content of `writeStream.status` if it's not 200).

Example (assumes you have the node-sass module installed):

```

+ 1
- 1
package.json View File

@@ -1,6 +1,6 @@
{
"name": "webframe",
"version": "0.4.1",
"version": "0.4.2",
"description": "Web framework.",
"main": "index.js",
"scripts": {

Loading…
Cancel
Save