-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[3.0.0] Upgraded to programming model v4.
- Loading branch information
Showing
33 changed files
with
4,615 additions
and
2,213 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
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 @@ | ||
*.js.map | ||
*.ts | ||
.git* | ||
.vscode | ||
__azurite_db*__.json | ||
__blobstorage__ | ||
__queuestorage__ | ||
local.settings.json | ||
test | ||
tsconfig.json |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,17 @@ | ||
import { PostInvocationContext, PreInvocationContext, app } from '@azure/functions'; | ||
|
||
app.hook.preInvocation((context: PreInvocationContext) => { | ||
if (context.invocationContext.options.trigger.type === 'httpTrigger') { | ||
context.invocationContext.log( | ||
`preInvocation hook executed for http function ${context.invocationContext.functionName}`, | ||
); | ||
} | ||
}); | ||
|
||
app.hook.postInvocation((context: PostInvocationContext) => { | ||
if (context.invocationContext.options.trigger.type === 'httpTrigger') { | ||
context.invocationContext.log( | ||
`postInvocation hook executed for http function ${context.invocationContext.functionName}`, | ||
); | ||
} | ||
}); |
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 @@ | ||
import { HttpRequest, InvocationContext, app } from '@azure/functions'; | ||
|
||
import { middleware } from '../../src'; | ||
import headerAuthentication from '../../src/headerAuthentication'; | ||
|
||
export const handler = async (request: HttpRequest, context: InvocationContext) => { | ||
context.info('Function called'); | ||
return { status: 204 }; | ||
}; | ||
app.http('test-header-authentication-function', { | ||
methods: ['POST'], | ||
authLevel: 'anonymous', | ||
route: 'authentication', | ||
handler: middleware([headerAuthentication()], handler, []), | ||
}); |
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 @@ | ||
import { HttpHandler, HttpRequestParams, app } from '@azure/functions'; | ||
|
||
import { middleware } from '../../src'; | ||
import authorization from '../../src/jwtAuthorization'; | ||
|
||
export const handler: HttpHandler = async (req, context) => { | ||
context.log('Function called'); | ||
return { status: 204 }; | ||
}; | ||
|
||
app.http('test-jwt-authorization-function', { | ||
methods: ['POST'], | ||
authLevel: 'anonymous', | ||
route: 'authorization/{id}', | ||
handler: middleware<HttpHandler>( | ||
[ | ||
authorization([ | ||
{ | ||
parameterExtractor: (parameters: HttpRequestParams) => parameters.id, | ||
jwtExtractor: (jwt: { userId: string }) => jwt.userId, | ||
}, | ||
]), | ||
], | ||
handler, | ||
[], | ||
), | ||
}); |
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,29 @@ | ||
import { HttpHandler, app } from '@azure/functions'; | ||
import * as Joi from 'joi'; | ||
import { ObjectSchema } from 'joi'; | ||
|
||
import { PostExecutionFunction, middleware } from '../../src'; | ||
import { requestValidation as validation } from '../../src/validation'; | ||
|
||
const schema: ObjectSchema = Joi.object({ | ||
name: Joi.string().min(3).max(30).required(), | ||
}).required(); | ||
|
||
export const functionHandler: HttpHandler = async (req, context) => { | ||
context.info('Function called'); | ||
const body = (await req.json()) as { name: string }; | ||
|
||
return { status: 200, jsonBody: { text: `Hallo ${body.name}` } }; | ||
}; | ||
|
||
const postFunction: PostExecutionFunction = (_, context) => { | ||
context.log('Called after function'); | ||
return; | ||
}; | ||
|
||
app.http('test-validation-function', { | ||
methods: ['POST'], | ||
authLevel: 'anonymous', | ||
route: 'validation', | ||
handler: middleware<HttpHandler>([validation(schema, { printRequest: true })], functionHandler, [postFunction]), | ||
}); |
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
example/test-header-authentication-function/test-header-authentication-function.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
example/test-jwt-authorization-function/test-jwt-authorization-function.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.