diff --git a/README.md b/README.md index 838d75e..7d5fe76 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Then create a `servers.json` file like this here: Now you are ready to start the script. Make sure to have an environment variable called `TINYSCALE_SECRET`: - TINYSCALE_SECRET=some_secret_string deno run --allow-net --allow-read --allow-env https://deno.land/x/tinyscale@v1.6.4/mod.ts + TINYSCALE_SECRET=some_secret_string deno run --allow-net --allow-read --allow-env https://deno.land/x/tinyscale@v1.7.0/mod.ts tinyscale will then run on port 3005 and you will have to set up your reverse proxy so that it can pick up requests. If you prefer a different port you can diff --git a/app.ts b/app.ts index 29f4a06..36bcc56 100644 --- a/app.ts +++ b/app.ts @@ -1,6 +1,7 @@ -import { opine, ErrorRequestHandler, Router, secret, createError, Color, deferred, Deferred } from "./deps.ts"; +import { opine, ErrorRequestHandler, Router, secret, HttpError, Color, deferred, Deferred } from "./deps.ts"; import { BBB } from './bbb.ts'; -import { Servers, server } from './servers.ts' +import { Servers } from './servers.ts' +import type { server } from './deps.ts' const date = () => new Date().toLocaleTimeString('de') @@ -22,7 +23,7 @@ router.use("/:call", (req, res, next) => { res.locals.handler = handler next() } else { - next(createError(401)) + next(new HttpError(401)); } }) // if the param is call, check for races @@ -62,7 +63,7 @@ router.all("/:call", async (req, res, next) => { res.send(body) } catch (e) { if (handler.call === 'create') { queue[handler.meeting_id]?.resolve(e); delete queue[handler.meeting_id] } - next(createError(500)) + next(new HttpError(500)); } } console.log(res.locals.log.join(' ')); @@ -80,7 +81,7 @@ const errorHandler: ErrorRequestHandler = (err, req, res, next) => { const app = opine() .use("/bigbluebutton/api", router) - .use((req, res, next) => next(createError(404))) + .use((req, res, next) => next(new HttpError(404))) .use(errorHandler); export default app; \ No newline at end of file diff --git a/bbb.ts b/bbb.ts index 3c10efa..673c0a5 100644 --- a/bbb.ts +++ b/bbb.ts @@ -1,6 +1,6 @@ import { Request, ParamsDictionary, createHash } from "./deps.ts"; +import type { server } from './deps.ts' -export interface server { host: string; secret: string }; export class BBB { call: string checksum_incoming: string diff --git a/deps.ts b/deps.ts index 873c617..4380831 100644 --- a/deps.ts +++ b/deps.ts @@ -3,7 +3,8 @@ export type { Deferred } from "https://deno.land/std/async/mod.ts"; export { join } from "https://deno.land/std/path/mod.ts"; export { createHash } from "https://deno.land/std/hash/mod.ts"; export * as Color from "https://deno.land/std/fmt/colors.ts"; -export { createError } from "https://deno.land/x/http_errors@3.0.0/mod.ts"; -export { opine, Router } from "https://deno.land/x/opine@1.7.2/mod.ts"; -export type { ErrorRequestHandler, Request, ParamsDictionary } from "https://deno.land/x/opine@1.7.2/mod.ts"; -export const secret: string = Deno.env.get("TINYSCALE_SECRET") || "" \ No newline at end of file +export { HttpError } from "https://deno.land/x/http_error@0.1.2/mod.ts"; +export { opine, Router } from "https://deno.land/x/opine@1.9.1/mod.ts"; +export type { ErrorRequestHandler, Request, ParamsDictionary } from "https://deno.land/x/opine@1.9.1/mod.ts"; +export const secret: string = Deno.env.get("TINYSCALE_SECRET") || "" +export interface server { host: string; secret: string }; \ No newline at end of file diff --git a/servers.ts b/servers.ts index 5a7c966..0669f1d 100644 --- a/servers.ts +++ b/servers.ts @@ -1,6 +1,5 @@ import { createHash, Color } from "./deps.ts"; -export interface server { host: string; secret: string }; - +import type { server } from './deps.ts' export class Servers { servers: server[] iterator!: IterableIterator @@ -36,7 +35,7 @@ export class Servers { if (!ok) throw "Configuration error. Exiting …" } catch (e) { // exit tinyscale if an error is encountered in servers.json - console.log(Color.brightRed(e)) + console.log(Color.brightRed(JSON.stringify(e))) Deno.exit(1); } })