Fix some nasty bug

This commit is contained in:
Zef Hemel
2022-03-31 17:25:34 +02:00
parent 859657f8b8
commit 4d201efdbb
10 changed files with 82 additions and 46 deletions
@@ -12,6 +12,8 @@ import spaceSyscalls from "./syscalls/space";
import { eventSyscalls } from "../plugos/syscalls/event";
import { pageIndexSyscalls } from "./syscalls";
import knex, { Knex } from "knex";
import shellSyscalls from "../plugos/syscalls/shell.node";
import { NodeCronHook } from "../plugos/hooks/node_cron";
export class ExpressServer {
app: Express;
@@ -47,6 +49,10 @@ export class ExpressServer {
},
useNullAsDefault: true,
});
system.registerSyscalls("shell", ["shell"], shellSyscalls(rootPath));
system.addHook(new NodeCronHook());
system.registerSyscalls("index", [], pageIndexSyscalls(this.db));
system.registerSyscalls("space", [], spaceSyscalls(this.storage));
system.registerSyscalls("event", [], eventSyscalls(this.eventHook));
@@ -69,7 +75,7 @@ export class ExpressServer {
.route(/\/(.+)/)
.get(async (req, res) => {
let pageName = req.params[0];
console.log("Getting", pageName);
// console.log("Getting", pageName);
try {
let pageData = await this.storage.readPage(pageName);
res.status(200);
@@ -80,7 +86,7 @@ export class ExpressServer {
res.status(200);
res.send("");
}
})
};)
.put(bodyParser.text({ type: "*/*" }), async (req, res) => {
let pageName = req.params[0];
console.log("Saving", pageName);
+2 -6
View File
@@ -5,10 +5,8 @@ import http from "http";
import yargs from "yargs";
import {hideBin} from "yargs/helpers";
import {SilverBulletHooks} from "../common/manifest";
import {ExpressServer} from "./express_server";
import {ExpressServer} from "./api_server";
import {DiskPlugLoader} from "../plugos/plug_loader";
import {NodeCronHook} from "../plugos/hooks/node_cron";
import shellSyscalls from "../plugos/syscalls/shell.node";
import {System} from "../plugos/system";
let args = yargs(hideBin(process.argv))
@@ -19,7 +17,7 @@ let args = yargs(hideBin(process.argv))
.parse();
if (!args._.length) {
console.error("Usage: silverbullet <path-to-pages>");
console.error("Usage: silverbullet <path-to-pages>");
process.exit(1);
}
@@ -44,8 +42,6 @@ expressServer
);
await plugLoader.loadPlugs();
plugLoader.watcher();
system.registerSyscalls("shell", ["shell"], shellSyscalls(pagesPath));
system.addHook(new NodeCronHook());
server.listen(port, () => {
console.log(`Server listening on port ${port}`);
});