- Implemented MpReauthNotice component to notify users when reauthorization is needed. - Created MpStatusCard component to display the current status of the Mercado Pago account. - Added utility functions and constants for handling Mercado Pago status and messages. - Introduced hooks for managing the connection and disconnection of Mercado Pago accounts. - Developed a disconnect confirmation modal for user actions. - Added tests for the new functionality and utility functions. - Defined schemas for Mercado Pago account status and callback reasons in shared package.
65 lines
2.2 KiB
TypeScript
65 lines
2.2 KiB
TypeScript
import { Hono } from 'hono';
|
|
import type { BackendEnv } from '@/http/env';
|
|
import {
|
|
internalServerErrorProblem,
|
|
notFoundProblem,
|
|
problemJson,
|
|
} from '@/http/problem-details';
|
|
import { requestIdMiddleware } from '@/http/request-id';
|
|
import { requestLoggerMiddleware } from '@/http/request-logger';
|
|
import { corsMiddleware, securityHeadersMiddleware } from '@/http/security-headers';
|
|
import { sessionAuthMiddleware } from '@/http/session-auth';
|
|
import { logger } from '@/logger';
|
|
import {
|
|
groupsRiskOverviewRoute,
|
|
studentStatusRoutes,
|
|
} from './modules/analytics';
|
|
import { attendeesRoutes } from './modules/attendees';
|
|
import { authRoutes } from './modules/auth';
|
|
import { classesRoutes } from './modules/classes';
|
|
import { groupsRoutes } from './modules/groups';
|
|
import { healthCheckRoutes } from './modules/health-check';
|
|
import { homeRoutes } from './modules/home';
|
|
import { invitationsRoutes } from './modules/invitations';
|
|
import { mpRoutes } from './modules/mp';
|
|
import { onboardingRoutes } from './modules/onboarding';
|
|
import { paymentsRoutes } from './modules/payments';
|
|
import { waitlistRoutes } from './modules/waitlist';
|
|
|
|
const app = new Hono<BackendEnv>();
|
|
|
|
app.use('*', corsMiddleware);
|
|
app.use('*', securityHeadersMiddleware);
|
|
app.use('*', requestIdMiddleware);
|
|
app.use('*', requestLoggerMiddleware);
|
|
|
|
app.get('/', (c) => c.json({ name: 'Gruperly API', status: 'ok' }));
|
|
|
|
const api = app.basePath('/api/v1');
|
|
|
|
api.use('*', sessionAuthMiddleware);
|
|
|
|
api.route('/auth', authRoutes);
|
|
api.route('/health', healthCheckRoutes);
|
|
api.route('/invitations', invitationsRoutes);
|
|
api.route('/groups', groupsRoutes);
|
|
api.route('/home', homeRoutes);
|
|
api.route('/onboarding', onboardingRoutes);
|
|
api.route('/mp', mpRoutes);
|
|
api.route('/attendees', attendeesRoutes);
|
|
api.route('/payments', paymentsRoutes);
|
|
api.route('/waitlist', waitlistRoutes);
|
|
api.route('/classes', classesRoutes);
|
|
api.route('/students', studentStatusRoutes);
|
|
api.route('/groups-risk', groupsRiskOverviewRoute);
|
|
|
|
app.notFound((c) => {
|
|
return problemJson(c, notFoundProblem(c.req.path));
|
|
});
|
|
|
|
app.onError((error, c) => {
|
|
logger.error({ error, path: c.req.path }, 'Unhandled request error');
|
|
return problemJson(c, internalServerErrorProblem(c.req.path));
|
|
});
|
|
|
|
export default app; |