-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PoC Azure/Functions v4 fit with Nammatham APIs (Functional Approach & Type-safe) #82
Comments
PoC Branch: |
My PoC and tested with the official v4 azure functions lib result is in branch: /**
* Nammatham v2 - Proof of concept: Type-safe & Functional Style
*
* Github Issue: https://github.com/thaitype/nammatham/issues/82
* Implementation: https://github.com/thaitype/nammatham/blob/poc-func-v4.functional-type-safe/examples/with-functional/src/functions/copyBlob1.ts
*/
import { initNammatham } from '@nammatham/core';
const nmt = initNammatham.create();
nmt
.httpGet('CopyBlob', {
authLevel: 'anonymous',
})
.addInput(
'blobInput',
nmt.input.storageBlob({
connection: 'AzureWebJobsStorage',
path: 'demo-input/xxx.txt',
})
)
.addOutput(
'blobOutput',
nmt.output.storageBlob({
connection: 'AzureWebJobsStorage',
path: 'demo-output/xxx-{rand-guid}.txt',
})
)
.handler((request, context) => {
context.log('function processed work item:', request);
const blobInputValue = context.inputs.blobInput.get();
context.outputs.blobOutput.set(blobInputValue);
return {
body: `Hello ${blobInputValue}`,
};
}); |
The PoC implements As you can see in the alpha release of v2, you can see the example to use import { input } from '@azure/functions';
import { func } from '../nammatham';
const blobInput = input.storageBlob({
connection: 'AzureWebJobsStorage',
path: 'demo-input/xxx.txt',
});
const blobOutput = input.storageBlob({
connection: 'AzureWebJobsStorage',
path: 'demo-output/xxx-{rand-guid}.txt',
});
export default func
.httpGet('CopyBlob', {
authLevel: 'anonymous',
extraInputs: [blobInput],
extraOutputs: [blobOutput],
})
.handler((request, ctx) => {
ctx.context.log('function processed work item:', request);
const blobInputValue = ctx.context.extraInputs.get(blobOutput);
ctx.context.extraOutputs.set(blobOutput, blobInputValue);
return {
body: `Hello ${blobInputValue}`,
};
}); This issue is quite good to PoC how make Nammatham has more fluent APIs, however, this will mark as v2-experiment instead, it can be considered to implement in the future release. So, this issue can be close now. |
From my research, TypeScript 5.0 Decorator support more type-safe decorator, however, most popular typeScript Dependency Injection currently support below TypeScript 5.0 Decorator which must provide following
tsconfig.json
With TypeScript 5.0 Decorator can evict both
tsconfig.json
.Currently issues that most popular is already stuck with TypeScript Decorator below version 5.0:
Another issues about Inversify currently find the new maintainer
The text was updated successfully, but these errors were encountered: