constants.ts
Raw
1import path from "node:path";
2import config from "./config.ts";
3
4// Auth / identity
5export const WEBAUTHN_RP_NAME = `${config.OWNER_DISPLAY_NAME}'s Hearthforge`;
6export const ADMIN_USERNAME = "admin";
7export const VALID_USERNAME_RE = /^[a-zA-Z0-9_-]+$/;
8export const VALID_REPO_NAME_RE = /^[a-zA-Z0-9._-]+$/;
9export const ALLOWED_REACTIONS = new Set([
10 "👍",
11 "👎",
12 "❤️",
13 "🎉",
14 "😕",
15 "👀",
16 "🚀",
17]);
18export const VALID_KEY_TYPES = new Set([
19 "ssh-rsa",
20 "ssh-ed25519",
21 "ecdsa-sha2-nistp256",
22 "ecdsa-sha2-nistp384",
23 "ecdsa-sha2-nistp521",
24 "sk-ssh-ed25519@openssh.com",
25 "sk-ecdsa-sha2-nistp256@openssh.com",
26]);
27export const CHALLENGE_TTL_MS = 5 * 60 * 1000;
28
29// Pagination
30export const REPOS_PER_PAGE = 20;
31export const COMMITS_PER_PAGE = 20;
32export const ISSUES_PER_PAGE = 20;
33export const PATCHES_PER_PAGE = 20;
34export const RELEASES_PER_PAGE = 20;
35export const BRANCHES_PER_PAGE = 30;
36export const TAGS_PER_PAGE = 30;
37
38// Cache sizes
39export const MAX_MD_CACHE = 50;
40export const MAX_FILE_CACHE = 500;
41export const MAX_DIFF_CACHE = 500;
42export const MAX_PATCH_CACHE = 100;
43
44// Paths — derived from config.DATA_DIR via getters so they reflect overrides.
45export const paths = {
46 get DB_PATH() {
47 return path.join(config.DATA_DIR, "hearthforge.db");
48 },
49 get REPOS_DIR() {
50 return path.join(config.DATA_DIR, "repos");
51 },
52 get AVATARS_DIR() {
53 return path.join(config.DATA_DIR, "avatars");
54 },
55 get RELEASES_DIR() {
56 return path.join(config.DATA_DIR, "releases");
57 },
58 get SSH_HOST_KEY_PATH() {
59 return (
60 process.env.SSH_HOST_KEY_PATH ??
61 path.join(config.DATA_DIR, "ssh_host_key")
62 );
63 },
64 get ALLOWED_SIGNERS_PATH() {
65 return path.join(config.DATA_DIR, "allowed_signers");
66 },
67};
68