©️
Cross api
En-US
En-US
  • Introduction
  • Compatibility
  • Extensions
  • Usage
    • Tools
      • Config
      • ListProvider
      • Language
      • Help
    • Structure
      • MakeApi
      • MakeModule
      • MakeProvider
      • Revert
  • Structure
    • Root
    • Src
    • @Types
    • Assets
    • Config
    • Dtos
    • Jobs
    • Keys
    • Middlewares
    • Modules
    • Routes
    • Shared
    • Utils
  • Services
    • Transactions
    • Exists
    • FindBy
    • FindIn
    • FindLike
    • FindAll
    • Create
    • CreateMany
    • Update
    • UpdateMany
    • Delete
    • DeleteMany
    • SoftDelete
    • SoftDeleteMany
  • Mappers
    • CloneAttribute
    • UpdateAttribute
    • PatchAttribute
    • UpdateString
    • PatchString
    • InsertAttribute
  • Providers
    • Cache
    • Crypto
    • Hash
    • Lead
    • MailTemplate
    • Mail
    • Queue
    • Notification
    • Storage
Powered by GitBook
On this page

Was this helpful?

Providers

Providers are implementations of services that assist in the business rules of your project. They can contain one or more implementations, you decide which one to use, to switch the key in .env.

To use a provider in your business logic, simply inject your token with tsyinge:

import { IProvider } from '@shared/container/providers/Provider/models/IProvider';
import { injectable, inject } from 'tsyringe';

@injectable()
export class ExampleService {
  public constructor(
    @inject('Provider')
    private readonly provider: IProvider,
  ) {}

  public async execute(): Promise<void> {
    try {
      this.provider.doSomething();
    } catch (error: unknown) {
      throw error;
    }
  }
}
PreviousInsertAttributeNextCache

Last updated 6 months ago

Was this helpful?