fix some syntax and stuff

This commit is contained in:
Darius
2025-09-26 21:44:24 +02:00
parent a0a76a8b75
commit cc5ecaf8e0
10 changed files with 346 additions and 30 deletions

View File

@@ -4,14 +4,12 @@ import {
type ServerResponse,
} from "node:http";
import { URL } from "node:url";
import { Config } from "../config/config.js";
import { Config } from "../config/config.ts";
export class TwitchAuth {
private readonly clientId: string;
private readonly redirectUri: string;
constructor(redirectUri: string = "http://localhost:3000") {
this.clientId = Config.client_id;
this.redirectUri = redirectUri;
}
@@ -19,7 +17,7 @@ export class TwitchAuth {
const baseUrl = "https://id.twitch.tv/oauth2/authorize";
const params = new URLSearchParams({
response_type: "code",
client_id: this.clientId,
client_id: Config.client_id,
redirect_uri: this.redirectUri,
scope: scopes.join(" "),
});

View File

@@ -1,5 +1,6 @@
import { apiClient } from "../core/api-client";
import { logError, logInfo } from "./logger";
import * as readline from "node:readline";
import { apiClient } from "../core/api-client.ts";
import { logError, logInfo } from "./logger.ts";
export async function getUserId(username: string): Promise<string | null> {
const user = await apiClient.users.getUserByName(username);
@@ -10,3 +11,17 @@ export async function getUserId(username: string): Promise<string | null> {
logError(`no user with name ${username} found`);
return null;
}
export async function promptForInput(prompt: string): Promise<string> {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
return new Promise<string>((resolve) => {
rl.question(prompt, (answer) => {
rl.close();
resolve(answer.trim());
});
});
}