Service Library - leaderboard
This document provides a complete reference of the custom code library for the leaderboard service. It includes all library functions, edge functions with their REST endpoints, templates, and assets.
Library Functions
Library functions are reusable modules available to all business APIs and other custom code within the service via require("lib/<moduleName>").
failIfNotRegisteredPlayer.js
module.exports = async function failIfNotRegisteredPlayer(userId, context=null) {
// fetch user role via serviceCommon helper
const { fetchRemoteObjectByMQuery } = require("serviceCommon");
const user = await fetchRemoteObjectByMQuery("User", { id: userId });
if (!user) throw new Error("User does not exist.");
if (user.roleId !== "registeredPlayer" && user.roleId !== "administrator") throw new Error("Leaderboard and stats are only for registered users.");
return true;
}
This document was generated from the service library configuration and should be kept in sync with design changes.