feat(dashboard): source overview
This commit is contained in:
@@ -11,7 +11,10 @@ const ServerConfigurationSchema = z.object({
|
||||
allowMethods: z.array(z.string()).optional(),
|
||||
exposeHeaders: z.array(z.string()).optional(),
|
||||
maxAge: z.number().int().min(0).optional(),
|
||||
origin: z.string(), //z.array(z.string()).default([]),
|
||||
origin: z
|
||||
.array(z.string())
|
||||
.optional()
|
||||
.default(["http://localhost:3000", "http://127.0.0.1:3000", "https://dashboard.basango.io"]),
|
||||
}),
|
||||
server: z.object({
|
||||
host: z.string().default("localhost"),
|
||||
|
||||
@@ -22,7 +22,7 @@ app.use(
|
||||
allowMethods: config.cors.allowMethods,
|
||||
exposeHeaders: config.cors.exposeHeaders,
|
||||
maxAge: config.cors.maxAge,
|
||||
origin: config.cors.origin,
|
||||
origin: ["http://localhost:3000", "http://127.0.0.1:3000", "https://dashboard.basango.io"],
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -55,6 +55,43 @@ export const getSourceSchema = z.object({
|
||||
id: idSchema,
|
||||
});
|
||||
|
||||
export const getSourcePublicationGraphSchema = z.object({
|
||||
days: z
|
||||
.number()
|
||||
.optional()
|
||||
.openapi({
|
||||
default: 60,
|
||||
description: "",
|
||||
example: 60,
|
||||
})
|
||||
.openapi({
|
||||
description: "The number of days to include in the publication graph.",
|
||||
}),
|
||||
id: idSchema,
|
||||
range: z
|
||||
.object({
|
||||
from: z.date().openapi({
|
||||
description: "The start date of the range.",
|
||||
}),
|
||||
to: z.date().openapi({
|
||||
description: "The end date of the range.",
|
||||
}),
|
||||
})
|
||||
.optional()
|
||||
.openapi({
|
||||
description: "The date range for the publication graph.",
|
||||
}),
|
||||
});
|
||||
|
||||
export const getSourceCategorySharesSchema = z.object({
|
||||
id: idSchema,
|
||||
limit: z.number().int().min(1).max(100).optional().openapi({
|
||||
default: 10,
|
||||
description: "The maximum number of categories to return.",
|
||||
example: 10,
|
||||
}),
|
||||
});
|
||||
|
||||
export const updateSourceSchema = z.object({
|
||||
credibility: credibilitySchema.optional(),
|
||||
description: createSourceSchema.shape.description,
|
||||
|
||||
@@ -7,7 +7,13 @@ import {
|
||||
updateSource,
|
||||
} from "@basango/db/queries";
|
||||
|
||||
import { createSourceSchema, getSourceSchema, updateSourceSchema } from "#api/schemas/sources";
|
||||
import {
|
||||
createSourceSchema,
|
||||
getSourceCategorySharesSchema,
|
||||
getSourcePublicationGraphSchema,
|
||||
getSourceSchema,
|
||||
updateSourceSchema,
|
||||
} from "#api/schemas/sources";
|
||||
import { createTRPCRouter, protectedProcedure } from "#api/trpc/init";
|
||||
|
||||
export const sourcesRouter = createTRPCRouter({
|
||||
@@ -21,13 +27,17 @@ export const sourcesRouter = createTRPCRouter({
|
||||
return getSourceById(ctx.db, input.id);
|
||||
}),
|
||||
|
||||
getCategoryShares: protectedProcedure.input(getSourceSchema).query(async ({ ctx, input }) => {
|
||||
return getSourceCategoryShares(ctx.db, input.id);
|
||||
}),
|
||||
getCategoryShares: protectedProcedure
|
||||
.input(getSourceCategorySharesSchema)
|
||||
.query(async ({ ctx, input }) => {
|
||||
return getSourceCategoryShares(ctx.db, input);
|
||||
}),
|
||||
|
||||
getPublicationGraph: protectedProcedure.input(getSourceSchema).query(async ({ ctx, input }) => {
|
||||
return getSourcePublicationGraph(ctx.db, input.id);
|
||||
}),
|
||||
getPublicationGraph: protectedProcedure
|
||||
.input(getSourcePublicationGraphSchema)
|
||||
.query(async ({ ctx, input }) => {
|
||||
return getSourcePublicationGraph(ctx.db, input);
|
||||
}),
|
||||
|
||||
update: protectedProcedure.input(updateSourceSchema).mutation(async ({ ctx, input }) => {
|
||||
return updateSource(ctx.db, input);
|
||||
|
||||
Reference in New Issue
Block a user