UNPKG

@jargon/jovo-plugin

Version:
42 lines 1.83 kB
"use strict"; /* * Copyright 2019 Jargon, Inc. or its affiliates. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * http://www.apache.org/licenses/LICENSE-2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); const sdk_core_1 = require("@jargon/sdk-core"); const jovo_core_1 = require("jovo-core"); const jovojargon_1 = require("../jovojargon"); /** The Jargon plugin for the Jovo framework */ class JargonPlugin extends jovo_core_1.Extensible { /** Constructor for the plugin * @param {any} options Optional options for the plugin. The values in DefaultResourceManagerOptions will be used for anything not provided */ constructor(options = {}) { super(); this._options = Object.assign({}, sdk_core_1.DefaultResourceManagerOptions, options); this._rmf = new sdk_core_1.DefaultResourceManagerFactory(this._options); } /** Called by the Jovo framework after the plugin is installed */ install(app) { app.middleware('after.platform.init').use((handleRequest) => { const jovo = handleRequest.jovo; const locale = jovo.$request.getLocale(); let rm = this._rmf.forLocale(locale); jovo.jargon = new jovojargon_1.JJ(jovo, rm); }); } uninstall(parent) { // Nothing to do here } } exports.JargonPlugin = JargonPlugin; //# sourceMappingURL=index.js.map