npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

azure-functions-decorators-typescript

v1.0.0-alpha.2

Published

Framework for Azure Functions Typescript Decorators

Readme

Azure Functions TypeScript Decorators

|Branch|Support level|Node.js Versions| |---|---|---| |main|Preview|18 (preview)|

Install

npm install azure-functions-decorators-typescript

Usage

This library contains definitions for TypeScript decorators that makes registering and defining Azure Functions easier than ever! Building upon the new Node.js programming model (v4 of @azure/functions), this library extends that framework to allow users to register functions using decorators!

This library is just a personal hackathon project, so there is no clear plan on when or if this may become officially public. That being said, you can try out the limited functionality that exists now and give your feedback for improvements!

Prerequisites

  • Node.js v18+
  • TypeScript v4+

Setup

For a ready-to-run app, clone this repo: https://github.com/hossam-nasr/func-node-decorators-prototype and fpllow the instructions in the README.

If you are creating your own app, the instructions you need to follow to run an app with v4 of @azure/functions still apply to this library. See more detailed information here: https://github.com/Azure/azure-functions-nodejs-library/wiki/Azure-Functions-Node.js-Framework-v4. Namely, take note of these important points:

  1. Make sure you reference this preview npm package in your package.json: "func-cli-nodejs-v4": "4.0.4764". This is a preview build of the func CLI that contains tooling support for running the new framework, which this library relies on.
  2. If you are using an extension bundle, you must be on version 3.15.0 or greater, e.g. by specifying [3.15.0, 4.0.0] in your host.json file.
  3. You must set the AzureWebJobsStorage setting to a valid value in your local.settings.json file, either to a connection string of a valid Azure storagea account, or to UseDevelopmentStorage=true and use the local storage emulator.

Define your functions using decorators!

You can now define your functions using TypeScript decorators! Below are a few examples:

Simple HTTP trigger function:

src/HttpTrigger1/index.ts:

module.exports = async function(context, req) {
    context.log("HTTP function processed request");

    const name = req.query.name 
        || req.body 
        || 'world';

    context.res = {
        body: `Hello, ${name}!`
    };
};

src/HttpTrigger1/function.json:

{
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
        "get",
        "post"
      ]
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    }
  ]
}

src/index.ts:

import { 
    azureFunction, 
    http 
} from 'azure-functions-decorators-typescript'

class FunctionApp {
    @azureFunction()
    async httpTrigger1(context, @http() request) {
        context.log("Http function processed request");

        const name = request.query.get('name') 
            || (await request.text()) 
            || 'world';

        return {
            body: `Hello, ${name}`,
        };
    }
}

export default FunctionApp

Setting an extra blob input:

src/MyFunction/index.ts:

module.exports = async function(context, req) {
    context.log("HTTP function processed request");

    const name = context.bindings.blobInput;

    context.res = {
        body: `Hello, ${name}!`
    };
};

src/MyFunction/function.json:

{
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
        "get",
        "post"
      ]
    },
    {
      "type": "blob",
      "name": "blobInput",
      "direction": "in",
      "path": "helloworld/{name}"
      "connection": "storage_conn"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    }
  ]
}

src/index.ts:

import { 
    azureFunction, 
    http,
    blobInput
} from 'azure-functions-decorators-typescript'

class FunctionApp {
    @azureFunction()
    async httpTrigger1(
        context, 
        @http() request, 
        @blobInput('helloworld/{name}', 'storage_conn') blobInput
    ) {
        context.log("Http function processed request");

        const name = blobInput;

        return {
            body: `Hello, ${name}`,
        };
    }
}

export default FunctionApp

Setting an extra queue output:

src/MyFunction/index.ts:

module.exports = async function(context, req) {
    context.log("HTTP function processed request");

    const name = req.query.name 
        || req.body 
        || 'world';
        
    context.bindings.queueOut = name;

    context.res = {
        body: `Hello, ${name}!`
    };
};

src/MyFunction/function.json:

{
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
        "get",
        "post"
      ]
    },
    {
      "type": "queue",
      "name": "queueOut",
      "direction": "output",
      "queueName": "helloworld"
      "connection": "storage_conn"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    }
  ]
}

src/index.ts:

import { 
    azureFunction, 
    http,
    queueOutput
} from 'azure-functions-decorators-typescript'

class FunctionApp {
    @azureFunction()
    async httpTrigger1(
        context, 
        @http() request, 
        @queueOutput('helloworld', 'storage_conn') queueOut
    ) {
        context.log("Http function processed request");

        const name = request.query.get('name') 
            || (await request.text()) 
            || 'world';
        
        queueOut.set(name);

        return {
            body: `Hello, ${name}`,
        };
    }
}

export default FunctionApp

Supported triggers and bindings

As this is just a hackathon project at the moment, most triggers and bindings do not have their own custom decorators. Below is a list of the available triggers and bindings and their supported state. This list will be updated when/if more triggers and bindings are added. The list of all available triggers and bindings was retrieved from the Microsoft docs here

|Type|Trigger|Input|Output| |---|---|---|---| HTTP | ✅ | | ❌ Timer | ✅ | | | Storage blob | ✅ | ✅ | ✅ Storage queue | ✅ | | ✅ CosmosDB | ✅ | ❌ | ❌ Azure SQL | | ❌ | ❌ Dapr | ❌ | ❌ | ❌ Event Grid | ❌ | | ❌ Event Hubs | ❌ | | ❌ IoT Hub | ❌ | | Kafka | ❌ | | ❌ Mobile Apps | | ❌ | ❌ Notification Hubs | | | ❌ RabbitMQ | ❌ | | ❌ SendGrid | | | ❌ Service Bus | ❌ | | ❌ SignalR | ❌ | ❌ | ❌ Table storage | | ❌ | ❌ Twilio | | | ❌

Generic triggers, inputs, and outputs

Even for the triggers and bindings that are not explicitly supported in this library, they can still be registered using the generic @trigger, @input, @output and @returns decorators. Below is an example of a function that uses all 4 of these to illustrate how they work:

import { HttpResponse, InvocationContext, output as AzFuncOutput } from '@azure/functions';
import { azureFunction, input, output, returns, trigger } from 'azure-functions-decorators-typescript';

class FunctionApp {
    @azureFunction()
    @returns(AzFuncOutput.http({}))
    async copyBlob1(
        context: InvocationContext,
        @trigger('queueTrigger', { queueName: 'copyblobqueue', connection: 'storage_APPSETTING' }) queueItem: unknown,
        @input('blob', { path: 'helloworld/{queueTrigger}', connection: 'storage_APPSETTING' }) blobInput: unknown,
        @output('blob', { path: 'helloworld/{queueTrigger}-copy', connection: 'storage_APPSETTING' }) blobOutput: any
    ): Promise<HttpResponse> {
        context.log('Storage queue function processes work item: ', queueItem);

        blobOutput.set(blobInput);

        return {
            body: `Successfully copied ${queueItem}`,
        };
    }
}

export default FunctionApp;