Appearance
API Import Aliases
This workflow defines the canonical import style for apps/api.
Scope
- Aliases are internal to
apps/apionly. - Other monorepo apps/packages must not import API internals through
@api/*.
Supported Aliases
@api/core/*->apps/api/src/core/*@api/shared/*->apps/api/src/shared/*@api/modules/*->apps/api/src/modules/*@api/*->apps/api/src/*
Usage Rules
- Prefer aliases for cross-boundary imports:
- module ->
core - module ->
shared - module -> another module
- module ->
- Keep short local relatives for nearby files inside the same module subtree.
- Do not introduce deep
../../../../chains when an alias can represent intent.
Examples
ts
import { PublicRoute } from '@api/core/decorators/public-route.decorator';
import { AppConfigService } from '@api/shared/infrastructure/envs/app-config.service';
import { UserRegisteredEvent } from '@api/modules/identity/domain/events/user-registered.event';Runtime and Tooling Notes
- Build:
apps/apirunsnest buildand thentsc-aliasso production JS indistresolves aliases with plain Node. - Jest:
moduleNameMappermaps@api/*to<rootDir>/*(withrootDir: "src"). - TypeORM CLI migrations: path resolution works through
ts-node+tsconfig-paths/register.