- Added home routes and corresponding route handler for fetching home summary. - Created GetHomeSummary use case to aggregate user data including groups, attendees, and upcoming payments. - Introduced HomeSummaryDto and related schemas for data validation. - Implemented nextClassOccurrence function to determine the next class based on user timezone. - Added tests for home summary functionality and next class occurrence logic.
23 lines
715 B
TypeScript
23 lines
715 B
TypeScript
import type { HomeQuery } from '@gruperly/shared';
|
|
import { HomeQuerySchema } from '@gruperly/shared';
|
|
import { Hono } from 'hono';
|
|
import { problemJson, resultJson, unauthorizedProblem } from '@/http/problem-details';
|
|
import { validate } from '@/http/validate';
|
|
import { GetHomeSummary } from './use-case';
|
|
|
|
const route = new Hono();
|
|
|
|
route.get('/', validate.query(HomeQuerySchema), async (c) => {
|
|
const user = c.get('user');
|
|
if (!user) {
|
|
return problemJson(c, unauthorizedProblem(c.req.path));
|
|
}
|
|
|
|
const query = c.req.valid('query') as HomeQuery;
|
|
const useCase = new GetHomeSummary();
|
|
const result = await useCase.execute(user.id, query);
|
|
|
|
return resultJson(c, result);
|
|
});
|
|
|
|
export default route; |