Skip to content

Commit

Permalink
Merge pull request #467 from MrBrax/develop-ts
Browse files Browse the repository at this point in the history
2023-10-09
  • Loading branch information
MrBrax authored Oct 9, 2023
2 parents 0ce7174 + 3077597 commit ba49910
Show file tree
Hide file tree
Showing 44 changed files with 1,529 additions and 1,060 deletions.
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
"search.exclude": {
"**/*.lock": true,
"build/**": true,
}
},
"eslint.workingDirectories": [
"./server",
"./twitch-chat-dumper",
"./client-vue"
],
}
666 changes: 335 additions & 331 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client-vue/.pnp.loader.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client-vue/.yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ supportedArchitectures:
- win32
- linux-arm64

yarnPath: .yarn/releases/yarn-3.6.1.cjs
yarnPath: .yarn/releases/yarn-3.6.4.cjs
4 changes: 2 additions & 2 deletions client-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "livestreamdvr-client",
"version": "2.3.4",
"version": "2.3.5",
"private": true,
"homepage": "https://github.com/MrBrax/LiveStreamDVR",
"scripts": {
Expand Down Expand Up @@ -64,7 +64,7 @@
"vitest": "^0.33.0",
"vue-tsc": "^1.8.5"
},
"packageManager": "yarn@3.6.1",
"packageManager": "yarn@3.6.4",
"engines": {
"node": ">=18"
}
Expand Down
2 changes: 1 addition & 1 deletion client-vue/src/components/SideMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</div>

<div v-if="store.streamerList && store.streamerList.length > 0" class="menu-middle">
<side-menu-streamer v-for="streamer in sortedStreamers" :key="streamer.login" ref="streamer" :streamer="streamer" />
<side-menu-streamer v-for="streamer in sortedStreamers" :key="streamer.internalName" ref="streamer" :streamer="streamer" />
</div>

<!-- what was the point of this divider? -->
Expand Down
4 changes: 2 additions & 2 deletions client-vue/src/components/SideMenuStreamer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
'is-live': streamer.is_live,
'is-capturing': streamer.is_capturing,
'is-animated': store.clientCfg('animationsEnabled'),
'is-active': route.query.channel == streamer.login,
'is-active': route.query.channel == streamer.internalName,
'is-converting': streamer.is_converting,
'no-capture': streamer.no_capture,
streamer: true,
}"
:data-streamer="streamer.login"
:data-streamer="streamer.internalName"
>
<!-- :style="{
'background-image': 'url(' + bannerUrl + ')',
Expand Down
4 changes: 2 additions & 2 deletions client-vue/src/components/SideMenuStreamerVod.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@
<!-- tooltip -->
<div :class="{ tooltip: true, 'is-static': store.clientCfg('tooltipStatic') }">
<div class="stream-channel">
{{ streamer.display_name }}
<template v-if="streamer.login.toLowerCase() != streamer.display_name.toLowerCase()"> ({{ streamer.login }}) </template>
{{ streamer.displayName }}
<template v-if="streamer.internalName.toLowerCase() != streamer.internalName.toLowerCase()"> ({{ streamer.displayName }}) </template>
</div>
<div class="stream-name">
{{ vod.basename }}
Expand Down
2 changes: 1 addition & 1 deletion client-vue/src/components/streamer/VideoDownloadModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async function fetchTwitchVods() {
let response;
try {
response = await axios.get<ApiResponse>(`/api/v0/twitchapi/videos/${props.streamer.login}`);
response = await axios.get<ApiResponse>(`/api/v0/twitchapi/videos/${props.streamer.internalName}`);
} catch (error) {
if (axios.isAxiosError(error)) {
console.error("fetchTwitchVods error", error.response);
Expand Down
6 changes: 3 additions & 3 deletions client-vue/src/core/Providers/Base/BaseChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import type { Providers } from "@common/Defs";

export default class BaseChannel {
provider: Providers = "base";
userid = "";
display_name = "";
login = "";
// userid = "";
// display_name = "";
// login = "";
description = "";
quality: VideoQuality[] = [];
no_capture = false;
Expand Down
2 changes: 1 addition & 1 deletion server/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = {
"no-var": "error",
"prefer-const": "error",
"@typescript-eslint/consistent-type-imports": "error",
"log-module": "warn",
// "log-module": "warn",
"no-throw-literal": "error",
// "import/no-relative-parent-imports": "error",
},
Expand Down
2 changes: 1 addition & 1 deletion server/.pnp.loader.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions server/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}\\src\\index.ts",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
"args": ["--port", "8081"],
"outFiles": ["${workspaceFolder}/**/*.js"]
}
]
}
}

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion server/.yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ supportedArchitectures:
- win32
- linux-arm64

yarnPath: .yarn/releases/yarn-3.6.1.cjs
yarnPath: .yarn/releases/yarn-3.6.3.cjs
4 changes: 2 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "livestreamdvr-server",
"version": "1.6.2",
"version": "1.6.3",
"description": "",
"main": "index.ts",
"scripts": {
Expand Down Expand Up @@ -79,7 +79,7 @@
"winston-daily-rotate-file": "^4.7.1",
"ws": "^8.13.0"
},
"packageManager": "yarn@3.6.1",
"packageManager": "yarn@3.6.3",
"engines": {
"node": ">=18"
},
Expand Down
87 changes: 87 additions & 0 deletions server/src/Controllers/Auth.test.ts.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import request from "supertest";
import { getApp } from "../app";

const app = getApp();

describe("Auth Controller", () => {
describe("POST /auth/login", () => {
it("should return 400 if already authenticated", async () => {
const agent = request.agent(app);
await agent.post("/api/v0/auth/login").send({ password: "test" });
const response = await agent
.post("/api/v0/auth/login")
.send({ password: "test" });
expect(response.status).toBe(400);
expect(response.body.authenticated).toBe(true);
expect(response.body.message).toBe(
"You are already authenticated."
);
});

it("should return 400 if no password set", async () => {
const response = await request(app)
.post("/api/v0/auth/login")
.send({ password: "" });
expect(response.status).toBe(400);
expect(response.body.authenticated).toBe(false);
expect(response.body.message).toBe("No password set.");
});

it("should return 401 if password is incorrect", async () => {
const response = await request(app)
.post("/api/v0/auth/login")
.send({ password: "wrong" });
expect(response.status).toBe(401);
expect(response.body.authenticated).toBe(false);
expect(response.body.message).toBe("Incorrect password.");
});

it("should return 200 if password is correct", async () => {
const response = await request(app)
.post("/api/v0/auth/login")
.send({ password: "test" });
expect(response.status).toBe(200);
expect(response.body.authenticated).toBe(true);
expect(response.body.message).toBe("Login successful.");
});
});

describe("POST /auth/logout", () => {
it("should return 200 if logged out successfully", async () => {
const agent = request.agent(app);
await agent.post("/api/v0/auth/login").send({ password: "test" });
const response = await agent.post("/api/v0/auth/logout");
expect(response.status).toBe(200);
expect(response.body.authenticated).toBe(false);
expect(response.body.message).toBe("Logout successful.");
});
});

describe("GET /auth/check", () => {
it("should return 200 if not password protected", async () => {
const response = await request(app).get("/api/v0/auth/check");
expect(response.status).toBe(200);
expect(response.body.authentication).toBe(false);
expect(response.body.authenticated).toBe(false);
expect(response.body.message).toBe("No password protection.");
});

it("should return 200 if authenticated", async () => {
const agent = request.agent(app);
await agent.post("/api/v0/auth/login").send({ password: "test" });
const response = await agent.get("/api/v0/auth/check");
expect(response.status).toBe(200);
expect(response.body.authentication).toBe(true);
expect(response.body.authenticated).toBe(true);
expect(response.body.guest_mode).toBe(false);
});

it("should return 200 if not authenticated", async () => {
const response = await request(app).get("/api/v0/auth/check");
expect(response.status).toBe(200);
expect(response.body.authentication).toBe(true);
expect(response.body.authenticated).toBe(false);
expect(response.body.guest_mode).toBe(false);
});
});
});
Loading

0 comments on commit ba49910

Please sign in to comment.