Skip to main content

MoopsyServer

class
MoopsyServer
<AuthSpec, PrivateAuthType>
(opts, callbacks)
Class
import { MoopsyServer } from "@moopsyjs/react";
<>
Type Arguments
AuthSpec:
Moopsy AuthSpec
PrivateAuthType:
object (any)
()
Arguments
opts:
{
port? (Optional, Default: 3001)
number
Port to run Moopsy server on
requireSchemas? (Optional, Default: true)
boolean
Whether to require manually defined schemas (as opposed to auto generated)
verbose? (Optional, Default: false)
boolean
Enable verbose logging to console
debugLatency? (Optional, Default: false)
boolean
Output method timing data for method calls to console
}
callbacks:
{
handleAuthLogin? (Optional, Default: null)
(AuthRequestType of AuthSpec) =>  (Function)
Function that handles auth login from the client. This should NOT take in credentials, setup a method to handle credential-based login, OAuth, etc, and return some sort of session token, and accept that here
}
Methods / Properties
endpoints=> EndpointManager   🔗
httpServerHTTPServer   🔗
expressAppExpressApp   🔗

The Moopsy Server handles communication between connected clients and your server, by processing authentication requests and handling auth state, calling method handlers in response to client requests, and more.

The Moopsy server handles creating an HTTP Server and Express App behind the scenes, you can access these using the httpServer and expressApp properties.

Usage

const server = new MoopsyServer({}, { handleAuthLogin });

server.endpoints.register<FooBP.Plug>(FooBP.Plug, async (params) => {
// Your method code
});