Skip to main content

EndpointManager

class
EndpointManager
Private Class
Methods / Properties
register=> Function

moopsyServer.
endpoints.
EndpointManager
register
<BP.Plug>
(BP, handler)
Function
<>
Type Arguments
BP.Plug:
Moopsy Blueprint Plug
()
Arguments
BP:
Moopsy Blueprint Constants
handler:
MoopsyEndpointHandler (Function)

MoopsyEndpointHandler
async
(params, auth)
 =>
Async Function
()
Arguments
params:
ParamsType of BP.Plug
auth:
{
public
PublicAuthType of AuthSpec
private
PrivateAuthType from MoopsyServer
}
=>
Returns
Promise<ReturnType of BP.Plug>

EndpointManager is a Private Class used to handle endpoints. You should never create it directly, use it as a property of a MoopsyServer.

Usage

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

server.endpoints.register<FooBP.Plug>(FooBP.Plug, async (params, auth) => {
if(auth.private.userType !== "admin") {
throw new MoopsyError(403, '403', 'Access Denied);
}

// Your method code
});