@nattyjs/azure-functions 0.0.1-beta.0 → 0.0.1-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +145 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.mjs +142 -0
- package/package.json +6 -3
- package/CHANGELOG.md +0 -17
- package/build.config.ts +0 -14
- package/functions/get-request-body.ts +0 -14
- package/functions/get-response-body.ts +0 -17
- package/functions/parse-cookies.ts +0 -13
- package/functions/request-handler.ts +0 -18
- package/index.ts +0 -2
- package/module/azure-function-module.ts +0 -78
- package/module/azure-function-test-module.ts +0 -13
- package/tsconfig.build.json +0 -10
- package/tsconfig.json +0 -13
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const functions = require('@azure/functions');
|
|
4
|
+
const core = require('@nattyjs/core');
|
|
5
|
+
const common = require('@nattyjs/common');
|
|
6
|
+
|
|
7
|
+
async function getRequestBodyInfo(request) {
|
|
8
|
+
const contentType = request.headers.get("content-type");
|
|
9
|
+
const bodyInfo = {};
|
|
10
|
+
if (request.method !== common.GET)
|
|
11
|
+
switch (contentType) {
|
|
12
|
+
case "application/json":
|
|
13
|
+
bodyInfo.json = await request.json();
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
return bodyInfo;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getResponse(responseInfo) {
|
|
20
|
+
let response = {};
|
|
21
|
+
if (responseInfo.body) {
|
|
22
|
+
if (responseInfo.body.json) {
|
|
23
|
+
response = {
|
|
24
|
+
jsonBody: responseInfo.body.json
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
response.headers = responseInfo.headers;
|
|
29
|
+
response.cookies = responseInfo.cookies;
|
|
30
|
+
response.status = responseInfo.status;
|
|
31
|
+
return response;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function parseCookies(value) {
|
|
35
|
+
const jsonCookies = new Array();
|
|
36
|
+
if (value) {
|
|
37
|
+
const cookies = value.split(";");
|
|
38
|
+
for (const cookie of cookies) {
|
|
39
|
+
const splitCookie = cookie.split("=");
|
|
40
|
+
jsonCookies.push({ name: splitCookie[0].trim(), value: splitCookie[1].trim() });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return jsonCookies;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function requestHandler(request, context) {
|
|
47
|
+
const httpHandler = new core.HttpHandler();
|
|
48
|
+
const httpContext = new core.HttpContext(
|
|
49
|
+
{
|
|
50
|
+
url: request.url,
|
|
51
|
+
method: request.method,
|
|
52
|
+
body: await getRequestBodyInfo(request),
|
|
53
|
+
headers: request.headers,
|
|
54
|
+
cookies: parseCookies(request.headers.get("cookie"))
|
|
55
|
+
},
|
|
56
|
+
context
|
|
57
|
+
);
|
|
58
|
+
return httpHandler.processRequest(httpContext).then((httpResponse) => {
|
|
59
|
+
return getResponse(httpResponse);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const AzureFunctionModule = {
|
|
64
|
+
init(config) {
|
|
65
|
+
const application = functions.app;
|
|
66
|
+
application.http("natty", {
|
|
67
|
+
route: `${common.commonContainer.nattyConfig.api.rootPath}/{*route}`,
|
|
68
|
+
methods: ["GET", "POST", "PUT", "DELETE"],
|
|
69
|
+
authLevel: "anonymous",
|
|
70
|
+
handler: requestHandler
|
|
71
|
+
});
|
|
72
|
+
application.http("nttyhtml", {
|
|
73
|
+
route: "requestinfo",
|
|
74
|
+
methods: ["GET"],
|
|
75
|
+
authLevel: "anonymous",
|
|
76
|
+
handler: (request, context) => {
|
|
77
|
+
return {
|
|
78
|
+
body: `
|
|
79
|
+
<html>
|
|
80
|
+
<head>
|
|
81
|
+
</head>
|
|
82
|
+
<body>
|
|
83
|
+
<script type="text/javascript">
|
|
84
|
+
async function onClick(){
|
|
85
|
+
const method = document.getElementById("method").value;
|
|
86
|
+
const url = document.getElementById("url").value;
|
|
87
|
+
const body = document.getElementById("body").value;
|
|
88
|
+
const headers = document.getElementById("headers").value || '{}';
|
|
89
|
+
if(method == "get"){
|
|
90
|
+
const response = await fetch(url,{headers:JSON.parse(headers)});
|
|
91
|
+
const result = await response.json();
|
|
92
|
+
console.log(result)
|
|
93
|
+
}else{
|
|
94
|
+
const response = await fetch(url, {
|
|
95
|
+
method: method, // *GET, POST, PUT, DELETE, etc.
|
|
96
|
+
headers: {
|
|
97
|
+
...JSON.parse(headers),
|
|
98
|
+
"Content-Type": "application/json",
|
|
99
|
+
// 'Content-Type': 'application/x-www-form-urlencoded',
|
|
100
|
+
},
|
|
101
|
+
body: body, // body data type must match "Content-Type" header
|
|
102
|
+
});
|
|
103
|
+
const result = await response.json();
|
|
104
|
+
console.log(result)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
debugger;
|
|
109
|
+
}
|
|
110
|
+
<\/script>
|
|
111
|
+
<input type="text" id="url"/>
|
|
112
|
+
<select id="method">
|
|
113
|
+
<option value="get">GET</option>
|
|
114
|
+
<option value="post">POST</option>
|
|
115
|
+
<option value="put">PUT</option>
|
|
116
|
+
<option value="delete">DELETE</option>
|
|
117
|
+
</select>
|
|
118
|
+
<textarea id="headers" name="headers" rows="4" cols="50"></textarea>
|
|
119
|
+
<textarea id="body" name="body" rows="4" cols="50">
|
|
120
|
+
</textarea>
|
|
121
|
+
<button onclick="onClick()"/>Submit</button>
|
|
122
|
+
</body>
|
|
123
|
+
</html>
|
|
124
|
+
`,
|
|
125
|
+
headers: {
|
|
126
|
+
"content-type": "text/html"
|
|
127
|
+
},
|
|
128
|
+
status: 200
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const AzureFunctionTestModule = {
|
|
136
|
+
async onRequest(request) {
|
|
137
|
+
if (request.body && request.body.json)
|
|
138
|
+
request.body.string = JSON.stringify(request.body.json);
|
|
139
|
+
const requestObject = new functions.HttpRequest(request);
|
|
140
|
+
return await requestHandler(requestObject, null);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
exports.AzureFunctionModule = AzureFunctionModule;
|
|
145
|
+
exports.AzureFunctionTestModule = AzureFunctionTestModule;
|
package/dist/index.d.ts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { app, HttpRequest } from '@azure/functions';
|
|
2
|
+
import { HttpHandler, HttpContext } from '@nattyjs/core';
|
|
3
|
+
import { GET, commonContainer } from '@nattyjs/common';
|
|
4
|
+
|
|
5
|
+
async function getRequestBodyInfo(request) {
|
|
6
|
+
const contentType = request.headers.get("content-type");
|
|
7
|
+
const bodyInfo = {};
|
|
8
|
+
if (request.method !== GET)
|
|
9
|
+
switch (contentType) {
|
|
10
|
+
case "application/json":
|
|
11
|
+
bodyInfo.json = await request.json();
|
|
12
|
+
break;
|
|
13
|
+
}
|
|
14
|
+
return bodyInfo;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getResponse(responseInfo) {
|
|
18
|
+
let response = {};
|
|
19
|
+
if (responseInfo.body) {
|
|
20
|
+
if (responseInfo.body.json) {
|
|
21
|
+
response = {
|
|
22
|
+
jsonBody: responseInfo.body.json
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
response.headers = responseInfo.headers;
|
|
27
|
+
response.cookies = responseInfo.cookies;
|
|
28
|
+
response.status = responseInfo.status;
|
|
29
|
+
return response;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function parseCookies(value) {
|
|
33
|
+
const jsonCookies = new Array();
|
|
34
|
+
if (value) {
|
|
35
|
+
const cookies = value.split(";");
|
|
36
|
+
for (const cookie of cookies) {
|
|
37
|
+
const splitCookie = cookie.split("=");
|
|
38
|
+
jsonCookies.push({ name: splitCookie[0].trim(), value: splitCookie[1].trim() });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return jsonCookies;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function requestHandler(request, context) {
|
|
45
|
+
const httpHandler = new HttpHandler();
|
|
46
|
+
const httpContext = new HttpContext(
|
|
47
|
+
{
|
|
48
|
+
url: request.url,
|
|
49
|
+
method: request.method,
|
|
50
|
+
body: await getRequestBodyInfo(request),
|
|
51
|
+
headers: request.headers,
|
|
52
|
+
cookies: parseCookies(request.headers.get("cookie"))
|
|
53
|
+
},
|
|
54
|
+
context
|
|
55
|
+
);
|
|
56
|
+
return httpHandler.processRequest(httpContext).then((httpResponse) => {
|
|
57
|
+
return getResponse(httpResponse);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const AzureFunctionModule = {
|
|
62
|
+
init(config) {
|
|
63
|
+
const application = app;
|
|
64
|
+
application.http("natty", {
|
|
65
|
+
route: `${commonContainer.nattyConfig.api.rootPath}/{*route}`,
|
|
66
|
+
methods: ["GET", "POST", "PUT", "DELETE"],
|
|
67
|
+
authLevel: "anonymous",
|
|
68
|
+
handler: requestHandler
|
|
69
|
+
});
|
|
70
|
+
application.http("nttyhtml", {
|
|
71
|
+
route: "requestinfo",
|
|
72
|
+
methods: ["GET"],
|
|
73
|
+
authLevel: "anonymous",
|
|
74
|
+
handler: (request, context) => {
|
|
75
|
+
return {
|
|
76
|
+
body: `
|
|
77
|
+
<html>
|
|
78
|
+
<head>
|
|
79
|
+
</head>
|
|
80
|
+
<body>
|
|
81
|
+
<script type="text/javascript">
|
|
82
|
+
async function onClick(){
|
|
83
|
+
const method = document.getElementById("method").value;
|
|
84
|
+
const url = document.getElementById("url").value;
|
|
85
|
+
const body = document.getElementById("body").value;
|
|
86
|
+
const headers = document.getElementById("headers").value || '{}';
|
|
87
|
+
if(method == "get"){
|
|
88
|
+
const response = await fetch(url,{headers:JSON.parse(headers)});
|
|
89
|
+
const result = await response.json();
|
|
90
|
+
console.log(result)
|
|
91
|
+
}else{
|
|
92
|
+
const response = await fetch(url, {
|
|
93
|
+
method: method, // *GET, POST, PUT, DELETE, etc.
|
|
94
|
+
headers: {
|
|
95
|
+
...JSON.parse(headers),
|
|
96
|
+
"Content-Type": "application/json",
|
|
97
|
+
// 'Content-Type': 'application/x-www-form-urlencoded',
|
|
98
|
+
},
|
|
99
|
+
body: body, // body data type must match "Content-Type" header
|
|
100
|
+
});
|
|
101
|
+
const result = await response.json();
|
|
102
|
+
console.log(result)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
debugger;
|
|
107
|
+
}
|
|
108
|
+
<\/script>
|
|
109
|
+
<input type="text" id="url"/>
|
|
110
|
+
<select id="method">
|
|
111
|
+
<option value="get">GET</option>
|
|
112
|
+
<option value="post">POST</option>
|
|
113
|
+
<option value="put">PUT</option>
|
|
114
|
+
<option value="delete">DELETE</option>
|
|
115
|
+
</select>
|
|
116
|
+
<textarea id="headers" name="headers" rows="4" cols="50"></textarea>
|
|
117
|
+
<textarea id="body" name="body" rows="4" cols="50">
|
|
118
|
+
</textarea>
|
|
119
|
+
<button onclick="onClick()"/>Submit</button>
|
|
120
|
+
</body>
|
|
121
|
+
</html>
|
|
122
|
+
`,
|
|
123
|
+
headers: {
|
|
124
|
+
"content-type": "text/html"
|
|
125
|
+
},
|
|
126
|
+
status: 200
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const AzureFunctionTestModule = {
|
|
134
|
+
async onRequest(request) {
|
|
135
|
+
if (request.body && request.body.json)
|
|
136
|
+
request.body.string = JSON.stringify(request.body.json);
|
|
137
|
+
const requestObject = new HttpRequest(request);
|
|
138
|
+
return await requestHandler(requestObject, null);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export { AzureFunctionModule, AzureFunctionTestModule };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nattyjs/azure-functions",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "ajayojha <ojhaajay@outlook.com>",
|
|
@@ -8,13 +8,16 @@
|
|
|
8
8
|
"module": "./dist/index.mjs",
|
|
9
9
|
"main": "./dist/index.cjs",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
11
14
|
"scripts": {
|
|
12
15
|
"build": "unbuild"
|
|
13
16
|
},
|
|
14
17
|
"dependencies": {
|
|
15
18
|
"@azure/functions": "^4.0.0-alpha.7",
|
|
16
|
-
"@nattyjs/core": "0.0.1-beta.
|
|
17
|
-
"@nattyjs/types": "0.0.1-beta.
|
|
19
|
+
"@nattyjs/core": "0.0.1-beta.10",
|
|
20
|
+
"@nattyjs/types": "0.0.1-beta.10"
|
|
18
21
|
},
|
|
19
22
|
"devDependencies": {
|
|
20
23
|
"@types/node": "20.3.1",
|
package/CHANGELOG.md
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
## <small>0.0.1-beta.0 (2023-08-30)</small>
|
|
2
|
-
|
|
3
|
-
* chore: configure nx workspace ([ca0d4fa](https://github.com/nattyjs/nattyjs/commit/ca0d4fa))
|
|
4
|
-
* chore(core): enhance httpresponse object ([d590e25](https://github.com/nattyjs/nattyjs/commit/d590e25))
|
|
5
|
-
* fix(azure-functions): read request body ([958b1c5](https://github.com/nattyjs/nattyjs/commit/958b1c5))
|
|
6
|
-
* fix(azure-functions): trim cookie name & value ([1ee4170](https://github.com/nattyjs/nattyjs/commit/1ee4170))
|
|
7
|
-
* fix(core): read request headers ([2ba9a59](https://github.com/nattyjs/nattyjs/commit/2ba9a59))
|
|
8
|
-
* feat(core): add cookies prop in http request ([7a9516c](https://github.com/nattyjs/nattyjs/commit/7a9516c))
|
|
9
|
-
* add @nattyjs/entity package library ([c8ef054](https://github.com/nattyjs/nattyjs/commit/c8ef054))
|
|
10
|
-
* adding multiple packages ([4bea772](https://github.com/nattyjs/nattyjs/commit/4bea772))
|
|
11
|
-
* code refactor and exception class add ([5f84606](https://github.com/nattyjs/nattyjs/commit/5f84606))
|
|
12
|
-
* fix(core):centralize http response ([2fd03fb](https://github.com/nattyjs/nattyjs/commit/2fd03fb))
|
|
13
|
-
* refactor code ([51db0df](https://github.com/nattyjs/nattyjs/commit/51db0df))
|
|
14
|
-
* temp push ([4a00779](https://github.com/nattyjs/nattyjs/commit/4a00779))
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
package/build.config.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { defineBuildConfig } from 'unbuild'
|
|
2
|
-
|
|
3
|
-
export default defineBuildConfig({
|
|
4
|
-
declaration: true,
|
|
5
|
-
rollup: {
|
|
6
|
-
inlineDependencies: false,
|
|
7
|
-
emitCJS:true
|
|
8
|
-
},
|
|
9
|
-
entries: [
|
|
10
|
-
'./index'
|
|
11
|
-
],
|
|
12
|
-
externals:['@nattyjs/common','@nattyjs/core',"@nattyjs/types","@azure/functions"]
|
|
13
|
-
|
|
14
|
-
})
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { GET } from "@nattyjs/common";
|
|
2
|
-
import { HttpRequestBodyInfo } from "@nattyjs/types";
|
|
3
|
-
|
|
4
|
-
export async function getRequestBodyInfo(request) {
|
|
5
|
-
const contentType = request.headers.get('content-type');
|
|
6
|
-
const bodyInfo: HttpRequestBodyInfo = {}
|
|
7
|
-
if (request.method !== GET)
|
|
8
|
-
switch (contentType) {
|
|
9
|
-
case "application/json":
|
|
10
|
-
bodyInfo.json = await request.json();
|
|
11
|
-
break;
|
|
12
|
-
}
|
|
13
|
-
return bodyInfo;
|
|
14
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { HttpResponse } from "@nattyjs/core";
|
|
2
|
-
|
|
3
|
-
export function getResponse(responseInfo: HttpResponse) {
|
|
4
|
-
let response:any = {};
|
|
5
|
-
if (responseInfo.body) {
|
|
6
|
-
if (responseInfo.body.json) {
|
|
7
|
-
response = {
|
|
8
|
-
jsonBody: responseInfo.body.json,
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
response.headers = responseInfo.headers;
|
|
13
|
-
response.cookies = responseInfo.cookies;
|
|
14
|
-
response.status = responseInfo.status;
|
|
15
|
-
return response;
|
|
16
|
-
}
|
|
17
|
-
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Cookie } from "@nattyjs/types";
|
|
2
|
-
|
|
3
|
-
export function parseCookies(value: string) {
|
|
4
|
-
const jsonCookies = new Array<Cookie>();
|
|
5
|
-
if (value) {
|
|
6
|
-
const cookies = value.split(";");
|
|
7
|
-
for (const cookie of cookies) {
|
|
8
|
-
const splitCookie = cookie.split('=');
|
|
9
|
-
jsonCookies.push({ name: splitCookie[0].trim(), value: splitCookie[1].trim() })
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return jsonCookies;
|
|
13
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { HttpContext ,HttpHandler, HttpResponse } from "@nattyjs/core";
|
|
2
|
-
import { getRequestBodyInfo } from "./get-request-body";
|
|
3
|
-
import { getResponse } from "./get-response-body";
|
|
4
|
-
import { parseCookies } from "./parse-cookies";
|
|
5
|
-
export async function requestHandler(request, context):Promise<any> {
|
|
6
|
-
const httpHandler = new HttpHandler();
|
|
7
|
-
const httpContext = new HttpContext(
|
|
8
|
-
{
|
|
9
|
-
url: request.url,
|
|
10
|
-
method:request.method,
|
|
11
|
-
body:await getRequestBodyInfo(request),
|
|
12
|
-
headers:request.headers,
|
|
13
|
-
cookies:parseCookies(request.headers.get("cookie"))
|
|
14
|
-
},context)
|
|
15
|
-
return httpHandler.processRequest(httpContext).then(httpResponse=>{
|
|
16
|
-
return getResponse(httpResponse);
|
|
17
|
-
})
|
|
18
|
-
}
|
package/index.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// import { NattyConfig } from "@nattyjs/core";
|
|
2
|
-
import { app } from "@azure/functions"
|
|
3
|
-
|
|
4
|
-
import { requestHandler } from "../functions/request-handler";
|
|
5
|
-
import { commonContainer } from "@nattyjs/common";
|
|
6
|
-
export const AzureFunctionModule: any = {
|
|
7
|
-
init(config: any) {
|
|
8
|
-
const application = app;
|
|
9
|
-
application.http("natty", {
|
|
10
|
-
route: `${commonContainer.nattyConfig.api.rootPath}/{*route}`,
|
|
11
|
-
methods: ["GET", "POST", "PUT", "DELETE"],
|
|
12
|
-
authLevel: 'anonymous',
|
|
13
|
-
handler: requestHandler
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
application.http("nttyhtml", {
|
|
17
|
-
route: "requestinfo",
|
|
18
|
-
methods: ["GET"],
|
|
19
|
-
authLevel: 'anonymous',
|
|
20
|
-
handler: (request: any, context: any) => {
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
body: `
|
|
24
|
-
<html>
|
|
25
|
-
<head>
|
|
26
|
-
</head>
|
|
27
|
-
<body>
|
|
28
|
-
<script type="text/javascript">
|
|
29
|
-
async function onClick(){
|
|
30
|
-
const method = document.getElementById("method").value;
|
|
31
|
-
const url = document.getElementById("url").value;
|
|
32
|
-
const body = document.getElementById("body").value;
|
|
33
|
-
const headers = document.getElementById("headers").value || '{}';
|
|
34
|
-
if(method == "get"){
|
|
35
|
-
const response = await fetch(url,{headers:JSON.parse(headers)});
|
|
36
|
-
const result = await response.json();
|
|
37
|
-
console.log(result)
|
|
38
|
-
}else{
|
|
39
|
-
const response = await fetch(url, {
|
|
40
|
-
method: method, // *GET, POST, PUT, DELETE, etc.
|
|
41
|
-
headers: {
|
|
42
|
-
...JSON.parse(headers),
|
|
43
|
-
"Content-Type": "application/json",
|
|
44
|
-
// 'Content-Type': 'application/x-www-form-urlencoded',
|
|
45
|
-
},
|
|
46
|
-
body: body, // body data type must match "Content-Type" header
|
|
47
|
-
});
|
|
48
|
-
const result = await response.json();
|
|
49
|
-
console.log(result)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
debugger;
|
|
54
|
-
}
|
|
55
|
-
<\/script>
|
|
56
|
-
<input type="text" id="url"/>
|
|
57
|
-
<select id="method">
|
|
58
|
-
<option value="get">GET</option>
|
|
59
|
-
<option value="post">POST</option>
|
|
60
|
-
<option value="put">PUT</option>
|
|
61
|
-
<option value="delete">DELETE</option>
|
|
62
|
-
</select>
|
|
63
|
-
<textarea id="headers" name="headers" rows="4" cols="50"></textarea>
|
|
64
|
-
<textarea id="body" name="body" rows="4" cols="50">
|
|
65
|
-
</textarea>
|
|
66
|
-
<button onclick="onClick()"/>Submit</button>
|
|
67
|
-
</body>
|
|
68
|
-
</html>
|
|
69
|
-
`,
|
|
70
|
-
headers: {
|
|
71
|
-
'content-type': 'text/html'
|
|
72
|
-
},
|
|
73
|
-
status: 200
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { HttpRequest,HttpResponse } from "@azure/functions"
|
|
2
|
-
import { HttpRequestInit, NattyTestModule } from "@nattyjs/types"
|
|
3
|
-
|
|
4
|
-
import { requestHandler } from "../functions/request-handler";
|
|
5
|
-
export const AzureFunctionTestModule:NattyTestModule = {
|
|
6
|
-
async onRequest(request:any)
|
|
7
|
-
{
|
|
8
|
-
if(request.body && request.body.json)
|
|
9
|
-
request.body.string = JSON.stringify(request.body.json);
|
|
10
|
-
const requestObject= new HttpRequest(request)
|
|
11
|
-
return await requestHandler(requestObject,null)
|
|
12
|
-
}
|
|
13
|
-
}
|
package/tsconfig.build.json
DELETED