Skip to content

Commit

Permalink
Merge pull request #6 from fyrejet/nextminor
Browse files Browse the repository at this point in the history
v2.2.0
  • Loading branch information
schamberg97 authored Oct 20, 2020
2 parents db51487 + 9d7e955 commit fcc5a62
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 247 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Fyrejet is shared with the community under MIT License.

## Breaking changes from `1.x` to `2.0`

* `uWebSockets.js` compatibility implementation has been rewritten from scratch and it no longer relies on 0http's `low` library, at least until it has the same improvements as we do have. Moreover, the tests are now shared between `Fyrejet` and `Fyrejet + uWebSockets.js`. As such, certain dirty hacks are no longer used, which means that projects using `Fyrejet 1.x` and uWebSockets can be slightly incompatible with `Fyrejet 2`. Thus, according to Semantic Versioning, it has to versioned as `Fyrejet 2`.
* `uWebSockets.js` compatibility implementation has been rewritten from scratch and it no longer relies on 0http's `low` library, at least until it has the same improvements as we do have. Moreover, the tests are now shared between `Fyrejet` and `Fyrejet + uWebSockets.js`. As such, certain dirty hacks are no longer used, which means that projects using `Fyrejet 1.x` and uWebSockets can be slightly incompatible with `Fyrejet 2`. Thus, according to Semantic Versioning, it has to be versioned as `Fyrejet 2`.
* When using `uWebSockets.js`, `serverType` has to be `uWebSockets` and not `uWebSocket`, as the former is a more correct project name. `uWebSocket` will be silently changed into `uWebSockets`. Next release will show deprecation messages.
* That's it :)

Expand Down Expand Up @@ -381,25 +381,30 @@ No known caveats yet.

## uWebSockets

Fyrejet includes BETA support for uWebSockets.
Fyrejet includes support for uWebSockets.

Versions 17.5.0 and 18.5.0 have been tested and do seem to work. Despite this, minor incompatibilities are expected. Please refer to Known problems section.

Despite, uWebSockets offers promising performance dividends for existing Express apps. For specific performance results, please check the [Benchmarks](#Benchmarks).



Versions 2.0-2.1.1 included their own internal fork of [jkybernees's `0http 2.x` `low` server](https://github.com/jkyberneees/0http/blob/v2/lib/server/low.js). Since then, it was forked into a separate project, [`low-http-server`](https://github.com/jkyberneees/low-http-server). [Fyrejet's changes were committed to that project](https://github.com/jkyberneees/low-http-server/pull/7) and low-http-server is deemed mostly production ready. Thus, from version 2.2.0, Fyrejet will use `low-http-server` instead of its own uWebSockets compatibility layer. This should not impact any existing Fyrejet apps, since both implementations are compatible and are very similar. However, this should mean additional features, [like SSL](https://github.com/jkyberneees/low-http-server/pull/6).



### How to use

```js
'use strict'

// preliminary testing done with uWS 17.5.0, but it is NOT covered with tests yet
const low = require('../index').uwsCompat
/* Based on low library from Rolando Santamaria Maso's (jkyberneees) excellent 0http.
However, many aspects of the library had to be reworked to make it more compatible with native node.js HTTP module. It is likely that the uwsCompat module could be made more efficient.
/* Uses jkybernees's and schamberg97's low-http-server
*/
const app = require('../index')({
prioRequestsProcessing: false, // without this option set to 'false' uWS is going to be extremely sluggish
server: low(),
prioRequestsProcessing: false, // without this option set to 'false' uWS is going to be extremely sluggish. However, this will reduce speed for node's native http
server: low(), // You can pass options to low(), check low-http-server documentation
serverType: 'uWebSockets' // also required, or there will always be errors
})

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var req = require('./lib/request')
var res = require('./lib/response')
var bodyParser = require('body-parser')
var finalhandler = require('finalhandler')
var uwsCompat = require('./lib/additions/uwsCompat')
var uwsCompat = require('low-http-server')

const requestRouter = require('./lib/routing/request-router')

Expand Down
226 changes: 0 additions & 226 deletions lib/additions/uwsCompat.js

This file was deleted.

24 changes: 13 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "fyrejet",
"version": "2.1.1",
"version": "2.2.0",
"description": "Web Framework for node.js that strives to provide (almost) perfect compatibility with Express, while providing better performance, where you need it.",
"main": "index.js",
"scripts": {
"lint": "eslint .",
"test": "mocha --require test/support/env --reporter spec --bail --check-leaks test/ test/acceptance/",
"test-uWS": "UWS_SERVER_ENABLED_FOR_TEST=TRUE mocha --require test/support/env --reporter spec --bail --check-leaks test test/acceptance/",
"test-uWS": "UWS_SERVER_ENABLED_FOR_TEST=TRUE mocha --require test/support/env --reporter spec --bail --check-leaks test test/acceptance/ --exit",
"postinstall": "node ./lib/tasks/postinstall.js"
},
"repository": {
Expand Down Expand Up @@ -38,23 +38,23 @@
"homepage": "https://github.com/fyrejet/fyrejet#readme",
"dependencies": {
"accepts": "~1.3.7",
"array-flatten": "1.1.1",
"body-parser": "1.19.0",
"clone": "^2.1.2",
"content-disposition": "0.5.3",
"content-type": "~1.0.4",
"cookie": "^0.4.1",
"debug": "^4.1.1",
"debug": "^4.2.0",
"depd": "^2.0.0",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"express": "^4.17.1",
"finalhandler": "~1.1.2",
"fresh": "0.5.2",
"low-http-server": "^2.1.1",
"lru-cache": "^6.0.0",
"methods": "~1.1.2",
"on-change": "^2.1.2",
"on-change": "^2.1.4",
"on-finished": "~2.3.0",
"parseurl": "~1.3.3",
"path-to-regexp": "0.1.7",
Expand All @@ -67,8 +67,10 @@
"setprototypeof": "^1.2.0",
"statuses": "~1.5.0",
"type-is": "~1.6.18",
"uuid": "^8.3.0",
"vary": "~1.1.2"
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v18.5.0",
"uuid": "^8.3.1",
"vary": "~1.1.2",
"array-flatten": "^1.1.1"
},
"devDependencies": {
"0http": "^3.0.0",
Expand All @@ -82,16 +84,16 @@
"express-session": "^1.17.1",
"hbs": "^4.1.1",
"istanbul": "0.4.5",
"marked": "0.7.0",
"marked": "^1.2.0",
"method-override": "3.0.0",
"mocha": "^8.1.3",
"mocha": "^8.2.0",
"morgan": "^1.10.0",
"multiparty": "4.2.2",
"pbkdf2-password": "1.2.1",
"restana": "^4.7.4",
"restana": "^4.8.0",
"should": "13.2.3",
"standard": "^14.3.4",
"supertest": "4.0.2",
"supertest": "^5.0.0",
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v18.5.0",
"vhost": "~3.0.2"
},
Expand Down
7 changes: 5 additions & 2 deletions test/acceptance/web-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ describe('web-service', function () {
request(app)
.get('/api/something?api-key=bar')
.expect('Content-Type', /json/)
.expect(404, '{"error":"Lame, can\'t find that"}', app.close)
done()
.expect(404, '{"error":"Lame, can\'t find that"}', () => {

done()
return app.close()
})
})
})
})
2 changes: 1 addition & 1 deletion test/app.listen.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('app.listen()', function () {
it('should wrap with an HTTP server', function (done) {
if (process.env.UWS_SERVER_ENABLED_FOR_TEST === 'TRUE') {
console.log('\x1b[31m%s\x1b[0m', 'Fyrejet (on uWS) doesn\'t conform to Express API here')
done()
return done()
}
var app = express()
app.del('/tobi', function (req, res) {
Expand Down

0 comments on commit fcc5a62

Please sign in to comment.