From 208de3d7371394e1fa37c4d80a83af6f46f7ca07 Mon Sep 17 00:00:00 2001 From: Timotej Ecimovic Date: Sat, 14 Aug 2021 09:06:55 -0400 Subject: [PATCH] Some minor cleanup. --- docs/design.md | 2 +- src-electron/util/script.js | 45 ------------------------------------- 2 files changed, 1 insertion(+), 46 deletions(-) delete mode 100644 src-electron/util/script.js diff --git a/docs/design.md b/docs/design.md index b292c92e33..f1024fbf6e 100644 --- a/docs/design.md +++ b/docs/design.md @@ -114,7 +114,7 @@ The HTTP methods are strictly observed: ## Generator and backend -The Zap back-end is a node.js application. The general design guidelines for the back-end logic are: +The Zap back-end is a node.js application. It was originally written in plain JavaScript, using common.js module mechanism, but has been then converted to use TypeScript. The conversion is ongoing. The general design guidelines for the back-end logic are: - fully embrace and make use of the asynchronous node.js callback model, thus ensuring least-blocking and maximum-performing infrastructure. Use of JS `promises` is a chosen pattern to follow asynchronicity. - use npm as a package manager. diff --git a/src-electron/util/script.js b/src-electron/util/script.js deleted file mode 100644 index 302b9ec635..0000000000 --- a/src-electron/util/script.js +++ /dev/null @@ -1,45 +0,0 @@ -/** - * - * Copyright (c) 2021 Silicon Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License 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. - */ - -const path = require('path') -const scriptApi = require('./script-api.js') -const nativeRequire = require('../util/native-require') - -/** - * Executes a named function from a given script. - * Arguments passed to the function are: - * api: which is the result of require('script-api.js') - * context: which contains 'db', 'sessionId', etc. - * - * @param {*} functionName - * @param {*} db - * @param {*} sessionId - * @param {*} script - */ -async function executeScriptFunction(functionName, context, script) { - let resolvedPath = path.resolve(script) - let loadedScript = nativeRequire(resolvedPath) - if (loadedScript[functionName]) { - return loadedScript[functionName](scriptApi, context) - } -} - -exports.executeScriptFunction = executeScriptFunction - -exports.functions = { - postLoad: 'postLoad', -}