feat: finalize academy redesign and production readiness
All checks were successful
CI / Validate frontend and API (push) Successful in 2m22s
CI / Build and publish Docker images (push) Successful in 1m6s

Align admin, community, search, library, learning and course management with the mockup. Add saved courses, download history, public community feed, instructor directory, backend search, course views, admin content tools and community moderation. Harden API and Nginx for production.
This commit is contained in:
Cauê Faleiros
2026-11-05 15:06:53 -03:00
parent 95a4bd4ac7
commit 21085e887d
99 changed files with 10749 additions and 3935 deletions

View File

@@ -22,6 +22,10 @@ const commentSchema = z.object({
});
const commentParamsSchema = z.object({ commentId: z.string().uuid() });
const replySchema = z.object({ text: z.string().trim().min(1).max(4000) });
const communityQuerySchema = z.object({
limit: z.coerce.number().int().min(1).max(100).default(50),
offset: z.coerce.number().int().min(0).default(0),
});
const ensurePublishedCourse = async (courseId: string) => {
const result = await pool.query(
@@ -38,6 +42,25 @@ const canViewCourseComments = async (courseId: string, user: { id: string; role:
};
export const learningRoutes: FastifyPluginAsync = async (app) => {
// Public, paginated feed used by the community screen. Individual course
// threads remain authenticated because they are part of the lesson area.
app.get('/community/comments', async (request) => {
const { limit, offset } = communityQuerySchema.parse(request.query);
const result = await pool.query(
`select c.id, c.course_id as "courseId", c.lesson_id as "lessonId", c.body as text,
c.created_at as "createdAt", u.display_name as "user",
cr.body as reply, cr.created_at as "replyCreatedAt"
from comments c
join users u on u.id = c.author_id
join courses co on co.id = c.course_id and co.status = 'published'
left join comment_replies cr on cr.comment_id = c.id
order by c.created_at desc
limit $1 offset $2`,
[limit, offset],
);
return { data: result.rows };
});
const canModerateComment = async (commentId: string, user: { id: string; role: string }) => {
const result = await pool.query<{ instructor_id: string }>(
`select c.instructor_id