Developer tooling for the api application encompasses a suite of scripts, configurations, and dependencies designed to streamline development, build processes, and maintain code quality. This includes automated asset processing, project-specific CLI configurations, and a comprehensive set of development and production dependencies alongside various utility scripts for tasks like database management, testing, and deployment.
This page details the core components of the api application's developer tooling, providing insights into its structure and functionality.
Badge Icon Encoding Script
The encode-badge-icons.ts script is a crucial utility for pre-processing static SVG assets. Its primary purpose is to extract SVG definitions of badge icons from a React component file, encode them as base64 data URLs, and then embed these data URLs into a TypeScript service file. This process optimizes the delivery of small icons by inlining them directly into the application's code, reducing HTTP requests.
Architecture and Data Flow
The script operates by reading a source file containing SVG components, parsing their content, performing base64 encoding, and finally updating a target service file with the generated data.
This script is designed to be run manually or as part of a build process, indicated by its usage instruction: bun run apps/api/scripts/encode-badge-icons.ts.
Key Components
logos.tsx: The source file (located at../../app/src/app/(app)/[orgId]/trust/portal-settings/components/logos.tsx) from which SVG definitions are extracted.extractSvg(componentName: string): A function that uses regular expressions to find and extract the SVG content corresponding to a given React component name withinlogos.tsx. It also cleans uppropsspread attributes from the SVG.function extractSvg(componentName: string): string | null { const regex = new RegExp(`export const ${componentName} = \\(props.*?\\) => \\(\\s*(<svg[\\s\\S]*?<\\/svg>)\\s*\\);`, 's'); const match = logosContent.match(regex); if (!match) { console.warn(`Warning: Could not find ${componentName}`); return null; } return match[1] .replace(/\{props\}/g, '') .replace(/\{\.\.\.props\}/g, '') .trim(); }badgesArray: An array of objects defining the specific badge icons to be processed. Each object includesname(component name inlogos.tsx),type(key for the map), andlabel(human-readable name).- Examples:
SOC2Type2,ISO27001,GDPR,HIPAA,PCIDSS.
- Examples:
encodedBadgesMap: An object that stores the final base64 encoded icon data URLs and their labels, keyed by thetypeproperty of each badge.trust-access.service.ts: The target service file (located at../src/trust-portal/trust-access.service.ts) where theBADGE_ICON_MAPconstant is updated.BADGE_ICON_MAP: A constant withintrust-access.service.tsthat holds the mapping of badge types to their encoded icon data and labels. The script dynamically generates and replaces this map.
NestJS CLI Configuration
The nest-cli.json file configures the NestJS Command Line Interface (CLI) for the api application. This configuration dictates how the NestJS CLI interacts with the project, including source file locations and build options.
Configuration Options
| Option | Description | Value |
|---|---|---|
$schema | JSON schema for validation of the configuration file. | https://json.schemastore.org/nest-cli |
collection | Specifies the schematics collection to use for generating NestJS artifacts. | @nestjs/schematics |
sourceRoot | Defines the root directory where application source files reside. | src |
compilerOptions | Options passed to the TypeScript compiler via the NestJS CLI. | { "deleteOutDir": true } |
compilerOptions.deleteOutDir | If true, the output directory (dist by default) is deleted before each build. | true |
Project Dependencies and Scripts
The package.json file for the api application defines its metadata, lists all required dependencies, and provides a set of scripts for various development, build, testing, and deployment tasks.
Dependencies
The api application relies on a wide array of packages for its functionality, ranging from core NestJS modules to database ORMs, cloud SDKs, AI tools, and utility libraries.
Scripts
The scripts section defines various command-line shortcuts for common tasks. These scripts automate repetitive actions, ensuring consistency across development environments.
Build Operations
The
buildscripts compile the NestJS application. Thebuild:dockerscript includes a Prisma generation step, essential for containerized environments.Database Management
Scripts for generating Prisma client, getting database schemas, and running migrations. The
db:getschemascript combines schemas from a shared package.Development & Debugging
Scripts for running the application in development mode, with watch functionality, and for debugging. The
devscript usesconcurrentlyto run both the NestJS API and Trigger.dev services simultaneously.Testing
A comprehensive set of scripts for running unit, integration, and end-to-end tests, including coverage reports and debugging options.
Code Quality
Scripts for formatting code with Prettier and linting with ESLint to maintain consistent code style and identify potential issues.
Deployment
A specific script for deploying Trigger.dev workflows.
| Script Name | Command | Description | | :-------------------- | :---