Skip to content

Core Config

Core configuration options are defined in apps/backend/src/infrastructure/core/core.config.ts.

Database Transaction Settings

OptionDefaultDescription
transactionMaxAttempts5Max retries for serialization/deadlock errors
baseDelayBetweenTransactionRetriesMillis50Base delay between retry attempts

Performance Thresholds

Thresholds for slow operation detection. When exceeded, the corresponding Core Hook fires.

OptionDefaultDescription
repoDurationThresholdMillis50Repo slow threshold
domainServiceDurationThresholdMillis100Domain service slow threshold
useCaseDurationThresholdMillis200Use-case slow threshold

Each use-case, repo, or domain service can override getDurationThresholdMillis() for a custom threshold:

typescript
protected override getDurationThresholdMillis(): number {
    return 500; // Custom threshold for this operation
}

Request Parsing

JSON Body Parser

OptionDefaultDescription
jsonBodyParser.maxBodySizeBytes200 KBMax request body size

Query Params Parser

OptionDefaultDescription
queryParamsParser.parameterLimit50Max number of parameters
queryParamsParser.depthLimit5Max nesting depth
queryParamsParser.arrayLimit10Max array length

File Upload

OptionDefaultDescription
fileUpload.maxFieldValueSizeBytes1 KBMax field value size
fileUpload.maxFieldNameSizeBytes100Max field name size

Environment

OptionDescription
isProductiontrue when NODE_ENV === 'production'
isTestingtrue when NODE_ENV === 'test'

API Sync

OptionDescription
syncApitrue when SYNC_API === 'true' - triggers OpenAPI spec and client generation

Generator Options

Options that affect what the CLI generates when you create endpoints, repos, etc. Set these to true if you want the generated code to include placeholder fields you'll fill in later.

Route Config

OptionDefaultDescription
generateMiddlewaresfalseInclude middlewares block in generated route config
generateSummaryfalseGenerate OpenAPI summary
generateDescriptionfalseGenerate OpenAPI description
generateExtraTagsfalseGenerate extra tags

With all options enabled, a generated route config looks like:

typescript
export const createCustomerRouteConfig = defineRouteConfig({
    method: 'post',
    path: customersPath,
    middlewares: {},      // generateMiddlewares: true
    summary: '',          // generateSummary: true
    description: '',      // generateDescription: true
    extraTags: [],        // generateExtraTags: true
});

With defaults (all false), these fields are omitted.

Responses

OptionDefaultDescription
generateDescriptionfalseGenerate response descriptions

When enabled, response definitions include a description placeholder:

typescript
export const createCustomerResponses = {
    customerCreated: {
        statusCode: 201,
        schema: createCustomerResponseZodSchema,
        description: '',  // generateDescription: true
    },
};

Repo

OptionDefaultDescription
generateUniqueKeyViolationErrorMaptrueGenerate unique constraint error mapping
generateForeignKeyViolationErrorMapfalseGenerate foreign key error mapping

When enabled, repos include placeholder methods for mapping database constraint errors to your error codes:

typescript
// generateUniqueKeyViolationErrorMap: true
protected override getUniqueKeyViolationErrorMap() {
    return {
        // 'constraint_name': ErrorCodes['YourErrorCode'],
    };
}

// generateForeignKeyViolationErrorMap: true
protected override getForeignKeyViolationErrorMap() {
    return {
        // 'constraint_name': ErrorCodes['YourErrorCode'],
    };
}