Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
azure-functions-decorators-typescript
Advanced tools
Framework for Azure Functions Typescript Decorators
Branch | Support level | Node.js Versions |
---|---|---|
main | Preview | 18 (preview) |
npm install azure-functions-decorators-typescript
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!
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:
"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.[3.15.0, 4.0.0]
in your host.json
file.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.You can now define your functions using TypeScript decorators! Below are a few examples:
Default | Decorators! |
---|---|
|
|
Default | Decorators! |
---|---|
|
|
Default | Decorators! |
---|---|
|
|
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 | ❌ |
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;
FAQs
Framework for Azure Functions Typescript Decorators
We found that azure-functions-decorators-typescript demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.