Pre plug format change

This commit is contained in:
Zef Hemel
2022-03-27 09:55:29 +02:00
parent 08e6c3bad8
commit a382ab3baa
13 changed files with 222 additions and 110 deletions
+14 -14
View File
@@ -119,21 +119,21 @@ export class SocketServer {
}
onCall(
"invokeFunction",
(plugName: string, name: string, ...args: any[]): Promise<any> => {
let plug = this.system.loadedPlugs.get(plugName);
if (!plug) {
throw new Error(`Plug ${plugName} not loaded`);
}
console.log(
"Invoking function",
name,
"for plug",
plugName,
"as requested over socket"
);
return plug.invoke(name, args);
"invokeFunction",
(plugName: string, name: string, ...args: any[]): Promise<any> => {
let plug = this.system.loadedPlugs.get(plugName);
if (!plug) {
throw new Error(`Plug ${plugName} not loaded`);
}
console.log(
"Invoking function",
name,
"for plug",
plugName,
"as requested over socket"
);
return plug.invoke(name, args);
}
);
console.log("Sending the sytem to the client");
+1 -1
View File
@@ -19,7 +19,7 @@ export class ExpressServer {
this.rootPath = rootPath;
this.system = system;
system.addFeature(new EndpointFeature(app));
system.addFeature(new EndpointFeature(app, "/_"));
// Fallback, serve index.html
let cachedIndex: string | undefined = undefined;
Regular → Executable
+30 -26
View File
@@ -1,26 +1,30 @@
#!/usr/bin/env node
import express from "express";
import http from "http";
import { Server } from "socket.io";
import { SocketServer } from "./api_server";
import {Server} from "socket.io";
import {SocketServer} from "./api_server";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { SilverBulletHooks } from "../common/manifest";
import { ExpressServer } from "./express_server";
import { DiskPlugLoader } from "../plugbox/plug_loader";
import {hideBin} from "yargs/helpers";
import {SilverBulletHooks} from "../common/manifest";
import {ExpressServer} from "./express_server";
import {DiskPlugLoader} from "../plugbox/plug_loader";
import { NodeCronFeature } from "../plugbox/feature/node_cron";
import shellSyscalls from "../plugbox/syscall/shell.node";
import { System } from "../plugbox/system";
let args = yargs(hideBin(process.argv))
.option("debug", {
type: "boolean",
})
.option("port", {
type: "number",
default: 3000,
})
.parse();
if (!args._.length) {
console.error("Usage: silverbullet <path-to-pages>");
process.exit(1);
}
const pagesPath = args._[0] as string;
const app = express();
@@ -41,25 +45,25 @@ app.use("/", express.static(distDir));
let socketServer = new SocketServer(pagesPath, io, system);
socketServer.init().catch((e) => {
console.error(e);
console.error(e);
});
const expressServer = new ExpressServer(app, pagesPath, distDir, system);
expressServer
.init()
.then(async () => {
let plugLoader = new DiskPlugLoader(
system,
`${__dirname}/../../plugs/dist`
);
await plugLoader.loadPlugs();
plugLoader.watcher();
system.registerSyscalls("shell", ["shell"], shellSyscalls(pagesPath));
system.addFeature(new NodeCronFeature());
server.listen(port, () => {
console.log(`Server listening on port ${port}`);
.init()
.then(async () => {
let plugLoader = new DiskPlugLoader(
system,
`${__dirname}/../../plugs/dist`
);
await plugLoader.loadPlugs();
plugLoader.watcher();
system.registerSyscalls("shell", ["shell"], shellSyscalls(pagesPath));
system.addFeature(new NodeCronFeature());
server.listen(port, () => {
console.log(`Server listening on port ${port}`);
});
})
.catch((e) => {
console.error(e);
});
})
.catch((e) => {
console.error(e);
});