azure-functions-decorator
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

azure-functions-decorator

Generate azure function's configuration files (function.config) with typescript decorators.

How to Install

$ npm install --save-dev azure-functions-decorator

How to Use

To generate function.json configuration files, you need to write resource endpoint as a class, and decorate method with @HttpFunction decorator something like below.

import 'reflect-metadata';
import { Context, HttpResponse, HttpStatusCode } from 'azure-functions-ts-essentials';
import { HttpFunction } from 'azure-functions-decorator';

class Hello {

  @HttpFunction({ route: 'v1/hello', scriptFile: __filename })
  async run(): Promise<HttpResponse> {
    return {
      status: HttpStatusCode.OK,
      body: 'Hello World'
    };
  }
}

Transpile above typescript codes into javascrpt, and then run azure-functions-docrator command.

$ npx azure-functions-decorator --source lib/functions/*.js --out lib/

Notice

This library uses typescript decorator, so you need to enable experimentalDecorators and emitDecoratorMetadata.

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

And you might need to install reflect-metadata.

Package Sidebar

Install

npm i azure-functions-decorator

Weekly Downloads

1

Version

0.1.3

License

MIT

Unpacked Size

11 kB

Total Files

14

Last publish

Collaborators

  • daylilyfield