Socket
Book a DemoInstallSign in
Socket

nestjs-azure-func-trigger

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestjs-azure-func-trigger

Nest - modern, fast, powerful node.js web framework (@azure-func-trigger

latest
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads Travis Linux Coverage Discord Backers on Open Collective Sponsors on Open Collective

Description

Azure Functions Trigger module for Nest.

This package works well together with @nestjs/azure-func-http which provides azure function http triggers for Nest.

This package provides a more general way to use any kind of azure function trigger ( timed, event bus, ...) for triggering methods of your Nest services.

Installation

Using npm:

$ npm install nestjs-azure-func-trigger

Tutorial

Adding a trigger is done by creating a new Azure Function in the app folder and then providing the createApp to the AzureFunctionTriggerAdapter.

import { InvocationContext } from '@azure/functions';
import { AzureFunctionTriggerAdapter } from 'nestjs-azure-func-trigger';
import { createApp } from '../src/main';

export default async function(context: InvocationContext): Promise<void> {
  return AzureFunctionTriggerAdapter.handle(createApp, context);
}

When the function is triggered it starts up and calls every service method that is annotated with AzureFunctionTrigger decorator that specified this function by the name parameter.

import { Injectable } from '@nestjs/common';

@Injectable()
class ClassWithTrigger {
  @AzureFunctionTrigger('FunctionName')
  public timerWithContext (
    @AzureFunctionContext() context: InvocationContext,
  ) {
    context.log('TimerWithContext', context);
  }
}

A function.json for this case looks like the following. Important is only the name of the function folder which in this case is "FunctionName"

{
  "bindings": [
    {
      "name": "trigger",
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "0 0,30 7-23 * * *"
    }
  ],
  "scriptFile": "../dist/FunctionName/index.js"
}

FAQs

Package last updated on 09 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts