|
@@ -1,25 +1,16 @@
|
|
-import bodyParser from "body-parser";
|
|
|
|
import cors from "cors";
|
|
import cors from "cors";
|
|
import express from "express";
|
|
import express from "express";
|
|
import publicContent from "../../app.json";
|
|
import publicContent from "../../app.json";
|
|
import { IConfig } from "../config";
|
|
import { IConfig } from "../config";
|
|
-import { IMessageHandler } from "../messageHandler";
|
|
|
|
import { IRealm } from "../models/realm";
|
|
import { IRealm } from "../models/realm";
|
|
-import { AuthMiddleware } from "./middleware/auth";
|
|
|
|
-import CallsApi from "./v1/calls";
|
|
|
|
import PublicApi from "./v1/public";
|
|
import PublicApi from "./v1/public";
|
|
|
|
|
|
-export const Api = ({ config, realm, messageHandler }: {
|
|
|
|
|
|
+export const Api = ({ config, realm }: {
|
|
config: IConfig;
|
|
config: IConfig;
|
|
realm: IRealm;
|
|
realm: IRealm;
|
|
- messageHandler: IMessageHandler;
|
|
|
|
}): express.Router => {
|
|
}): express.Router => {
|
|
- const authMiddleware = new AuthMiddleware(config, realm);
|
|
|
|
-
|
|
|
|
const app = express.Router();
|
|
const app = express.Router();
|
|
|
|
|
|
- const jsonParser = bodyParser.json();
|
|
|
|
-
|
|
|
|
app.use(cors());
|
|
app.use(cors());
|
|
|
|
|
|
app.get("/", (_, res) => {
|
|
app.get("/", (_, res) => {
|
|
@@ -27,7 +18,6 @@ export const Api = ({ config, realm, messageHandler }: {
|
|
});
|
|
});
|
|
|
|
|
|
app.use("/:key", PublicApi({ config, realm }));
|
|
app.use("/:key", PublicApi({ config, realm }));
|
|
- app.use("/:key/:id/:token", authMiddleware.handle, jsonParser, CallsApi({ realm, messageHandler }));
|
|
|
|
|
|
|
|
return app;
|
|
return app;
|
|
};
|
|
};
|