ultimate-express 1.3.15 → 1.3.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,320 +1,320 @@
1
- # µExpress / Ultimate Express
2
-
3
- The *Ultimate* Express. Fastest http server with **full** Express compatibility, based on µWebSockets.
4
-
5
- This library is a very fast re-implementation of Express.js 4.
6
- It is designed to be a drop-in replacement for Express.js, with the same API and functionality, while being much faster. It is not a fork of Express.js.
7
- To make sure µExpress matches behavior of Express in all cases, we run all tests with Express first, and then with µExpress and compare results to make sure they match.
8
-
9
- `npm install ultimate-express` -> replace `express` with `ultimate-express` -> done[*](https://github.com/dimdenGD/ultimate-express?tab=readme-ov-file#differences-from-express)
10
-
11
- [![Node.js >= 16.0.0](https://img.shields.io/badge/Node.js-%3E=16.0.0-green)](https://nodejs.org)
12
- [![npm](https://img.shields.io/npm/v/ultimate-express?label=last+version)](https://npmjs.com/package/ultimate-express)
13
- [![Patreon](https://img.shields.io/badge/donate-Patreon-orange)](https://patreon.com/dimdendev)
14
-
15
- ## Difference from similar projects
16
-
17
- Similar projects based on uWebSockets:
18
-
19
- - `express` on Bun - since Bun uses uWS for its HTTP module, Express is about 2-3 times faster than on Node.js, but still almost 2 times slower than µExpress because it doesn't do uWS-specific optimizations.
20
- - `hyper-express` - while having a similar API to Express, it's very far from being a drop-in replacement, and implements most of the functionality differently. This creates a lot of random quirks and issues, making the switch quite difficult. Built in middlewares are also very different, middlewares for Express are mostly not supported.
21
- - `uwebsockets-express` - this library is closer to being a drop-in replacement, but misses a lot of APIs, depends on Express by calling it's methods under the hood and doesn't try to optimize routing by using native uWS router.
22
-
23
- ## Performance
24
-
25
- ### Test results
26
-
27
- Tested using [wrk](https://github.com/wg/wrk) (`-d 60 -t 1 -c 200`). Tested on Ubuntu 22.04, Node.js 20.17.0, AMD Ryzen 5 3600, 64GB RAM.
28
-
29
- | Test | Express req/sec | µExpress req/sec | Express throughput | µExpress throughput | µExpress speedup |
30
- | --------------------------------------------- | --------------- | ---------------- | ------------------ | ------------------- | ---------------- |
31
- | routing/simple-routes (/) | 11.16k | 75.14k | 2.08 MB/sec | 14.46 MB/sec | **6.73X** |
32
- | routing/lot-of-routes (/999) | 4.63k | 54.57k | 0.84 MB/sec | 10.03 MB/sec | **11.78X** |
33
- | routing/some-middlewares (/90) | 10.12k | 61.92k | 1.79 MB/sec | 11.32 MB/sec | **6.12X** |
34
- | routers/nested-routers (/abccc/nested/ddd) | 10.18k | 51.15k | 1.82 MB/sec | 9.40 MB/sec | **5.02X** |
35
- | middlewares/express-static (/static/index.js) | 6.58k | 32.45k | 10.15 MB/sec | 49.43 MB/sec | **4.87X** |
36
- | engines/ejs (/test) | 5.50k | 40.82k | 2.45 MB/sec | 18.38 MB/sec | **7.42X** |
37
- | middlewares/body-urlencoded (/abc) | 8.07k | 50.52k | 1.68 MB/sec | 10.78 MB/sec | **6.26X** |
38
-
39
- ### Performance against other frameworks
40
-
41
- Tested using [bun-http-framework-benchmark](https://github.com/dimdenGD/bun-http-framework-benchmark). This table only includes Node.js results.
42
- For full table with other runtimes, check [here](https://github.com/dimdenGD/bun-http-framework-benchmark?tab=readme-ov-file#results).
43
-
44
- | Framework | Average | Ping | Query | Body |
45
- | -------------------- | -------------- | ------------- | ------------- | ------------- |
46
- | uws | 95,531.277 | 109,960.35 | 105,601.47 | 71,032.01 |
47
- | **ultimate-express (declarative)** | **86,794.997** | **108,546.44** | **105,869.75** | **45,968.8** |
48
- | hyper-express | 68,959.92 | 82,547.21 | 71,685.51 | 52,647.04 |
49
- | **ultimate-express** | **60,839.75** | **68,938.53** | **66,173.86** | **47,406.86** |
50
- | h3 | 35,423.263 | 41,243.68 | 34,429.26 | 30,596.85 |
51
- | fastify | 33,094.62 | 40,147.67 | 40,076.35 | 19,059.84 |
52
- | hono | 26,576.02 | 36,215.35 | 34,656.12 | 8,856.59 |
53
- | koa | 24,045.08 | 28,202.12 | 24,590.84 | 19,342.28 |
54
- | express | 10,411.313 | 11,245.57 | 10,598.74 | 9,389.63 |
55
-
56
- ### Performance on real-world application
57
-
58
- Also tested on a [real-world application](https://nekoweb.org) with templates, static files and dynamic pages with data from database, and showed 1.5-4X speedup in requests per second depending on the page.
59
-
60
- ## Differences from Express
61
-
62
- In a lot of cases, you can just replace `require("express")` with `require("ultimate-express")` and everything works the same. But there are some differences:
63
-
64
- - `case sensitive routing` is enabled by default.
65
- - a new option `catch async errors` is added. If it's enabled, you don't need to use `express-async-errors` module.
66
- - request body is only read for POST, PUT and PATCH requests by default. You can add additional methods by setting `body methods` to array with uppercased methods.
67
- - For HTTPS, instead of doing this:
68
- ```js
69
- const https = require("https");
70
- const express = require("express");
71
-
72
- const app = express();
73
-
74
- https.createServer({
75
- key: fs.readFileSync('path/to/key.pem'),
76
- cert: fs.readFileSync('path/to/cert.pem')
77
- }, app).listen(3000, () => {
78
- console.log('Server is running on port 3000');
79
- });
80
- ```
81
-
82
- You have to pass `uwsOptions` to the `express()` constructor:
83
- ```js
84
- const express = require("ultimate-express");
85
-
86
- const app = express({
87
- uwsOptions: {
88
- // https://unetworking.github.io/uWebSockets.js/generated/interfaces/AppOptions.html
89
- key_file_name: 'path/to/key.pem',
90
- cert_file_name: 'path/to/cert.pem'
91
- }
92
- });
93
-
94
- app.listen(3000, () => {
95
- console.log('Server is running on port 3000');
96
- });
97
- ```
98
-
99
- - This also applies to non-SSL HTTP too. Do not create http server manually, use `app.listen()` instead.
100
-
101
- ## Performance tips
102
-
103
- 1. µExpress tries to optimize routing as much as possible, but it's only possible if:
104
- - `case sensitive routing` is enabled (it is by default, unlike in normal Express).
105
- - only string paths without regex characters like *, +, (), {}, etc. can be optimized.
106
- - only 1-level deep routers can be optimized.
107
-
108
- Optimized routes can be up to 10 times faster than normal routes, as they're using native uWS router and have pre-calculated path.
109
-
110
- 2. Do not use external `serve-static` module. Instead use built-in `express.static()` middleware, which is optimized for uExpress.
111
-
112
- 3. Do not use `body-parser` module. Instead use built-in `express.text()`, `express.json()` etc.
113
-
114
- 4. Do not set `body methods` to read body of requests with GET method or other methods that don't need a body. Reading body makes endpoint about 15% slower.
115
-
116
- 5. By default, µExpress creates 1 (or 0 if your CPU has only 1 core) child thread to improve performance of reading files. You can change this number by setting `threads` to a different number in `express()`, or set to 0 to disable thread pool (`express({ threads: 0 })`). Threads are shared between all express() instances, with largest `threads` number being used. Using more threads will not necessarily improve performance. Sometimes not using threads at all is faster, please [test](https://github.com/wg/wrk/) both options.
117
-
118
- ## WebSockets
119
-
120
- Since you don't create http server manually, you can't properly use http.on("upgrade") to handle WebSockets. To solve this, there's currently 2 options:
121
-
122
- - There's a sister library that implements `ws` compatible API: [Ultimate WS](https://github.com/dimdenGD/ultimate-ws). It's same concept as this library, but for WebSockets: fast drop-in replacement for `ws` module with support for Ultimate Express upgrades. There's a guide for how to upgrade http requests in the documentation.
123
- - You can simply use `app.uwsApp` to access uWebSockets.js `App` instance and call its `ws()` method directly.
124
-
125
- ## Compatibility
126
-
127
- In general, basically all features and options are supported. Use [Express 4.x documentation](https://expressjs.com/en/4x/api.html) for API reference.
128
-
129
- ✅ - Full support (all features and options are supported)
130
- 🚧 - Partial support (some options are not supported)
131
- ❌ - Not supported
132
-
133
- ### express
134
-
135
- - ✅ express()
136
- - ✅ express.Router()
137
- - ✅ express.json()
138
- - ✅ express.urlencoded()
139
- - ✅ express.static()
140
- - ✅ express.text()
141
- - ✅ express.raw()
142
- - 🚧 express.request (this is not a constructor but a prototype for replacing methods)
143
- - 🚧 express.response (this is not a constructor but a prototype for replacing methods)
144
-
145
- ### Application
146
-
147
- - ✅ app.listen(port[, host][, callback])
148
- - ✅ app.listen(unix_socket[, callback])
149
- - ✅ app.METHOD() (app.get, app.post, etc.)
150
- - ✅ app.route()
151
- - ✅ app.all()
152
- - ✅ app.use()
153
- - ✅ app.mountpath
154
- - ✅ app.set()
155
- - ✅ app.get()
156
- - ✅ app.enable()
157
- - ✅ app.disable()
158
- - ✅ app.enabled()
159
- - ✅ app.disabled()
160
- - ✅ app.path()
161
- - ✅ app.param(name, callback)
162
- - ✅ app.param(callback)
163
- - ✅ app.engine()
164
- - ✅ app.render()
165
- - ✅ app.locals
166
- - ✅ app.settings
167
- - ✅ app.engines
168
- - ✅ app.on("mount")
169
- - ✅ HEAD method
170
-
171
- ### Application settings
172
-
173
- - ✅ case sensitive routing
174
- - ✅ env
175
- - ✅ etag
176
- - ✅ jsonp callback name
177
- - ✅ json escape
178
- - ✅ json replacer
179
- - ✅ json spaces
180
- - ✅ query parser
181
- - ✅ strict routing
182
- - ✅ subdomain offset
183
- - ✅ trust proxy
184
- - ✅ views
185
- - ✅ view cache
186
- - ✅ view engine
187
- - ✅ x-powered-by
188
-
189
- ### Request
190
- - ✅ implements Readable stream
191
- - ✅ req.app
192
- - ✅ req.baseUrl
193
- - ✅ req.body
194
- - ✅ req.cookies
195
- - ✅ req.fresh
196
- - ✅ req.hostname
197
- - ✅ req.header
198
- - ✅ req.headers
199
- - ✅ req.headersDistinct
200
- - ✅ req.rawHeaders
201
- - ✅ req.ip
202
- - ✅ req.ips
203
- - ✅ req.method
204
- - ✅ req.url
205
- - ✅ req.originalUrl
206
- - ✅ req.params
207
- - ✅ req.path
208
- - ✅ req.protocol
209
- - ✅ req.query
210
- - ✅ req.res
211
- - ✅ req.secure
212
- - ✅ req.signedCookies
213
- - ✅ req.stale
214
- - ✅ req.subdomains
215
- - ✅ req.xhr
216
- - 🚧 req.route (route implementation is different from Express)
217
- - 🚧 req.connection, req.socket (only `end()`, `encrypted`, `remoteAddress`, `localPort` and `remotePort` are supported)
218
- - ✅ req.accepts()
219
- - ✅ req.acceptsCharsets()
220
- - ✅ req.acceptsEncodings()
221
- - ✅ req.acceptsLanguages()
222
- - ✅ req.get()
223
- - ✅ req.is()
224
- - ✅ req.param()
225
- - ✅ req.range()
226
-
227
- ### Response
228
-
229
- - ✅ implements Writable stream
230
- - ✅ res.app
231
- - ✅ res.headersSent
232
- - ✅ res.req
233
- - ✅ res.locals
234
- - ✅ res.append()
235
- - ✅ res.attachment()
236
- - ✅ res.cookie()
237
- - ✅ res.clearCookie()
238
- - ✅ res.download()
239
- - ✅ res.end()
240
- - ✅ res.format()
241
- - ✅ res.getHeader(), res.get()
242
- - ✅ res.json()
243
- - ✅ res.jsonp()
244
- - ✅ res.links()
245
- - ✅ res.location()
246
- - ✅ res.redirect()
247
- - ✅ res.render()
248
- - ✅ res.send()
249
- - ✅ res.sendFile()
250
- - - ✅ options.maxAge
251
- - - ✅ options.root
252
- - - ✅ options.lastModified
253
- - - ✅ options.headers
254
- - - ✅ options.dotfiles
255
- - - ✅ options.acceptRanges
256
- - - ✅ options.cacheControl
257
- - - ✅ options.immutable
258
- - - ✅ Range header
259
- - - ✅ Setting ETag header
260
- - - ✅ If-Match header
261
- - - ✅ If-Modified-Since header
262
- - - ✅ If-Unmodified-Since header
263
- - - ✅ If-Range header
264
- - ✅ res.sendStatus()
265
- - ✅ res.header(), res.setHeader(), res.set()
266
- - ✅ res.status()
267
- - ✅ res.type()
268
- - ✅ res.vary()
269
- - ✅ res.removeHeader()
270
- - ✅ res.write()
271
- - ✅ res.writeHead()
272
-
273
- ### Router
274
-
275
- - ✅ router.all()
276
- - ✅ router.METHOD() (router.get, router.post, etc.)
277
- - ✅ router.route()
278
- - ✅ router.use()
279
- - ✅ router.param(name, callback)
280
- - ✅ router.param(callback)
281
- - ✅ options.caseSensitive
282
- - ✅ options.strict
283
- - ✅ options.mergeParams
284
-
285
- ## Tested middlewares
286
-
287
- Almost all middlewares that are compatible with Express are compatible with µExpress. Here's list of middlewares that we test for compatibility:
288
-
289
- - ✅ [body-parser](https://npmjs.com/package/body-parser) (use `express.text()` etc instead for better performance)
290
- - ✅ [cookie-parser](https://npmjs.com/package/cookie-parser)
291
- - ✅ [cookie-session](https://npmjs.com/package/cookie-session)
292
- - ✅ [compression](https://npmjs.com/package/compression)
293
- - ✅ [serve-static](https://npmjs.com/package/serve-static) (use `express.static()` instead for better performance)
294
- - ✅ [serve-index](https://npmjs.com/package/serve-index)
295
- - ✅ [cors](https://npmjs.com/package/cors)
296
- - ✅ [errorhandler](https://npmjs.com/package/errorhandler)
297
- - ✅ [method-override](https://npmjs.com/package/method-override)
298
- - ✅ [multer](https://npmjs.com/package/multer)
299
- - ✅ [response-time](https://npmjs.com/package/response-time)
300
- - ✅ [express-fileupload](https://npmjs.com/package/express-fileupload)
301
- - ✅ [express-session](https://npmjs.com/package/express-session)
302
- - ✅ [express-rate-limit](https://npmjs.com/package/express-rate-limit)
303
- - ✅ [express-subdomain](https://npmjs.com/package/express-subdomain)
304
- - ✅ [vhost](https://npmjs.com/package/vhost)
305
- - ✅ [tsoa](https://github.com/lukeautry/tsoa)
306
-
307
- Middlewares and modules that are confirmed to not work:
308
-
309
- - ❌ [express-async-errors](https://npmjs.com/package/express-async-errors) - doesn't work, use `app.set('catch async errors', true)` instead.
310
-
311
- ## Tested view engines
312
-
313
- Any Express view engine should work. Here's list of engines we include in our test suite:
314
-
315
- - ✅ [ejs](https://npmjs.com/package/ejs)
316
- - ✅ [pug](https://npmjs.com/package/pug)
317
- - ✅ [express-dot-engine](https://npmjs.com/package/express-dot-engine)
318
- - ✅ [express-art-template](https://npmjs.com/package/express-art-template)
319
- - ✅ [express-handlebars](https://npmjs.com/package/express-handlebars)
320
- - ✅ [swig](https://npmjs.com/package/swig)
1
+ # µExpress / Ultimate Express
2
+
3
+ The *Ultimate* Express. Fastest http server with **full** Express compatibility, based on µWebSockets.
4
+
5
+ This library is a very fast re-implementation of Express.js 4.
6
+ It is designed to be a drop-in replacement for Express.js, with the same API and functionality, while being much faster. It is not a fork of Express.js.
7
+ To make sure µExpress matches behavior of Express in all cases, we run all tests with Express first, and then with µExpress and compare results to make sure they match.
8
+
9
+ `npm install ultimate-express` -> replace `express` with `ultimate-express` -> done[*](https://github.com/dimdenGD/ultimate-express?tab=readme-ov-file#differences-from-express)
10
+
11
+ [![Node.js >= 16.0.0](https://img.shields.io/badge/Node.js-%3E=16.0.0-green)](https://nodejs.org)
12
+ [![npm](https://img.shields.io/npm/v/ultimate-express?label=last+version)](https://npmjs.com/package/ultimate-express)
13
+ [![Patreon](https://img.shields.io/badge/donate-Patreon-orange)](https://patreon.com/dimdendev)
14
+
15
+ ## Difference from similar projects
16
+
17
+ Similar projects based on uWebSockets:
18
+
19
+ - `express` on Bun - since Bun uses uWS for its HTTP module, Express is about 2-3 times faster than on Node.js, but still almost 2 times slower than µExpress because it doesn't do uWS-specific optimizations.
20
+ - `hyper-express` - while having a similar API to Express, it's very far from being a drop-in replacement, and implements most of the functionality differently. This creates a lot of random quirks and issues, making the switch quite difficult. Built in middlewares are also very different, middlewares for Express are mostly not supported.
21
+ - `uwebsockets-express` - this library is closer to being a drop-in replacement, but misses a lot of APIs, depends on Express by calling it's methods under the hood and doesn't try to optimize routing by using native uWS router.
22
+
23
+ ## Performance
24
+
25
+ ### Test results
26
+
27
+ Tested using [wrk](https://github.com/wg/wrk) (`-d 60 -t 1 -c 200`). Tested on Ubuntu 22.04, Node.js 20.17.0, AMD Ryzen 5 3600, 64GB RAM.
28
+
29
+ | Test | Express req/sec | µExpress req/sec | Express throughput | µExpress throughput | µExpress speedup |
30
+ | --------------------------------------------- | --------------- | ---------------- | ------------------ | ------------------- | ---------------- |
31
+ | routing/simple-routes (/) | 11.16k | 75.14k | 2.08 MB/sec | 14.46 MB/sec | **6.73X** |
32
+ | routing/lot-of-routes (/999) | 4.63k | 54.57k | 0.84 MB/sec | 10.03 MB/sec | **11.78X** |
33
+ | routing/some-middlewares (/90) | 10.12k | 61.92k | 1.79 MB/sec | 11.32 MB/sec | **6.12X** |
34
+ | routers/nested-routers (/abccc/nested/ddd) | 10.18k | 51.15k | 1.82 MB/sec | 9.40 MB/sec | **5.02X** |
35
+ | middlewares/express-static (/static/index.js) | 6.58k | 32.45k | 10.15 MB/sec | 49.43 MB/sec | **4.87X** |
36
+ | engines/ejs (/test) | 5.50k | 40.82k | 2.45 MB/sec | 18.38 MB/sec | **7.42X** |
37
+ | middlewares/body-urlencoded (/abc) | 8.07k | 50.52k | 1.68 MB/sec | 10.78 MB/sec | **6.26X** |
38
+
39
+ ### Performance against other frameworks
40
+
41
+ Tested using [bun-http-framework-benchmark](https://github.com/dimdenGD/bun-http-framework-benchmark). This table only includes Node.js results.
42
+ For full table with other runtimes, check [here](https://github.com/dimdenGD/bun-http-framework-benchmark?tab=readme-ov-file#results).
43
+
44
+ | Framework | Average | Ping | Query | Body |
45
+ | -------------------- | -------------- | ------------- | ------------- | ------------- |
46
+ | uws | 95,531.277 | 109,960.35 | 105,601.47 | 71,032.01 |
47
+ | **ultimate-express (declarative)** | **86,794.997** | **108,546.44** | **105,869.75** | **45,968.8** |
48
+ | hyper-express | 68,959.92 | 82,547.21 | 71,685.51 | 52,647.04 |
49
+ | **ultimate-express** | **60,839.75** | **68,938.53** | **66,173.86** | **47,406.86** |
50
+ | h3 | 35,423.263 | 41,243.68 | 34,429.26 | 30,596.85 |
51
+ | fastify | 33,094.62 | 40,147.67 | 40,076.35 | 19,059.84 |
52
+ | hono | 26,576.02 | 36,215.35 | 34,656.12 | 8,856.59 |
53
+ | koa | 24,045.08 | 28,202.12 | 24,590.84 | 19,342.28 |
54
+ | express | 10,411.313 | 11,245.57 | 10,598.74 | 9,389.63 |
55
+
56
+ ### Performance on real-world application
57
+
58
+ Also tested on a [real-world application](https://nekoweb.org) with templates, static files and dynamic pages with data from database, and showed 1.5-4X speedup in requests per second depending on the page.
59
+
60
+ ## Differences from Express
61
+
62
+ In a lot of cases, you can just replace `require("express")` with `require("ultimate-express")` and everything works the same. But there are some differences:
63
+
64
+ - `case sensitive routing` is enabled by default.
65
+ - a new option `catch async errors` is added. If it's enabled, you don't need to use `express-async-errors` module.
66
+ - request body is only read for POST, PUT and PATCH requests by default. You can add additional methods by setting `body methods` to array with uppercased methods.
67
+ - For HTTPS, instead of doing this:
68
+ ```js
69
+ const https = require("https");
70
+ const express = require("express");
71
+
72
+ const app = express();
73
+
74
+ https.createServer({
75
+ key: fs.readFileSync('path/to/key.pem'),
76
+ cert: fs.readFileSync('path/to/cert.pem')
77
+ }, app).listen(3000, () => {
78
+ console.log('Server is running on port 3000');
79
+ });
80
+ ```
81
+
82
+ You have to pass `uwsOptions` to the `express()` constructor:
83
+ ```js
84
+ const express = require("ultimate-express");
85
+
86
+ const app = express({
87
+ uwsOptions: {
88
+ // https://unetworking.github.io/uWebSockets.js/generated/interfaces/AppOptions.html
89
+ key_file_name: 'path/to/key.pem',
90
+ cert_file_name: 'path/to/cert.pem'
91
+ }
92
+ });
93
+
94
+ app.listen(3000, () => {
95
+ console.log('Server is running on port 3000');
96
+ });
97
+ ```
98
+
99
+ - This also applies to non-SSL HTTP too. Do not create http server manually, use `app.listen()` instead.
100
+
101
+ ## Performance tips
102
+
103
+ 1. µExpress tries to optimize routing as much as possible, but it's only possible if:
104
+ - `case sensitive routing` is enabled (it is by default, unlike in normal Express).
105
+ - only string paths without regex characters like *, +, (), {}, etc. can be optimized.
106
+ - only 1-level deep routers can be optimized.
107
+
108
+ Optimized routes can be up to 10 times faster than normal routes, as they're using native uWS router and have pre-calculated path.
109
+
110
+ 2. Do not use external `serve-static` module. Instead use built-in `express.static()` middleware, which is optimized for uExpress.
111
+
112
+ 3. Do not use `body-parser` module. Instead use built-in `express.text()`, `express.json()` etc.
113
+
114
+ 4. Do not set `body methods` to read body of requests with GET method or other methods that don't need a body. Reading body makes endpoint about 15% slower.
115
+
116
+ 5. By default, µExpress creates 1 (or 0 if your CPU has only 1 core) child thread to improve performance of reading files. You can change this number by setting `threads` to a different number in `express()`, or set to 0 to disable thread pool (`express({ threads: 0 })`). Threads are shared between all express() instances, with largest `threads` number being used. Using more threads will not necessarily improve performance. Sometimes not using threads at all is faster, please [test](https://github.com/wg/wrk/) both options.
117
+
118
+ ## WebSockets
119
+
120
+ Since you don't create http server manually, you can't properly use http.on("upgrade") to handle WebSockets. To solve this, there's currently 2 options:
121
+
122
+ - There's a sister library that implements `ws` compatible API: [Ultimate WS](https://github.com/dimdenGD/ultimate-ws). It's same concept as this library, but for WebSockets: fast drop-in replacement for `ws` module with support for Ultimate Express upgrades. There's a guide for how to upgrade http requests in the documentation.
123
+ - You can simply use `app.uwsApp` to access uWebSockets.js `App` instance and call its `ws()` method directly.
124
+
125
+ ## Compatibility
126
+
127
+ In general, basically all features and options are supported. Use [Express 4.x documentation](https://expressjs.com/en/4x/api.html) for API reference.
128
+
129
+ ✅ - Full support (all features and options are supported)
130
+ 🚧 - Partial support (some options are not supported)
131
+ ❌ - Not supported
132
+
133
+ ### express
134
+
135
+ - ✅ express()
136
+ - ✅ express.Router()
137
+ - ✅ express.json()
138
+ - ✅ express.urlencoded()
139
+ - ✅ express.static()
140
+ - ✅ express.text()
141
+ - ✅ express.raw()
142
+ - 🚧 express.request (this is not a constructor but a prototype for replacing methods)
143
+ - 🚧 express.response (this is not a constructor but a prototype for replacing methods)
144
+
145
+ ### Application
146
+
147
+ - ✅ app.listen(port[, host][, callback])
148
+ - ✅ app.listen(unix_socket[, callback])
149
+ - ✅ app.METHOD() (app.get, app.post, etc.)
150
+ - ✅ app.route()
151
+ - ✅ app.all()
152
+ - ✅ app.use()
153
+ - ✅ app.mountpath
154
+ - ✅ app.set()
155
+ - ✅ app.get()
156
+ - ✅ app.enable()
157
+ - ✅ app.disable()
158
+ - ✅ app.enabled()
159
+ - ✅ app.disabled()
160
+ - ✅ app.path()
161
+ - ✅ app.param(name, callback)
162
+ - ✅ app.param(callback)
163
+ - ✅ app.engine()
164
+ - ✅ app.render()
165
+ - ✅ app.locals
166
+ - ✅ app.settings
167
+ - ✅ app.engines
168
+ - ✅ app.on("mount")
169
+ - ✅ HEAD method
170
+
171
+ ### Application settings
172
+
173
+ - ✅ case sensitive routing
174
+ - ✅ env
175
+ - ✅ etag
176
+ - ✅ jsonp callback name
177
+ - ✅ json escape
178
+ - ✅ json replacer
179
+ - ✅ json spaces
180
+ - ✅ query parser
181
+ - ✅ strict routing
182
+ - ✅ subdomain offset
183
+ - ✅ trust proxy
184
+ - ✅ views
185
+ - ✅ view cache
186
+ - ✅ view engine
187
+ - ✅ x-powered-by
188
+
189
+ ### Request
190
+ - ✅ implements Readable stream
191
+ - ✅ req.app
192
+ - ✅ req.baseUrl
193
+ - ✅ req.body
194
+ - ✅ req.cookies
195
+ - ✅ req.fresh
196
+ - ✅ req.hostname
197
+ - ✅ req.header
198
+ - ✅ req.headers
199
+ - ✅ req.headersDistinct
200
+ - ✅ req.rawHeaders
201
+ - ✅ req.ip
202
+ - ✅ req.ips
203
+ - ✅ req.method
204
+ - ✅ req.url
205
+ - ✅ req.originalUrl
206
+ - ✅ req.params
207
+ - ✅ req.path
208
+ - ✅ req.protocol
209
+ - ✅ req.query
210
+ - ✅ req.res
211
+ - ✅ req.secure
212
+ - ✅ req.signedCookies
213
+ - ✅ req.stale
214
+ - ✅ req.subdomains
215
+ - ✅ req.xhr
216
+ - 🚧 req.route (route implementation is different from Express)
217
+ - 🚧 req.connection, req.socket (only `end()`, `encrypted`, `remoteAddress`, `localPort` and `remotePort` are supported)
218
+ - ✅ req.accepts()
219
+ - ✅ req.acceptsCharsets()
220
+ - ✅ req.acceptsEncodings()
221
+ - ✅ req.acceptsLanguages()
222
+ - ✅ req.get()
223
+ - ✅ req.is()
224
+ - ✅ req.param()
225
+ - ✅ req.range()
226
+
227
+ ### Response
228
+
229
+ - ✅ implements Writable stream
230
+ - ✅ res.app
231
+ - ✅ res.headersSent
232
+ - ✅ res.req
233
+ - ✅ res.locals
234
+ - ✅ res.append()
235
+ - ✅ res.attachment()
236
+ - ✅ res.cookie()
237
+ - ✅ res.clearCookie()
238
+ - ✅ res.download()
239
+ - ✅ res.end()
240
+ - ✅ res.format()
241
+ - ✅ res.getHeader(), res.get()
242
+ - ✅ res.json()
243
+ - ✅ res.jsonp()
244
+ - ✅ res.links()
245
+ - ✅ res.location()
246
+ - ✅ res.redirect()
247
+ - ✅ res.render()
248
+ - ✅ res.send()
249
+ - ✅ res.sendFile()
250
+ - - ✅ options.maxAge
251
+ - - ✅ options.root
252
+ - - ✅ options.lastModified
253
+ - - ✅ options.headers
254
+ - - ✅ options.dotfiles
255
+ - - ✅ options.acceptRanges
256
+ - - ✅ options.cacheControl
257
+ - - ✅ options.immutable
258
+ - - ✅ Range header
259
+ - - ✅ Setting ETag header
260
+ - - ✅ If-Match header
261
+ - - ✅ If-Modified-Since header
262
+ - - ✅ If-Unmodified-Since header
263
+ - - ✅ If-Range header
264
+ - ✅ res.sendStatus()
265
+ - ✅ res.header(), res.setHeader(), res.set()
266
+ - ✅ res.status()
267
+ - ✅ res.type()
268
+ - ✅ res.vary()
269
+ - ✅ res.removeHeader()
270
+ - ✅ res.write()
271
+ - ✅ res.writeHead()
272
+
273
+ ### Router
274
+
275
+ - ✅ router.all()
276
+ - ✅ router.METHOD() (router.get, router.post, etc.)
277
+ - ✅ router.route()
278
+ - ✅ router.use()
279
+ - ✅ router.param(name, callback)
280
+ - ✅ router.param(callback)
281
+ - ✅ options.caseSensitive
282
+ - ✅ options.strict
283
+ - ✅ options.mergeParams
284
+
285
+ ## Tested middlewares
286
+
287
+ Almost all middlewares that are compatible with Express are compatible with µExpress. Here's list of middlewares that we test for compatibility:
288
+
289
+ - ✅ [body-parser](https://npmjs.com/package/body-parser) (use `express.text()` etc instead for better performance)
290
+ - ✅ [cookie-parser](https://npmjs.com/package/cookie-parser)
291
+ - ✅ [cookie-session](https://npmjs.com/package/cookie-session)
292
+ - ✅ [compression](https://npmjs.com/package/compression)
293
+ - ✅ [serve-static](https://npmjs.com/package/serve-static) (use `express.static()` instead for better performance)
294
+ - ✅ [serve-index](https://npmjs.com/package/serve-index)
295
+ - ✅ [cors](https://npmjs.com/package/cors)
296
+ - ✅ [errorhandler](https://npmjs.com/package/errorhandler)
297
+ - ✅ [method-override](https://npmjs.com/package/method-override)
298
+ - ✅ [multer](https://npmjs.com/package/multer)
299
+ - ✅ [response-time](https://npmjs.com/package/response-time)
300
+ - ✅ [express-fileupload](https://npmjs.com/package/express-fileupload)
301
+ - ✅ [express-session](https://npmjs.com/package/express-session)
302
+ - ✅ [express-rate-limit](https://npmjs.com/package/express-rate-limit)
303
+ - ✅ [express-subdomain](https://npmjs.com/package/express-subdomain)
304
+ - ✅ [vhost](https://npmjs.com/package/vhost)
305
+ - ✅ [tsoa](https://github.com/lukeautry/tsoa)
306
+
307
+ Middlewares and modules that are confirmed to not work:
308
+
309
+ - ❌ [express-async-errors](https://npmjs.com/package/express-async-errors) - doesn't work, use `app.set('catch async errors', true)` instead.
310
+
311
+ ## Tested view engines
312
+
313
+ Any Express view engine should work. Here's list of engines we include in our test suite:
314
+
315
+ - ✅ [ejs](https://npmjs.com/package/ejs)
316
+ - ✅ [pug](https://npmjs.com/package/pug)
317
+ - ✅ [express-dot-engine](https://npmjs.com/package/express-dot-engine)
318
+ - ✅ [express-art-template](https://npmjs.com/package/express-art-template)
319
+ - ✅ [express-handlebars](https://npmjs.com/package/express-handlebars)
320
+ - ✅ [swig](https://npmjs.com/package/swig)