@webfaas/webfaas-plugin-packagestore-cache-disk
v0.3.0
Published
WebFaaS Framework - Plugin - Package Store Cache - Disk
Downloads
5
Readme
WebFaas - Plugin - PackageRegistry - Cache - Disk
WebFaaS Plugin for node.
Config - Simple
{
"registry.cache.disk": [
{
"enabled": true
}
]
}
Config - Complete
{
"registry.cache.disk": [
{
"enabled": true,
"base": "[folder cache]"
}
]
}
Example
"use strict";
import * as os from "os";
import * as fs from "fs";
import * as path from "path";
import { ModuleManager, Core } from "@webfaas/webfaas-core";
import { PackageStoreCache } from "../lib/PackageStoreCache";
import { PackageRegistryMock } from "../test/mocks/PackageRegistryMock";
var folderCache: string = path.join(os.tmpdir(), "webfaastest_example");
try {
fs.mkdirSync(folderCache);
} catch (error) {
}
const packageRegistry1 = new PackageRegistryMock.PackageRegistry1();
const core = new Core();
const packageStoreCache = new PackageStoreCache();
packageStoreCache.getConfig().base = folderCache;
core.getPackageStoreManager().setCache(packageStoreCache);
core.getPackageRegistryManager().addRegistry("registry1", "", packageRegistry1);
core.import("@registry1/mathsum", "0", undefined, "registry1").then((moduleObj: any)=>{
if (moduleObj){
console.log("module loaded", moduleObj);
console.log("2 = 3 => ", moduleObj(2,3));
}
else{
console.log("module not loaded");
}
});