memory-card
Version:
ES6 Map like Async API, with Swagger API Backend Support.
24 lines • 932 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStorage = void 0;
const config_js_1 = require("../config.js");
const backend_config_js_1 = require("./backend-config.js");
async function getStorage(name, options = {
type: 'file',
}) {
config_js_1.log.verbose('getStorage', 'name: %s, options: %s', name, JSON.stringify(options));
if (!name) {
if (options.type !== 'nop') {
throw new Error('storage have to be `nop` with a un-named storage');
}
name = 'nop';
}
if (!options.type || !(options.type in backend_config_js_1.BACKEND_FACTORY_DICT)) {
throw new Error('backend unknown: ' + options.type);
}
const Backend = await backend_config_js_1.BACKEND_FACTORY_DICT[options.type]();
const backend = new Backend(name, options);
return backend;
}
exports.getStorage = getStorage;
//# sourceMappingURL=get-storage.js.map