Skip to main content

Shared Libraries

Importing

import { JwtAuthGuard, ProjectAccessGuard, CurrentUser } from '@app/auth';
import { PaginationQueryDto, ApiResponse } from '@app/common';
import { BaseEntity, Organization } from '@app/database';

@app/auth

Guards

  • JwtAuthGuard - Validates Cognito JWT (global)
  • ProjectAccessGuard - Validates project membership
  • OrgRolesGuard - Validates organization role
  • PlatformAdminGuard - Restricts to platform admins

Decorators

  • @CurrentUser() - Get authenticated user
  • @CurrentProject() - Get validated project
  • @Public() - Skip JWT validation
  • @OrgRoles('admin', 'owner') - Require org roles

@app/common

Response Format

All responses wrapped in envelope:

{ "data": { ... } }

Paginated:

{ "data": [...], "meta": { "page": 1, "limit": 20, "total": 100, "totalPages": 5 } }

EncryptionService

const encrypted = this.encryptionService.encrypt('secret');
const decrypted = this.encryptionService.decrypt(encrypted);

@app/database

BaseEntity

export class MyEntity extends BaseEntity {
// Inherits: id (UUID), createdAt, updatedAt
}