Type-safe Serverless Library for Azure Functions and friends
🚧 Alpha Stage: Internal Use Only 🚧
Please note that Nammatham v2 is currently in its Alpha stage and is intended for internal use only. As we actively develop and refine the platform, be aware that the API may undergo frequent changes.
Note: Nammatham v1 is currently in maintenance mode. no new features are actively being developed
Version | Status | Azure Functions Node.js | Branch | Build Status |
---|---|---|---|---|
v1.x | Maintenance | v3.x | v1.x | |
v2.x | Alpha | v4.x | main | Tracking v2 Roadmap |
Nammatham (นามธรรม in Thai, pronounced /naam ma tham/
, means abstract in Thai) is Azure Function Nodejs.
You can see examples or follow the minimal app getting started below:
import { AzureFunctionsAdapter } from "@nammatham/azure-functions";
import { initNammatham } from "@nammatham/core";
import { expressPlugin } from "@nammatham/express";
const n = initNammatham.create(new AzureFunctionsAdapter());
const func = n.func;
const app = n.app;
const helloFunction = func
.httpGet('hello', {
route: 'hello-world',
})
.handler(async (request, ctx) => {
ctx.context.log('HTTP trigger function processed a request.');
ctx.context.debug(`Http function processed request for url "${request.url}"`);
const name = request.query.get('name') || (await request.text()) || 'world';
return { body: `Hello, ${name}!` };
});
app.addFunctions(helloFunction);
app.register(expressPlugin());
app.start();
Then edit package.json
like this;
{
"main": "dist/src/main.js",
"scripts": {
"dev": "cross-env NAMMATHAM_ENV=development tsx watch src/main.ts",
"start": "tsc && func start"
}
}
Run Dev Server on locally, (For dev server use tsx watch
for reloading run dev server using express
)
npm run dev
Run Azure Functions on locally (Using Official Azure Functions Node.js)
npm start
- core, Nammatham Core package for initializing Nammatham App
- azure-functions, Azure Functions Adapter for Nammatham
- express, Express Plugin for run server. Nammatham itself doesn't contain any server, enabling this plugin to provide better DX than the original server e.g. Azure Functions Runtime
- trpc-azure-functions, provide tRPC Plugin for Azure Functions, inclduing express server for local testing.
Empowering TypeScript on Azure Functions with Nammatham, Azure Open Source Day @ Microsoft Thailand, 25 Mar 2023 (Thai speech, subtitle will added later)
- Slides: https://docs.google.com/presentation/d/1WUIXaUxXaiixZ2bgGCfx-f4Gdrmjl4RfbwKaEfAC6t4/edit?usp=sharing
- Azure Functions .NET
- inversify-express-utils - We use inversify as a Dependency Injection Tool.
- Nestjs
- typestack/routing-controllers
- azure-middleware - Azure Functions Middleware Libray
- Thada Wangthammang, Software Engineer, Thailand