Skip to content

Commit 50641ab

Browse files
committed
Restructure project
1 parent 79eab43 commit 50641ab

7 files changed

Lines changed: 60 additions & 37 deletions

File tree

‎README.md‎

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,40 @@
1-
**µWebSockets.js** is a JavaScript platform, runtime and web server built on [µWebSockets](https://github.com/uNetworking/uWebSockets) v0.15 and V8.
1+
<div align="center">
2+
<img src="misc/logo.svg" height="180" />
23

3-
There are two modes; compiled as a stand-alone JavaScript runtime or as a Node.js native addon.
4+
*µWebSockets™ (it's "[micro](https://en.wikipedia.org/wiki/Micro-)") is simple, secure & standards compliant web I/O for the most demanding*<sup>[[1]](benchmarks)</sup> *of applications.*
45

5-
For the most common Node.js systems are available precompiled binaries:
6+
• [Read more](misc/READMORE.md)
7+
8+
</div>
9+
10+
11+
### NPM install
12+
While not physically hosted by NPM, it's still possible to install using NPM tools like so (or any such version):
613

714
```
815
npm install uNetworking/uWebSockets.js#semver:0.0.1
916
```
1017

11-
or any such version.
18+
### Presenting; faster I/O for Node.js
19+
Every other week a new "web framework" pops up for Node.js. Fastify, Restana, Aero, Micro and so on. Most aim to improve I/O performance, but fall flat. You can't fix an inherent design flaw of an entire stack just by slapping a few lines of JavaScript on top.
1220

13-
```javascript
14-
/* The stand-alone runtime has uWS namespace already loaded. */
15-
var uWS = uWS ? uWS : require('../dist/uws.js');
21+
µWS.js is a 100% C/C++ web platform completely bypassing the entire Node.js I/O stack. JavaScript-exposed functions and objects are entirely backed by native code all the way down to the OS kernel. This makes it possible to reach unprecedented I/O performance from within Node.js (or any stand-alone V8 build). Scroll down for benchmarks.
1622

17-
const world = 'Strings are slower than ArrayBuffer but who cares for demo purose!';
23+
##### In a nutshell
24+
```javascript
25+
const uWS = require('uWebSockets.js');
1826
const port = 3000;
1927

20-
uWS.App().get('/hello', (res, req) => {
21-
res.end(world);
28+
uWS.SSLApp({
29+
/* cert, key and such specified here, or use uWS.App */
30+
}).get('/whatsmyuseragent', (res, req) => {
31+
res.writeHeader(
32+
'content-type', 'text/html; charset= utf-8'
33+
).end(
34+
'Your user agent is: ' + req.getHeader('user-agent')
35+
);
2236
}).get('/*', (res, req) => {
23-
res.writeHeader('content-type', 'text/html; charset= utf-8').end(req.getHeader('user-agent') + ' är din user agent, biatch!');
37+
res.end('Wildcard route');
2438
}).listen(port, (token) => {
2539
if (token) {
2640
console.log('Listening to port ' + port);
@@ -30,9 +44,17 @@ uWS.App().get('/hello', (res, req) => {
3044
});
3145
```
3246

47+
### Streams
48+
Proper streaming of huge data is supported over Http/Https and demonstrated with examples. Here's a shot of me watching real-time streamed HD video from Node.js while simultaneously scoring a 115k req/sec with wrk. For my computer, that's about 5x that of vanilla Node.js (without any HD video streaming/playing).
49+
50+
![](misc/streaming.png)
51+
3352
### Benchmarks
34-
Performance retention is up to 75% of native C++ [µWebSockets](https://github.com/uNetworking/uWebSockets) v0.15. That puts it some 20x as fast as Deno and even faster than most C++-only servers, all from within a JavaScript VM.
35-
![](https://github.com/uNetworking/uWebSockets/blob/master/misc/bigshot_lineup.png)
53+
Performance retention is about 65% that of the native C++ [µWebSockets](https://github.com/uNetworking/uWebSockets) v0.15. That makes it some 20x as fast as Deno and even faster than most C++-only servers, all from within a JavaScript VM.
54+
55+
Http | WebSockets
56+
--- | ---
57+
![](https://github.com/uNetworking/uWebSockets/blob/master/misc/bigshot_lineup.png) | ![](https://github.com/uNetworking/uWebSockets/blob/master/misc/websocket_lineup.png)
3658

3759
### Build from source
3860
Easiest is to compile yourself a Node.js native addon. The following works for Linux and macOS systems:

‎addon.pro‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎benchmarks.png‎

-17 KB
Binary file not shown.

‎misc/addon.pro‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
TEMPLATE = app
2+
CONFIG += console c++1z
3+
CONFIG -= app_bundle
4+
CONFIG -= qt
5+
6+
SOURCES += \
7+
../src/addon.cpp \
8+
../uWebSockets/uSockets/src/eventing/epoll.c \
9+
../uWebSockets/uSockets/src/context.c \
10+
../uWebSockets/uSockets/src/socket.c \
11+
../uWebSockets/uSockets/src/eventing/libuv.c \
12+
../uWebSockets/uSockets/src/ssl.c \
13+
../uWebSockets/uSockets/src/loop.c
14+
15+
INCLUDEPATH += ../targets/node-v11.1.0/include/node
16+
INCLUDEPATH += ../uWebSockets/src
17+
INCLUDEPATH += ../uWebSockets/uSockets/src
18+
19+
HEADERS += \
20+
../src/AppWrapper.h \
21+
../src/HttpRequestWrapper.h \
22+
../src/HttpResponseWrapper.h \
23+
../src/Utilities.h \
24+
../src/WebSocketWrapper.h
File renamed without changes.

‎misc/logo.svg‎

Lines changed: 1 addition & 0 deletions
Loading

‎misc/streaming.png‎

606 KB
Loading

0 commit comments

Comments
 (0)