1.0.5 • Published 1 year ago
slazy v1.0.5
Slazy
Slazy is a library for NestJS that allows you to easily send Slack messages using decorators when an error occurs in your API.
Installation
yarn add slazy
# or
npm install slazyUsage
Get your Slack webhook URL from the Slack API (Incoming Webhooks).
In your
*.module.tsfile, addSlazyModuleto the imports:
import { SlazyModule } from 'slazy';
@Module({
imports: [
SlazyModule.forFeature({ slackWebhookUrl: 'your slack webhook URL' }),
// other imports
],
// other module properties
})
export class YourModule {}- In your controller, use the
@Slazydecorator to specify when to send a Slack message:
import { Slazy } from 'slazy';
@Controller('your-route')
export class YourController {
@Get()
@Slazy({ statusCode: 4xx | 5xx, message: 'message you want to send to Slack channel' })
yourMethod() {
// your method implementation
}
}Replace 4xx | 5xx with the specific status codes you want to handle and customize the message as needed.