--- /dev/null
+/*
+ * Copyright (C) 2018 Nick Downing <nick@ndcode.org>
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+let BuildCache = require('@ndcode/build_cache')
+let emailjs = require('emailjs')
+let fs = require('fs')
+let util = require('util')
+
+let fs_readFile = util.promisify(fs.readFile)
+
+let EmailJSCache = function(diag) {
+ if (!this instanceof EmailJSCache)
+ throw Error('EmailJSCache is a constructor')
+ this.diag = diag || false
+
+ this.build_cache = new BuildCache()
+}
+
+EmailJSCache.prototype.get = function(key) {
+ return /*await*/ this.build_cache.get(
+ key,
+ async result => {
+ let text = await fs_readFile(key, {encoding: 'utf-8'})
+ result.value = emailjs.server.connect(JSON.parse(text))
+ if (this.diag)
+ console.log(`opened emailjs client ${key}`)
+ }
+ )
+}
+
+module.exports = EmailJSCache
--- /dev/null
+Copyright (C) 2018 Nick Downing <nick@ndcode.org>
+SPDX-License-Identifier: MIT
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.
--- /dev/null
+{
+ "name": "@ndcode/emailjs_cache",
+ "version": "0.1.0",
+ "description": "Configure emailjs via a JSON file which can be changed while system is live.",
+ "keywords": [
+ "configure",
+ "emailjs",
+ "JSON",
+ "persistent",
+ "cache",
+ "live"
+ ],
+ "homepage": "https://www.ndcode.org",
+ "repository": {
+ "type": "git",
+ "url": "https://git.ndcode.org/public/emailjs_cache.git"
+ },
+ "bugs": {
+ "email": "nick@ndcode.org"
+ },
+ "main": "EmailJSCache.js",
+ "engines": {
+ "node": ">=0.4.0"
+ },
+ "directories": {},
+ "dependencies": {
+ "@ndcode/build_cache": "^0.1.0",
+ "emailjs": "^2.2.0"
+ },
+ "devDependencies": {},
+ "maintainers": "Nick Downing <nick@ndcode.org>",
+ "license": "MIT"
+}