NestJS · Providers · Junior · Live Coding
What is a custom injection token and why use string/symbol tokens?
Short Interview Answer
Tokens identify providers when you inject interfaces or multiple alike dependencies.
Detailed Explanation
TypeScript interfaces disappear at runtime — tokens preserve DI identity. Use symbols/consts to avoid collisions.
Example
export const PAYMENTS = Symbol('PAYMENTS');
@Inject(PAYMENTS) private payments: PaymentsPort