1.2.1
Protected abortReadonly clientClient Infos
Readonly internal: booleanWhether the Client IP Address is from an internal fetch
9.3.0
Readonly ip: IPAddress<4 | 6>The IP Address that the Client is using
When a valid Proxy Request is made (and proxy is enabled) this will be the proper IP
3.0.0
Readonly origin: stringThe Origin of the Clients Request
9.5.0
localhost:8000
Readonly port: numberThe Port that the Client is using
3.0.0
Readonly proxied: booleanWhether the Client IP Address is proxied
9.3.0
Readonly referrer: stringThe Referrer of the Clients Request
9.5.0
https://localhost:8000/me
Readonly userThe User Agent of the Client
3.0.0
The Request Context Object used by the server
9.0.0
The Global Context Object used by the server
9.0.0
Readonly headersA Collection of all Headers
if (ctr.headers.has('authorization')) console.log('Authorization Header is present')
console.log(ctr.headers.get('authorization')) // Will print undefined if not present
console.log(ctr.headers.get('authorization', 'hello')) // Will print 'hello' if not present
2.0.0
Readonly paramsA Collection of all Path Parameters
console.log(ctr.params.get('server')) // Will print undefined if not present
2.0.0
Protected rawThe Server Object that initialized this Request
9.8.0
Readonly typeThe Type of this Websocket Event
5.7.0
Readonly urlThe Requested URL
0.0.2
A Collection of all Client Cookies
import { Cookie } from "rjweb-server"
if (ctr.cookies.has('theme')) console.log('Theme Cookie is present')
console.log(ctr.cookies.get('theme')) // Will print undefined if not present
console.log(ctr.cookies.get('theme', 'light')) // Will print 'light' if not present
ctr.cookies.set('session', new Cookie(Math.random(), {
path: '/'
}))
2.0.0
A Collection of all URL Fragments
if (ctr.fragments.has('user')) console.log('User Fragment is present')
console.log(ctr.fragments.get('user')) // Will print undefined if not present
console.log(ctr.fragments.get('user', 'default')) // Will print 'default' if not present
7.0.0
A Collection of all URL Queries
if (ctr.queries.has('user')) console.log('User Query is present')
console.log(ctr.queries.get('user')) // Will print undefined if not present
console.log(ctr.queries.get('user', 'default')) // Will print 'default' if not present
2.0.0
Grab a Channel from either a string identifier or a Channel object
const channel = ctr.$channel('channel')
await channel.send('text', 'Ok')
// or
const ref = new Channel<string>()
const channel = ctr.$channel(ref)
await channel.send('text', 'Ok')
9.8.0
The Request Message as a Blob-like Object
const size = await ctr.$message().size()
return ctr.print(`The size of the message is ${size} bytes`)
9.7.0
Close the Socket and send a Code + Message to the Client (automatically Formatted)
This will instantly close the socket connection with a status code and
message of choice, after calling and successfully closing the .onClose()
callback will be called to finish the task.
Optional code: numberOptional reason: stringctr.close(1011, 'An Error has occured')
5.4.0
Get Infos about the current Ratelimit
This will get all information about the currently applied ratelimit
to the socket. If none is active, will return null.
The Websocket Message (JSON Automatically parsed if enabled)
5.4.0
Print a Message to the Client (automatically Formatted)
This Message will instantly sent to the client, since this is a websocket, this also means that the message cannot be overriden after this function is called.
await ctr.print({
message: 'this is json!'
})
// content will be `{"message":"this is json!"}`
/// or
await ctr.print({
message: 'this is json!'
}, true)
// content will be `{\n "message": "this is json!"\n}`
/// or
await ctr.print('this is text!')
// content will be `this is text!`
5.4.0
Print a Raw Message to the Client (ArrayBuffer only)
Same as .print() but only accepts ArrayBuffer as the content and therefore
skips the parsing process. This is useful for sending data synchronously.
const buffer = new ArrayBuffer(10)
ctr.printRaw('binary', buffer)
9.8.0
Print a raw channels value to the client
This will print when the provided channel has a new value, basically subscribing to the channel. This uses strings to identify the channel instead of the channel object. (CAUTION)
ctr.printRawChannel('channel')
await ctr.$channel('channel').print('text', 'Ok')
9.8.0
Remove a channel from the client
This will remove the subscription to the channel from the client. No more messages will be sent.
const channel = new Channel<string>()
ctr.printChannel(channel)
ref.send('Ok')
ctr.removeChannel(channel)
ref.send('No') // will not be sent
9.0.0
Remove a raw channel from the client
This will remove the subscription to the channel from the client. No more messages will be sent. This uses strings to identify the channel instead of the channel object. (CAUTION)
ctr.printRawChannel('channel')
await ctr.$channel('channel').print('text', 'Ok')
ctr.removeRawChannel('channel')
await ctr.$channel('channel').print('text', 'No') // will not be sent
9.8.0
Skips counting the request to the Client IPs Rate limit (if there is one)
When a specific IP makes sends a message to an endpoint under a ratelimit, the maxhits will be increased instantly to prevent bypassing the rate limit by spamming messages faster than the host can handle. When this function is called, the server removes the set hit again.
8.6.0
Context Variables that are available anywhere in the requests lifespan