Comparing version 2.3.0 to 3.0.0
{ | ||
"name": "quinn", | ||
"version": "2.3.0", | ||
"version": "3.0.0", | ||
"description": "Maybe coming some day.", | ||
"main": "dist/quinn.js", | ||
"scripts": { | ||
"test": "make clean lint test check-checkout-clean" | ||
"test": "jshint *.js && mocha --harmony" | ||
}, | ||
@@ -15,19 +15,12 @@ "author": { | ||
"dependencies": { | ||
"bluebird": "^2.1.2", | ||
"continuation-local-storage": "^3.0.0", | ||
"cookie": "^0.1.2", | ||
"debug": "^1.0.2", | ||
"lodash": "^2.4.1", | ||
"quinn-respond": "^2.0.0", | ||
"resolve-deep": "^1.0.1" | ||
"caseless": "^0.10.0" | ||
}, | ||
"devDependencies": { | ||
"envify": "^1.2.1", | ||
"jshint": "~2.5.1", | ||
"mocha": "^1.20.1", | ||
"quinn-render": "^1.0.0", | ||
"quinn-router": "^1.0.1", | ||
"quinnc": "^1.0.0", | ||
"react": "^0.10.0", | ||
"reakt": "0.0.5" | ||
"babel": "^5.1.10", | ||
"express": "^4.12.3", | ||
"gofer": "^2.3.6", | ||
"jshint": "^2.7.0", | ||
"mocha": "^2.2.4", | ||
"response": "^0.14.0", | ||
"wegweiser": "^3.2.1" | ||
}, | ||
@@ -34,0 +27,0 @@ "directories": { |
101
README.md
@@ -1,37 +0,90 @@ | ||
Maybe coming some day. | ||
# Quinn | ||
A web framework designed for things to come.<sup>[1]</sup> | ||
```js | ||
import { createServer } from 'http'; | ||
import quinn from 'quinn'; | ||
import respond from 'quinn/respond'; | ||
const app = quinn(req => respond({ body: 'Hello World!' })); | ||
createServer(app).listen(3000); | ||
``` | ||
## Concepts | ||
### Request handler | ||
*This is what others might call an "application".* | ||
*But "application is a pretty silly name.* | ||
A potentially async function that takes a request and returns a response. | ||
```js | ||
function(request, params) { | ||
return response; | ||
function handler(request) { | ||
return result; | ||
} | ||
``` | ||
#### `request` | ||
#### `Request` | ||
A node.js request object, as documented in the offical node.js docs. | ||
There are no additional properties, no magical extension methods. | ||
An [`http.IncomingMessage`](https://iojs.org/api/http.html#http_http_incomingmessage). | ||
There are no additional properties or magical extension methods. | ||
#### `params` | ||
#### `DispatchResult` | ||
Think: the "arguments". | ||
This can be path parameters, query parameters. | ||
`params` should never contain anything other than simple data. | ||
By default `params` defaults to an empty object. | ||
If a request handler forwards to a different handler, | ||
it should forward all params that were passed in. | ||
Injecting magic catch-all params is highly discouraged. | ||
Say no to `params.cookies` or `.session` or any other funny business. | ||
`params` SHOULD be a simple object. | ||
Any other kind of value should be the exception. | ||
Either a `VirtualResponse`<sup>[2]</sup> or `undefined`. | ||
If it's `undefined`, the handler was unable to handle the given request. | ||
E.g. the handler implements routing logic and no route matched the given url. | ||
#### `response` | ||
#### `VirtualResponse` | ||
Describes the response that should be returned. | ||
A proper response has a method to pipe to node.js response stream. | ||
It's also valid to return any of the things | ||
that can be coerced into a response object by `quinn.respond`. | ||
A pass-through stream describing the response that should be returned. | ||
While it might have additional utility functions, | ||
only the following properties and methods should be relied on: | ||
* [`response.setHeader(name, value)`](https://iojs.org/api/http.html#http_response_setheader_name_value) | ||
* [`response.getHeader(name)`](https://iojs.org/api/http.html#http_response_getheader_name) | ||
* [`response.removeHeader(name)`](https://iojs.org/api/http.html#http_response_removeheader_name) | ||
* [`response.statusCode`](https://iojs.org/api/http.html#http_response_statuscode) | ||
* [`response.write(chunk[, encoding][, callback])`](https://iojs.org/api/http.html#http_response_write_chunk_encoding_callback) | ||
* [`response.end([data][, encoding][, callback])`](https://iojs.org/api/http.html#http_response_end_data_encoding_callback) | ||
The behavior of each should match [`ServerResponse`](https://iojs.org/api/http.html#http_class_http_serverresponse). | ||
All headers and the status code should be forwarded | ||
when the response is piped to a target. | ||
The `statusCode` by setting the property, | ||
the headers by calls to `setHeader` on the target, one header at a time. | ||
Quinn itself only cares that it has a `pipe` method | ||
which is used to forward the data to a [`ServerResponse`](https://iojs.org/api/http.html#http_class_http_serverresponse). | ||
## Combining Quinn | ||
### With Express | ||
```js | ||
import express from 'express'; | ||
import quinn from 'quinn/express'; | ||
import respond from 'quinn/respond'; | ||
const app = express(); | ||
app.get('/quinn-route', quinn(req => respond({ body: 'Hello World!' }))); | ||
``` | ||
## References | ||
### Similar Libraries | ||
Most of these are based on JSGI. | ||
Which would make sense if node wouldn't include an http server. | ||
* [mikeal/response](https://github.com/mikeal/response) | ||
* [q-io](http://documentup.com/kriskowal/q-io#http-applications) | ||
* [bogart](https://github.com/nrstott/bogart) | ||
* [mach](https://github.com/mjackson/mach) | ||
----- | ||
<sup>[1]</sup> In other words: an experimental mess. | ||
<sup>[2]</sup> Because buzz word. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
7
91
7967
110
1
+ Addedcaseless@^0.10.0
+ Addedcaseless@0.10.0(transitive)
- Removedbluebird@^2.1.2
- Removedcontinuation-local-storage@^3.0.0
- Removedcookie@^0.1.2
- Removeddebug@^1.0.2
- Removedlodash@^2.4.1
- Removedquinn-respond@^2.0.0
- Removedresolve-deep@^1.0.1
- Removedasync-listener@0.6.10(transitive)
- Removedbluebird@2.11.0(transitive)
- Removedcaseless@0.3.0(transitive)
- Removedcontinuation-local-storage@3.2.1(transitive)
- Removedcookie@0.1.5(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removeddebug@1.0.5(transitive)
- Removedemitter-listener@1.1.2(transitive)
- Removedinherits@2.0.4(transitive)
- Removedisarray@0.0.1(transitive)
- Removedlodash@2.4.2(transitive)
- Removedms@2.0.0(transitive)
- Removedquinn-respond@2.0.1(transitive)
- Removedreadable-stream@1.1.14(transitive)
- Removedresolve-deep@1.0.1(transitive)
- Removedsemver@5.7.2(transitive)
- Removedshimmer@1.2.1(transitive)
- Removedstring_decoder@0.10.31(transitive)