Architecture
Feature module DTO boundary
A server-side DTO helper is not a session verifier. Call it only after deriving actor identity from a trusted server session. It compares tenant/member scope and projects explicitly approved fields, avoiding audit notes. The surrounding server-only data access layer must also verify the resource and authorization policy. Source: https://nextjs.org/docs/app/guides/data-security. Documentation-reviewed illustrative draft; installed declarations and runtime not verified.
Formal Syntax & Structure
nextjs syntaxnextjs
route → feature service → scoped DAL → DTOWorking Example
Example Snippetnextjs
type Row = { lessonId: string; memberId: string; tenantId: string; percent: number; auditNote: string };export function progressDTO(row: Row, actor: {memberId:string;tenantId:string}) { if (row.tenantId !== actor.tenantId || row.memberId !== actor.memberId) return null; return {lessonId: row.lessonId, percent: row.percent};}