Rib-Server
Rib-Server is the simplest way to create and horizontally scale a realtime backend. This should be coupled with rib-client to create a simple real-time application. Rib-Server allows you to call client-side functions directly from the server.
For the official github, please click here.
Example
let RibServer = defaultRibServer let myRib = myRib { console}logMessageargTypes = "string" // validates client passed 1st parameter of type string { return x + y}addargTypes = "number" "number" // validates client passed 1st & 2nd parameter of type number myRib // allows us to call add & logMessage functions from the client
Documentation
startServer: Static Function
const PORT = 5000RibServer
Starts up a server with a specified port and an optional message log.
setRedisUrl: Static Function
RibServer
Link to a redis server. This is for horizontal scaling your application. More can be found on the official redis documentation at https://redis.io/.
setRoute: Static Function
RibServer
Set a route for your application and the file to send with the associated route.
setClientFolder: Static Function
RibServer
Set static folder that can be accessed by a client.
setClientFolders: Static Function
RibServer
Set static folders that can be accessed by a client.
getApp: Static Function
const app = RibServer
Get express app to use for middleware.
Instantiate Rib Server:
let myRib =
Note: The constructor takes two optional parameters. The first is the namespace that the client is trying to connect to(default is "/"). The second is whether or not you want to use the singleton design pattern(default is true).
onConnect: Function
myRib
Call a function after a client connects to the server. The object given is called a Persistent Client Object(PCO for short). This object is given each time a client calls a serverside function, and you can attach any data to this object and it will be persistent each time that client calls a server side function.
onDisconnect: Function
myRib
Call a function when a client disconnects from the server. The callback value is a Persistent Client Object(PCO for short).
exposeFunction: Function
{ return x + y}addargTypes = "number" "number"myRib
Expose a server-side function that can be called from the rib-client instance. If argTypes is an added onto the function, aka functionName.argTypes = [], then this function's arguments will be validated before executing the function. Recognized argtypes are "undefined", "object", "boolean", "number", "string", "symbol", "null", and "any".
exposeFunctions: Function
myRib
Expose an array of server-side functions that can be called with a rib-client instance. If argTypes is added onto a function, functionName.argTypes = [], then that function's arguments will be validated before executing the function. Recognized argtypes are "undefined", "object", "boolean", "number", "string", "symbol", "null", and "any".
concealFunction: Function
myRib
Conceal a server-side function where it can no longer be accessed from all clients.
concealFunctions: Function
myRib
Conceal server-side functions where they can no longer be accessed from the client.
possibleClientFunctions: Function
myRibpossibleClientFunctions = "logMessage"
Gives ability to call your client-side functions with ease of mind by setting an array of possible client-side functions.
call: Function
app
The safest way to call a client function.
runPOF: Function
const res = await app // run function getName on each PCO whose locationId matches specified
Run a persistent object function that matches a query