Compare commits

..

1 Commits

Author SHA1 Message Date
Olivier 'reivilibre
698a6c7e19 Replace config: use Valibot and allow multiple forges of one type
Signed-off-by: Olivier 'reivilibre <git.contact@librepush.net>
2025-09-30 15:08:22 +01:00
6 changed files with 7 additions and 10 deletions

View File

@ -16,10 +16,7 @@
"enabled": true,
"includes": ["src/**", "!src/types/openapi.d.ts"],
"rules": {
"recommended": true,
"style": {
"noNonNullAssertion": "off"
}
"recommended": true
}
},
"javascript": {

View File

@ -1,6 +1,6 @@
import * as v from "valibot";
import { CONFIG_SCHEMA_KEYS, type Config, ConfigSchema } from "./schema";
import { ConfigSchema, CONFIG_SCHEMA_KEYS, type Config } from "./schema";
import { transformEnvToConfig } from "./transformer";
import * as v from "valibot";
function createConfig(): Config {
const rawConfig = transformEnvToConfig(

View File

@ -26,7 +26,7 @@ export function transformEnvToConfig<Keys extends string[]>(
// descend into the deeper layers
// (following keyPath)
let current: Record<string, unknown> = config;
for (const part of keyPathParts.slice(0, -1)) {
for (let part of keyPathParts.slice(0, -1)) {
if (!(part in current)) {
current[part] = {};
}

View File

@ -18,7 +18,7 @@ authRouter.get("/login/:forgeId", (req: Request, res: Response) => {
}
const forgeId = parseInt(forgeIdParam, 10);
if (Number.isNaN(forgeId)) {
if (isNaN(forgeId)) {
res.status(400).json({ error: "Invalid forgeId" });
return;
}

View File

@ -1,8 +1,8 @@
import express from "express";
import session from "express-session";
import { createOpenAPIBackend, createOpenAPIMiddleware } from "./api/openapi";
import { config } from "./config";
import { connectDB } from "./config/db";
import { config } from "./config";
import authRouter from "./routes/auth";
import { seedForges } from "./util/seedforges";

View File

@ -1,9 +1,9 @@
import * as arctic from "arctic";
import type { ForgeInstanceConfig } from "../../config/schema";
import type { Forge } from "../../types/forge";
import type { ForgeUser } from "../../types/forgeuser";
import type { GiteaRepo } from "../../types/gitearepo";
import type { Repository } from "../../types/openapi";
import { ForgeInstanceConfig } from "../../config/schema";
export class GiteaForge implements Forge {
private gitea: arctic.Gitea;
private forgeId: number;