mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 01:36:06 -04:00
resolve typing errors, run api when appservice runs
This commit is contained in:
parent
be18613722
commit
4a9e5d422d
@ -19,6 +19,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/crypto-js": "^4.0.2",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/html-to-text": "^8.0.1",
|
||||
"@types/humanize-duration": "^3.27.1",
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
|
@ -34,6 +34,8 @@ export class Api {
|
||||
}
|
||||
|
||||
public start(port: number) {
|
||||
this.httpdConfig.use(express.json());
|
||||
|
||||
this.httpdConfig.get("/get", this.pathGet);
|
||||
this.httpdConfig.get("/list", this.pathList);
|
||||
this.httpdConfig.post("/create", this.pathCreate);
|
||||
@ -42,13 +44,13 @@ export class Api {
|
||||
}
|
||||
|
||||
private async pathGet(request: express.Request, response: express.Response) {
|
||||
const accessToken = request.params.query["openId"];
|
||||
const accessToken = request.query["openId"];
|
||||
if (accessToken === undefined) {
|
||||
response.status(401);
|
||||
return;
|
||||
}
|
||||
|
||||
const mjolnirId = request.params.query["mxid"];
|
||||
const mjolnirId = request.query["mxid"];
|
||||
if (mjolnirId === undefined) {
|
||||
response.status(400);
|
||||
return;
|
||||
@ -69,7 +71,7 @@ export class Api {
|
||||
}
|
||||
|
||||
private async pathList(request: express.Request, response: express.Response) {
|
||||
const accessToken = request.params.query["openId"];
|
||||
const accessToken = request.query["openId"];
|
||||
if (accessToken === undefined) {
|
||||
response.status(401);
|
||||
return;
|
||||
@ -83,7 +85,7 @@ export class Api {
|
||||
}
|
||||
|
||||
private async pathCreate(request: express.Request, response: express.Response) {
|
||||
const accessToken = request.params.query["openId"];
|
||||
const accessToken = request.body["openId"];
|
||||
if (accessToken === undefined) {
|
||||
response.status(401);
|
||||
return;
|
||||
|
@ -20,6 +20,7 @@ import { AppServiceRegistration, Bridge, Cli, Request, WeakEvent, BridgeContext,
|
||||
// needed by appservice irc, though it looks completely dead.
|
||||
import * as Datastore from "nedb";
|
||||
import { MjolnirManager } from ".//MjolnirManager";
|
||||
import { Api } from "./Api";
|
||||
// ts-node src/appservice/AppService.ts -r -u "http://localhost:9000" # remember to add the registration to homeserver.yaml! you probably want host.docker.internal as the hostname of the appservice if using mx-tester
|
||||
// ts-node src/appservice/AppService -p 9000 # to start.
|
||||
|
||||
@ -29,6 +30,7 @@ export class MjolnirAppService {
|
||||
private readonly mjolnirManager: MjolnirManager = new MjolnirManager();
|
||||
|
||||
public constructor() {
|
||||
new Api("http://localhost:9999", this).start(9001);
|
||||
this.bridge = new Bridge({
|
||||
homeserverUrl: "http://localhost:9999",
|
||||
domain: "localhost:9999",
|
||||
|
Loading…
Reference in New Issue
Block a user