feat(dashboard): setting up layout

This commit is contained in:
2025-11-12 16:51:59 +02:00
parent b8b2a15ee9
commit a3f46b6b38
61 changed files with 2957 additions and 123 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ import path from "node:path";
import { loadConfig } from "@devscast/config";
import { z } from "zod";
const PROJECT_DIR = path.resolve(__dirname, "../../");
const PROJECT_DIR = path.resolve(__dirname, "../");
export const { env, config } = loadConfig({
env: {
+38 -2
View File
@@ -5,13 +5,16 @@ import { Database } from "@/client";
import { NotFoundError } from "@/errors";
import { Credibility, source } from "@/schema";
export async function getSources(db: Database) {
return db.query.source.findMany();
}
export type CreateSourceParams = {
name: string;
url: string;
displayName?: string;
description?: string;
credibility: Credibility;
updatedAt?: Date;
credibility?: Credibility;
};
export async function createSource(db: Database, params: CreateSourceParams) {
@@ -23,6 +26,33 @@ export async function createSource(db: Database, params: CreateSourceParams) {
return result;
}
export type UpdateSourceParams = {
id: string;
name?: string;
displayName?: string;
description?: string;
credibility?: Credibility;
};
export async function updateSource(db: Database, params: UpdateSourceParams) {
const [result] = await db
.update(source)
.set({
credibility: params.credibility,
description: params.description,
displayName: params.displayName,
name: params.name,
})
.where(eq(source.id, params.id))
.returning();
if (result === undefined) {
throw new NotFoundError(`Source not found`);
}
return result;
}
export type DeleteSourceParams = {
id: string;
};
@@ -39,6 +69,12 @@ export async function getSourceByName(db: Database, name: string) {
});
}
export async function getById(db: Database, id: string) {
return db.query.source.findFirst({
where: eq(source.id, id),
});
}
export async function getSourceIdByName(db: Database, name: string): Promise<string> {
const result = await db.query.source.findFirst({
columns: {