Optional
customAttach any other properties that you want inside of here.
Optional
protocolsA shape (that is parsed by the
object-shape-tester
package) that all
protocols for this WebSocket are collectively tested against. Omit this or set it to
undefined
to allow a string array of any length.
This shape will be tested against all protocols together in a single array, so this should be
an array shape. Only string-compatible values inside the array will work. It is recommended
to use tupleShape
from the object-shape-tester
package.
Optional
requiredSet a required client origin for this endpoint.
undefined
, this endpoint allows any origins (regardless of the
service's origin requirement).Optional
searchA shape used to verify search params. This should match the entire search params object.
Note the following:
import {exact, enumShape, tupleShape} from 'object-shape-tester';
const partialWebSocketInit = {
searchParamsShape: {
// use `tupleShape` to ensure there's exactly one entry for this search param
userId: tupleShape(enumShape(MyEnum)),
date: tupleShape(exact('2')),
// don't use `tupleShape` here so that there can be any number of entries
colors: [''],
},
};
Initialization for a WebSocket within a service definition..
Package
@rest-vir/define-service