-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(examples): add azure-functions inversify class examples
- Loading branch information
1 parent
18801b7
commit 9cf2273
Showing
12 changed files
with
121 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# @examples/azure-functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"version": "2.0", | ||
"logging": { | ||
"applicationInsights": { | ||
"samplingSettings": { | ||
"isEnabled": true, | ||
"excludedTypes": "Request" | ||
} | ||
} | ||
}, | ||
"extensionBundle": { | ||
"id": "Microsoft.Azure.Functions.ExtensionBundle", | ||
"version": "[3.15.0, 4.0.0)" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"IsEncrypted": false, | ||
"Values": { | ||
"FUNCTIONS_WORKER_RUNTIME": "node", | ||
"AzureWebJobsFeatureFlags": "EnableWorkerIndexing", | ||
"AzureWebJobsStorage": "UseDevelopmentStorage=true" | ||
}, | ||
"ConnectionStrings": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "@examples/azure-functions-with-inversify", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "dist/src/main.js", | ||
"scripts": { | ||
"build": "tsc", | ||
"lint": "tsc --noEmit", | ||
"start": "tsc && func start", | ||
"dev": "cross-env NODE_ENV=development tsx watch src/main.ts" | ||
}, | ||
"author": "Thada Wangthammang", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@azure/functions": "^4.1.0", | ||
"@di-extra/inversify": "^0.2.0", | ||
"nammatham": "2.0.0-alpha.13", | ||
"inversify": "^6.0.2", | ||
"reflect-metadata": "^0.2.1" | ||
}, | ||
"devDependencies": { | ||
"cross-env": "^7.0.3", | ||
"npm-run-all": "^4.1.5", | ||
"tsx": "^4.7.0", | ||
"typescript": "^5.0.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Container } from 'inversify'; | ||
import { DataService } from './services/data.service'; | ||
|
||
export const container = new Container(); | ||
container.bind<DataService>(DataService).toSelf(); | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'reflect-metadata'; | ||
import { expressPlugin } from 'nammatham'; | ||
import hello from './functions/hello'; | ||
import { app } from './nammatham'; | ||
|
||
app.addFunctions(hello); | ||
|
||
const dev =process.env.NODE_ENV === 'development'; | ||
app.register(expressPlugin({ dev })); | ||
app.start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { initNammatham } from 'nammatham'; | ||
|
||
const n = initNammatham.create(); | ||
n.func; | ||
// ^? | ||
export const func = n.func; | ||
export const app = n.app; |
9 changes: 9 additions & 0 deletions
9
examples/azure-functions-with-context/src/services/data.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { injectable } from 'inversify'; | ||
|
||
@injectable() | ||
export class DataService { | ||
|
||
public getData() { | ||
return `Data from DataService`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es6", | ||
"outDir": "dist", | ||
"rootDir": ".", | ||
"sourceMap": true, | ||
"strict": true, | ||
"esModuleInterop": true, | ||
"experimentalDecorators": true, | ||
}, | ||
"exclude": ["node_modules", "**/*.test.ts"] | ||
} |
18 changes: 18 additions & 0 deletions
18
examples/azure-functions-with-inversify/src/controllers/home.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { func } from '../nammatham'; | ||
import { DataService } from '../services/data.service'; | ||
|
||
export class HomeController { | ||
constructor(public dataService: DataService) {} | ||
|
||
hello = func | ||
.httpGet('hello', { | ||
route: 'hello-world', | ||
}) | ||
.handler(async c => { | ||
c.context.log('HTTP trigger function processed a request.'); | ||
|
||
return c.json({ | ||
data: 'hello world' + this.dataService.getData(), | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import 'reflect-metadata'; | ||
import { expressPlugin } from 'nammatham'; | ||
import hello from './functions/hello'; | ||
import { HomeController } from './controllers/home.controller'; | ||
import { app } from './nammatham'; | ||
import { container } from './container'; | ||
import { DataService } from './services/data.service'; | ||
|
||
app.addFunctions(hello); | ||
const homeController = new HomeController(container.get(DataService)); | ||
app.addFunctions(homeController.hello); | ||
|
||
const dev =process.env.NODE_ENV === 'development'; | ||
const dev = process.env.NODE_ENV === 'development'; | ||
app.register(expressPlugin({ dev })); | ||
app.start(); |