chore: updated dependencies of server

This commit is contained in:
Davide Passoni
2024-12-12 13:27:35 +01:00
parent d7edb00254
commit 6250f760a9
4 changed files with 29 additions and 19 deletions

View File

@@ -160,6 +160,7 @@ module.exports = function (configLocation, viteProxy) {
app.use("/olympus", async (req, res, next) => {
/* Check if custom authorization headers are being used */
const user =
//@ts-ignore
req.auth?.user ??
checkCustomHeaders(config, usersConfig, groupsConfig, req);
@@ -174,9 +175,11 @@ module.exports = function (configLocation, viteProxy) {
/* Check that the user is authorized to that role */
if (userConfig.roles.includes(req.headers["x-command-mode"])) {
/* Check that the role is valid */
//@ts-ignore
if (req.headers["x-command-mode"] in defaultUsers) {
/* Apply the authorization headers */
req.headers.authorization = `Basic ${btoa(
//@ts-ignore
user + ":" + defaultUsers[req.headers["x-command-mode"]]
)}`;
} else {
@@ -246,7 +249,7 @@ module.exports = function (configLocation, viteProxy) {
);
} else {
app.get("/", function (req, res) {
res.sendfile(path.join(__dirname, "..", "public", "index.html"));
res.sendFile(path.join(__dirname, "..", "public", "index.html"));
});
}

View File

@@ -1,12 +1,14 @@
import express = require("express");
const gtts = require("node-gtts")("en");
//const gtts = require("node-gtts")("en");
const speech = require("@google-cloud/speech");
const router = express.Router();
module.exports = function () {
router.put("/generate", (req, res, next) => {
res.set({ "Content-Type": "audio/mpeg" });
gtts.stream(req.body.text).pipe(res);
//res.set({ "Content-Type": "audio/mpeg" });
// TODO
//gtts.stream(req.body.text).pipe(res);
res.sendStatus(404);
});
router.put("/recognize", (req, res, next) => {