enable https and add logging

This commit is contained in:
Matthieu Jolimaitre 2024-02-05 17:40:40 +01:00
parent 141c755a37
commit fb141abd05
2 changed files with 11 additions and 9 deletions

View file

@ -1,5 +1,6 @@
import { z } from "https://deno.land/x/zod@v3.22.4/mod.ts";
import { channel } from "./utils.ts";
import { channel, log_from } from "./utils.ts";
const log = log_from(import.meta.url);
export type TargetRole = { guild_id: string; role_id: string };
@ -25,6 +26,7 @@ export class RuleSet {
const file_content = await Deno.readTextFile(path);
const parsed = parse_rules(file_content);
for (const { group_id, target_role } of parsed) await result.append_rule(group_id, target_role);
result.update_channel = channel();
return result;
}
@ -76,7 +78,11 @@ export class RuleSet {
}
public async *receive_rule_update() {
while (true) yield await this.update_channel.receive();
while (true) {
const update = await this.update_channel.receive();
log(`Received an update for roles`, update);
yield update;
}
}
private async save() {

View file

@ -48,7 +48,7 @@ export class WebVerifier {
}
public url() {
return `http://${this.conf.url_prefix}`;
return `${this.conf.url_prefix}`;
}
private serve(request: Request): Response {
@ -76,18 +76,14 @@ export class WebVerifier {
return response_success();
}
private async serve_result_page() {
//
}
private create_verif_link() {
const uid = uuid.generate() as string;
const link = `http://${this.conf.url_prefix}/verify/${uid}`;
const link = `${this.conf.url_prefix}/verify/${uid}`;
return { uid, link };
}
private create_confirm_link(uid: string) {
return `http://${this.conf.url_prefix}/confirm/${uid}`;
return `${this.conf.url_prefix}/confirm/${uid}`;
}
private async start_peremption(uid: string) {