UNPKG

meocord

Version:

Decorator-based Discord bot framework built on discord.js. Brings NestJS-style controllers, dependency injection, guards, and testing utilities to bot development — with a full CLI and TypeScript-first design.

30 lines (27 loc) 761 B
import 'reflect-metadata'; import { injectable } from 'inversify'; import { MetadataKey } from '../enum/metadata-key.enum.js'; /** * `@Service()` decorator to mark a class as a service that can be injected into controllers or used as standalone services. * * @example * ```typescript * @Service() * class MyService { * constructor(private anotherService: AnotherService) {} * * doSomething() { * this.anotherService.alsoDoSomething() * console.log('Hello, World!') * } * } * ``` * @returns A decorator function to apply to the class. */ function Service() { return function(target) { if (!Reflect.hasMetadata(MetadataKey.Injectable, target)) { injectable()(target); } }; } export { Service };