UNPKG

gpii-universal

Version:

Cross platform, core components of the GPII personalization infrastructure.

44 lines (35 loc) 1.35 kB
/** GPII Preferences Server Test Utility Copyright 2018 OCAD University Licensed under the New BSD license. You may not use this file except in compliance with this License. You may obtain a copy of the License at https://github.com/GPII/universal/blob/master/LICENSE.txt */ "use strict"; var fluid = require("infusion"), gpii = fluid.registerNamespace("gpii"); // Add an endpoint for fetching raw preferences fluid.defaults("gpii.tests.preferencesServer", { gradeNames: ["gpii.preferencesServer"], requestHandlers: { rawPreferencesGet: { route: "/rawPreferences/:gpiiKey", method: "get", type: "gpii.tests.preferencesServer.rawGet.handler" } } }); fluid.defaults("gpii.tests.preferencesServer.rawGet.handler", { gradeNames: ["kettle.request.http"], invokers: { handleRequest: { funcName: "gpii.tests.preferencesServer.rawGet.handler.getRawPreferences", args: ["{preferencesServer}", "{that}", "{that}.req.params.gpiiKey"] } } }); gpii.tests.preferencesServer.rawGet.handler.getRawPreferences = function (preferencesServer, request, gpiiKey) { var prefsPromise = preferencesServer.preferencesService.getPreferencesByGpiiKey(gpiiKey); prefsPromise.then(request.events.onSuccess.fire, request.events.onError.fire); };