Generated using TypeDoc
Constructs an SSL app. See App.
-Generated using TypeDoc
Takes a POSTed body and contentType, and returns an array of parts if the request is a multipart request
-Generated using TypeDoc
Takes a POSTed body and contentType, and returns an array of parts if the request is a multipart request
+Closes a uSockets listen socket.
-Generated using TypeDoc
Gets local port of socket (or listenSocket) or -1.
-Generated using TypeDoc
Generated using TypeDoc
Options used when constructing an app. Especially for SSLApp. +
Options used when constructing an app. Especially for SSLApp. These are options passed directly to uSockets, C layer.
-Optional ca_Optional cert_Optional dh_Optional key_Optional passphraseOptional ssl_Optional ssl_This translates to SSL_MODE_RELEASE_BUFFERS
-Generated using TypeDoc
An HttpRequest is stack allocated and only accessible during the callback invocation.
-Returns the lowercased header value or empty string.
-Returns the parsed parameter at index. Corresponds to route. Can also take the name of the parameter.
-Setting yield to true is to say that this route handler did not handle the route, causing the router to continue looking for a matching route handler, or fail.
-Generated using TypeDoc
An HttpRequest is stack allocated and only accessible during the callback invocation.
+Loops over all headers.
+Returns the HTTP method as-is.
+Returns the lowercased header value or empty string.
+Returns the lowercased HTTP method, useful for "any" routes.
+Returns the parsed parameter at index. Corresponds to route. Can also take the name of the parameter.
+Returns the raw querystring (the part of URL after ? sign) or empty string.
+Returns a decoded query parameter value or undefined.
+Returns the URL including initial /slash
+Setting yield to true is to say that this route handler did not handle the route, causing the router to continue looking for a matching route handler, or fail.
+An HttpResponse is valid until either onAborted callback or any of the .end/.tryEnd calls succeed. You may attach user data to this object.
-Arbitrary user data may be attached to this object
-Immediately force closes the connection. Any onAborted callback will run.
-Corking a response is a performance improvement in both CPU and network, as you ready the IO system for writing multiple chunks at once. -By default, you're corked in the immediately executing top portion of the route handler. In all other cases, such as when returning from -await, or when being called back from an async database request or anything that isn't directly executing in the route handler, you'll want +
An HttpResponse is valid until either onAborted callback or any of the .end/.tryEnd calls succeed. You may attach user data to this object.
+Arbitrary user data may be attached to this object
+Immediately force closes the connection. Any onAborted callback will run.
+Corking a response is a performance improvement in both CPU and network, as you ready the IO system for writing multiple chunks at once. +By default, you're corked in the immediately executing top portion of the route handler. In all other cases, such as when returning from +await, or when being called back from an async database request or anything that isn't directly executing in the route handler, you'll want to cork before calling writeStatus, writeHeader or just write. Corking takes a callback in which you execute the writeHeader, writeStatus and such calls, in one atomic IO operation. This is important, not only for TCP but definitely for TLS where each write would otherwise result in one TLS block being sent off, each with one send syscall.
Example usage:
res.cork(() => {
res.writeStatus("200 OK").writeHeader("Some", "Value").write("Hello world!");
});
-Ends this response by copying the contents of body.
-Optional body: RecognizedStringOptional closeConnection: booleanEnds this response without a body.
-Optional reportedContentLength: numberOptional closeConnection: booleanEvery HttpResponse MUST have an attached abort handler IF you do not respond + +
Ends this response by copying the contents of body.
+Optionalbody: RecognizedStringOptionalcloseConnection: booleanEnds this response without a body.
+OptionalreportedContentLength: numberOptionalcloseConnection: booleanReturns the remote IP address in binary format (4 or 16 bytes), as reported by the PROXY Protocol v2 compatible proxy.
+Returns the remote IP address as text, as reported by the PROXY Protocol v2 compatible proxy.
+Returns the remote IP address in binary format (4 or 16 bytes).
+Returns the remote IP address as text.
+Returns the global byte write offset for this response. Use with onWritable.
+Every HttpResponse MUST have an attached abort handler IF you do not respond to it immediately inside of the callback. Returning from an Http request handler without attaching (by calling onAborted) an abort handler is ill-use and will terminate. When this event emits, the response has been aborted and may not be used.
-Handler for reading data from POST and such requests. You MUST copy the data of chunk if isLast is not true. We Neuter ArrayBuffers on return, making it zero length.
-Registers a handler for writable events. Continue failed write attempts in here. +
Handler for reading data from POST and such requests. You MUST copy the data of chunk if isLast is not true. We Neuter ArrayBuffers on return, making it zero length.
+Registers a handler for writable events. Continue failed write attempts in here. You MUST return true for success, false for failure. Writing nothing is always success, so by default you must return true.
-Ends this response, or tries to, by streaming appropriately sized chunks of body. Use in conjunction with onWritable. Returns tuple [ok, hasResponded].
-Upgrades a HttpResponse to a WebSocket. See UpgradeAsync, UpgradeSync example files.
-Enters or continues chunked encoding mode. Writes part of the response. End with zero length write. Returns true if no backpressure was added.
-Writes key and value to HTTP response. +
Pause http body streaming (throttle)
+Resume http body streaming (unthrottle)
+Ends this response, or tries to, by streaming appropriately sized chunks of body. Use in conjunction with onWritable. Returns tuple [ok, hasResponded].
+Upgrades a HttpResponse to a WebSocket. See UpgradeAsync, UpgradeSync example files.
+Enters or continues chunked encoding mode. Writes part of the response. End with zero length write. Returns true if no backpressure was added.
+Writes key and value to HTTP response. See writeStatus and corking.
-Generated using TypeDoc
Writes the HTTP status message such as "200 OK". +This has to be called first in any response, otherwise +it will be called automatically with "200 OK".
+If you want to send custom headers in a WebSocket +upgrade response, you have to call writeStatus with +"101 Switching Protocols" before you call writeHeader, +otherwise your first call to writeHeader will call +writeStatus with "200 OK" and the upgrade will fail.
+As you can imagine, we format outgoing responses in a linear +buffer, not in a hash table. You can read about this in +the user manual under "corking".
+Generated using TypeDoc
TemplatedApp is either an SSL or non-SSL app. See App for more info, read user manual.
-Adds a server name.
-Registers an HTTP handler matching specified URL pattern on any HTTP method.
-Closes all sockets including listen sockets. This will forcefully terminate all connections.
-Registers an HTTP CONNECT handler matching specified URL pattern.
-Registers an HTTP DELETE handler matching specified URL pattern.
-Browse to SNI domain. Used together with .get, .post and similar to attach routes under SNI domains.
-Attaches a "filter" function to track socket connections / disconnections
-Registers an HTTP GET handler matching specified URL pattern.
-Registers an HTTP HEAD handler matching specified URL pattern.
-Listens to hostname & port. Callback hands either false or a listen socket.
-Listens to port. Callback hands either false or a listen socket.
-Listens to port and sets Listen Options. Callback hands either false or a listen socket.
-Listens to unix socket. Callback hands either false or a listen socket.
-Registers a synchronous callback on missing server names. See /examples/ServerName.js.
-Returns number of subscribers for this topic.
-Registers an HTTP OPTIONS handler matching specified URL pattern.
-Registers an HTTP PATCH handler matching specified URL pattern.
-Registers an HTTP POST handler matching specified URL pattern.
-Publishes a message under topic, for all WebSockets under this app. See WebSocket.publish.
-Optional isBinary: booleanOptional compress: booleanRegisters an HTTP PUT handler matching specified URL pattern.
-Removes a server name.
-Registers an HTTP TRACE handler matching specified URL pattern.
-Registers a handler matching specified URL pattern where WebSocket upgrade requests are caught.
-Generated using TypeDoc
TemplatedApp is either an SSL or non-SSL app. See App for more info, read user manual.
+Registers an HTTP handler matching specified URL pattern on any HTTP method.
+Closes all sockets including listen sockets. This will forcefully terminate all connections.
+Registers an HTTP CONNECT handler matching specified URL pattern.
+Registers an HTTP DELETE handler matching specified URL pattern.
+Browse to SNI domain. Used together with .get, .post and similar to attach routes under SNI domains.
+Attaches a "filter" function to track socket connections / disconnections
+Registers an HTTP GET handler matching specified URL pattern.
+Registers an HTTP HEAD handler matching specified URL pattern.
+Listens to hostname & port. Callback hands either false or a listen socket.
+Listens to hostname & port and sets Listen Options. Callback hands either false or a listen socket.
+Listens to port. Callback hands either false or a listen socket.
+Listens to port and sets Listen Options. Callback hands either false or a listen socket.
+Listens to unix socket. Callback hands either false or a listen socket.
+Registers a synchronous callback on missing server names. See /examples/ServerName.js.
+Registers an HTTP OPTIONS handler matching specified URL pattern.
+Registers an HTTP PATCH handler matching specified URL pattern.
+Registers an HTTP POST handler matching specified URL pattern.
+Publishes a message under topic, for all WebSockets under this app. See WebSocket.publish.
+OptionalisBinary: booleanOptionalcompress: booleanRegisters an HTTP PUT handler matching specified URL pattern.
+Registers an HTTP TRACE handler matching specified URL pattern.
+Registers a handler matching specified URL pattern where WebSocket upgrade requests are caught.
+A WebSocket connection that is valid from open to close event. +
A WebSocket connection that is valid from open to close event. Read more about this in the user manual.
-Gracefully closes this WebSocket. Immediately calls the close handler. A WebSocket close message is sent with code and shortMessage.
-Optional code: numberOptional shortMessage: RecognizedStringReturns the bytes buffered in backpressure. This is similar to the bufferedAmount property in the browser counterpart. +
Optionalcode: numberOptionalshortMessage: RecognizedStringReturns the remote IP address. Note that the returned IP is binary, not text.
IPv4 is 4 byte long and can be converted to text by printing every byte as a digit between 0 and 255. IPv6 is 16 byte long and can be converted to text in similar ways, but you typically print digits in HEX.
See getRemoteAddressAsText() for a text version.
-Returns whether this websocket is subscribed to topic.
-Sends a ping control message. Returns sendStatus similar to WebSocket.send (regarding backpressure). This helper function correlates to WebSocket::send(message, uWS::OpCode::PING, ...) in C++.
-Optional message: RecognizedStringReturns the remote IP address as text. See RecognizedString.
+Returns a list of topics this websocket is subscribed to.
+Returns the UserData object.
+Returns whether this websocket is subscribed to topic.
+Sends a ping control message. Returns sendStatus similar to WebSocket.send (regarding backpressure). This helper function correlates to WebSocket::send(message, uWS::OpCode::PING, ...) in C++.
+Optionalmessage: RecognizedStringPublish a message under topic. Backpressure is managed according to maxBackpressure, closeOnBackpressureLimit settings. Order is guaranteed since v20.
-Optional isBinary: booleanOptional compress: booleanSends a message. Returns 1 for success, 2 for dropped due to backpressure limit, and 0 for built up backpressure that will drain over time. You can check backpressure before or after sending by calling getBufferedAmount().
+OptionalisBinary: booleanOptionalcompress: booleanSends a message. Returns 1 for success, 2 for dropped due to backpressure limit, and 0 for built up backpressure that will drain over time. You can check backpressure before or after sending by calling getBufferedAmount().
Make sure you properly understand the concept of backpressure. Check the backpressure example file.
-Optional isBinary: booleanOptional compress: booleanSubscribe to a topic.
-Unsubscribe from a topic. Returns true on success, if the WebSocket was subscribed.
-Generated using TypeDoc
OptionalisBinary: booleanOptionalcompress: booleanSends the first fragment of a fragmented message. Use for sending large messages in chunks. +Returns 1 for success, 2 for dropped due to backpressure limit, and 0 for built up backpressure.
+OptionalisBinary: booleanOptionalcompress: booleanSends a middle fragment of a fragmented message. +Returns 1 for success, 2 for dropped due to backpressure limit, and 0 for built up backpressure.
+Optionalcompress: booleanSends the last fragment of a fragmented message. +Returns 1 for success, 2 for dropped due to backpressure limit, and 0 for built up backpressure.
+Optionalcompress: booleanUnsubscribe from a topic. Returns true on success, if the WebSocket was subscribed.
+A structure holding settings and handlers for a WebSocket URL route handler.
-Optional closeHandler for close event, no matter if error, timeout or graceful close. You may not use WebSocket after this event. Do not send on this WebSocket from within here, it is closed.
-Optional closeWhether or not we should automatically close the socket when a message is dropped due to backpressure. Defaults to false.
-Optional compressionWhat permessage-deflate compression to use. uWS.DISABLED, uWS.SHARED_COMPRESSOR or any of the uWS.DEDICATED_COMPRESSOR_xxxKB. Defaults to uWS.DISABLED.
-Optional drainHandler for when WebSocket backpressure drains. Check ws.getBufferedAmount(). Use this to guide / drive your backpressure throttling.
-Optional droppedHandler for a dropped WebSocket message. Messages can be dropped due to specified backpressure settings. Messages are given as ArrayBuffer no matter if they are binary or not. Given ArrayBuffer is valid during the lifetime of this callback (until first await or return) and will be neutered.
-Handler for a dropped WebSocket message. Messages can be dropped due to specified backpressure settings. Messages are given as ArrayBuffer no matter if they are binary or not. Given ArrayBuffer is valid during the lifetime of this callback (until first await or return) and will be neutered.
-Optional idleMaximum amount of seconds that may pass without sending or getting a message. Connection is closed if this timeout passes. Resolution (granularity) for timeouts are typically 4 seconds, rounded to closest. +
A structure holding settings and handlers for a WebSocket URL route handler.
+OptionalcloseHandler for close event, no matter if error, timeout or graceful close. You may not use WebSocket after this event. Do not send on this WebSocket from within here, it is closed.
+OptionalcloseWhether or not we should automatically close the socket when a message is dropped due to backpressure. Defaults to false.
+OptionalcompressionWhat permessage-deflate compression to use. uWS.DISABLED, uWS.SHARED_COMPRESSOR or any of the uWS.DEDICATED_COMPRESSOR_xxxKB. Defaults to uWS.DISABLED.
+OptionaldrainHandler for when WebSocket backpressure drains. Check ws.getBufferedAmount(). Use this to guide / drive your backpressure throttling.
+OptionaldroppedHandler for a dropped WebSocket message. Messages can be dropped due to specified backpressure settings. Messages are given as ArrayBuffer no matter if they are binary or not. Given ArrayBuffer is valid during the lifetime of this callback (until first await or return) and will be neutered.
+OptionalidleMaximum amount of seconds that may pass without sending or getting a message. Connection is closed if this timeout passes. Resolution (granularity) for timeouts are typically 4 seconds, rounded to closest. Disable by using 0. Defaults to 120.
-Optional maxMaximum length of allowed backpressure per socket when publishing or sending messages. Slow receivers with too high backpressure will be skipped until they catch up or timeout. Defaults to 64 * 1024.
-Optional maxMaximum number of minutes a WebSocket may be connected before being closed by the server. 0 disables the feature.
-Optional maxMaximum length of received message. If a client tries to send you a message larger than this, the connection is immediately closed. Defaults to 16 * 1024.
-Optional messageHandler for a WebSocket message. Messages are given as ArrayBuffer no matter if they are binary or not. Given ArrayBuffer is valid during the lifetime of this callback (until first await or return) and will be neutered.
-Handler for a WebSocket message. Messages are given as ArrayBuffer no matter if they are binary or not. Given ArrayBuffer is valid during the lifetime of this callback (until first await or return) and will be neutered.
-Optional openHandler for new WebSocket connection. WebSocket is valid from open to close, no errors.
-Optional pingHandler for received ping control message. You do not need to handle this, pong messages are automatically sent as per the standard.
-Optional pongHandler for received pong control message.
-Optional sendWhether or not we should automatically send pings to uphold a stable connection given whatever idleTimeout.
-Optional subscriptionHandler for subscription changes.
-Optional upgradeUpgrade handler used to intercept HTTP upgrade requests and potentially upgrade to WebSocket. +
OptionalmaxMaximum length of allowed backpressure per socket when publishing or sending messages. Slow receivers with too high backpressure will be skipped until they catch up or timeout. Defaults to 64 * 1024.
+OptionalmaxMaximum number of minutes a WebSocket may be connected before being closed by the server. 0 disables the feature.
+OptionalmaxMaximum length of received message. If a client tries to send you a message larger than this, the connection is immediately closed. Defaults to 16 * 1024.
+OptionalmessageHandler for a WebSocket message. Messages are given as ArrayBuffer no matter if they are binary or not. Given ArrayBuffer is valid during the lifetime of this callback (until first await or return) and will be neutered.
+OptionalopenHandler for new WebSocket connection. WebSocket is valid from open to close, no errors.
+OptionalpingHandler for received ping control message. You do not need to handle this, pong messages are automatically sent as per the standard.
+OptionalpongHandler for received pong control message.
+OptionalsendWhether or not we should automatically send pings to uphold a stable connection given whatever idleTimeout.
+OptionalsubscriptionHandler for subscription changes.
+OptionalupgradeUpgrade handler used to intercept HTTP upgrade requests and potentially upgrade to WebSocket. See UpgradeAsync and UpgradeSync example files.
-Upgrade handler used to intercept HTTP upgrade requests and potentially upgrade to WebSocket. -See UpgradeAsync and UpgradeSync example files.
-Generated using TypeDoc
Native type representing a raw uSockets struct us_listen_socket_t. +
Native type representing a raw uSockets struct us_listen_socket_t. Careful with this one, it is entirely unchecked and native so invalid usage will blow up.
-Generated using TypeDoc
Native type representing a raw uSockets struct us_socket_t. +
Native type representing a raw uSockets struct us_socket_t. Careful with this one, it is entirely unchecked and native so invalid usage will blow up.
-Generated using TypeDoc
Native type representing a raw uSockets struct us_socket_context_t. +
Native type representing a raw uSockets struct us_socket_context_t. Used while upgrading a WebSocket manually.
-Generated using TypeDoc
WebSocket compression options. Combine any compressor with any decompressor using bitwise OR.
-Generated using TypeDoc
WebSocket compression options. Combine any compressor with any decompressor using bitwise OR.
+Recognized string types, things C++ can read and understand as strings. +
Recognized string types, things C++ can read and understand as strings. "String" does not have to mean "text", it can also be "binary".
Ironically, JavaScript strings are the least performant of all options, to pass or receive to/from C++. This because we expect UTF-8, which is packed in 8-byte chars. JavaScript strings are UTF-16 internally meaning extra copies and reinterpretation are required.
-That's why all events pass data by ArrayBuffer and not JavaScript strings, as they allow zero-copy data passing.
+That's why all events pass data by ArrayBuffer and not JavaScript strings, as they allow zero-copy data passing.
You can always do Buffer.from(arrayBuffer).toString(), but keeping things binary and as ArrayBuffer is preferred.
-Generated using TypeDoc
Sliding dedicated compress window, requires 128KB of memory per socket
-Generated using TypeDoc
Sliding dedicated compress window, requires 128KB of memory per socket
+Sliding dedicated compress window, requires 16KB of memory per socket
-Generated using TypeDoc
Sliding dedicated compress window, requires 16KB of memory per socket
+Sliding dedicated compress window, requires 256KB of memory per socket
-Generated using TypeDoc
Sliding dedicated compress window, requires 256KB of memory per socket
+Sliding dedicated compress window, requires 32KB of memory per socket
-Generated using TypeDoc
Sliding dedicated compress window, requires 32KB of memory per socket
+Sliding dedicated compress window, requires 3KB of memory per socket
-Generated using TypeDoc
Sliding dedicated compress window, requires 3KB of memory per socket
+Sliding dedicated compress window, requires 4KB of memory per socket
-Generated using TypeDoc
Sliding dedicated compress window, requires 4KB of memory per socket
+Sliding dedicated compress window, requires 64KB of memory per socket
-Generated using TypeDoc
Sliding dedicated compress window, requires 64KB of memory per socket
+Sliding dedicated compress window, requires 8KB of memory per socket
-Generated using TypeDoc
Sliding dedicated compress window, requires 8KB of memory per socket
+Sliding dedicated decompress window, requires 32KB of memory per socket (plus about 23KB)
-Generated using TypeDoc
Sliding dedicated decompress window, requires 32KB of memory per socket (plus about 23KB)
+Sliding dedicated decompress window, requires 16KB of memory per socket (plus about 23KB)
-Generated using TypeDoc
Sliding dedicated decompress window, requires 16KB of memory per socket (plus about 23KB)
+Sliding dedicated decompress window, requires 1KB of memory per socket (plus about 23KB)
-Generated using TypeDoc
Sliding dedicated decompress window, requires 1KB of memory per socket (plus about 23KB)
+Sliding dedicated decompress window, requires 2KB of memory per socket (plus about 23KB)
-Generated using TypeDoc
Sliding dedicated decompress window, requires 2KB of memory per socket (plus about 23KB)
+Sliding dedicated decompress window, requires 32KB of memory per socket (plus about 23KB)
-Generated using TypeDoc
Sliding dedicated decompress window, requires 32KB of memory per socket (plus about 23KB)
+Sliding dedicated decompress window, requires 4KB of memory per socket (plus about 23KB)
-Generated using TypeDoc
Sliding dedicated decompress window, requires 4KB of memory per socket (plus about 23KB)
+Sliding dedicated decompress window, requires 512B of memory per socket (plus about 23KB)
-Generated using TypeDoc
Sliding dedicated decompress window, requires 512B of memory per socket (plus about 23KB)
+Sliding dedicated decompress window, requires 8KB of memory per socket (plus about 23KB)
-Generated using TypeDoc
Sliding dedicated decompress window, requires 8KB of memory per socket (plus about 23KB)
+No compression (always a good idea if you operate using an efficient binary protocol)
-Generated using TypeDoc
No compression (always a good idea if you operate using an efficient binary protocol)
+Generated using TypeDoc
Zero memory overhead decompression.
-Generated using TypeDoc
Zero memory overhead decompression.
+
Constructs a non-SSL app. An app is your starting point where you attach behavior to URL routes. +
Function App
Constructs a non-SSL app. An app is your starting point where you attach behavior to URL routes. This is also where you listen and run your app, set any SSL options (in case of SSLApp) and the like.
-Parameters
Optionaloptions: AppOptionsReturns TemplatedApp
Settings
Member Visibility
Theme
Generated using TypeDoc
Parameters
Optionaloptions: AppOptionsReturns TemplatedApp