generated from scale-tone/react-ts-basic
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replaced proxies with backend functions (since proxies do not work wi…
…th Static Web Apps anymore)
- Loading branch information
1 parent
6bdf604
commit 4a1d59c
Showing
11 changed files
with
459 additions
and
70 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,19 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"authLevel": "anonymous", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "req", | ||
"methods": [ | ||
"get" | ||
] | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "res" | ||
} | ||
], | ||
"scriptFile": "../dist/autocomplete/index.js" | ||
} |
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,20 @@ | ||
import { AzureFunction, Context, HttpRequest } from "@azure/functions" | ||
import axios from 'axios'; | ||
|
||
const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise<void> { | ||
|
||
const searchApiUrl = `https://${process.env.SearchServiceName}.search.windows.net/indexes/${process.env.SearchIndexName}/docs/autocomplete?api-version=2019-05-06&`; | ||
const url = req.url.replace(/^http(s)?:\/\/[^/]+\/api\/autocomplete(\?)?/i, searchApiUrl); | ||
|
||
const searchApiResponse = await axios.get(url, { | ||
headers: { | ||
"api-key": process.env.SearchApiKey, | ||
} }); | ||
|
||
context.res = { | ||
status: searchApiResponse.status, | ||
body: searchApiResponse.data, | ||
}; | ||
}; | ||
|
||
export default httpTrigger; |
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,20 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"authLevel": "anonymous", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "req", | ||
"methods": [ | ||
"get", | ||
"post" | ||
] | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "res" | ||
} | ||
], | ||
"scriptFile": "../dist/config-script/index.js" | ||
} |
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 { AzureFunction, Context } from "@azure/functions" | ||
|
||
const httpTrigger: AzureFunction = async function (context: Context): Promise<void> { | ||
|
||
const serverSideConfig = { | ||
SearchServiceName: process.env.SearchServiceName, | ||
SearchIndexName: process.env.SearchIndexName, | ||
AzureMapSubscriptionKey: process.env.AzureMapSubscriptionKey, | ||
CognitiveSearchKeyField: process.env.CognitiveSearchKeyField, | ||
CognitiveSearchNameField: process.env.CognitiveSearchNameField, | ||
CognitiveSearchGeoLocationField: process.env.CognitiveSearchGeoLocationField, | ||
CognitiveSearchOtherFields: process.env.CognitiveSearchOtherFields, | ||
CognitiveSearchTranscriptFields: process.env.CognitiveSearchTranscriptFields, | ||
CognitiveSearchFacetFields: process.env.CognitiveSearchFacetFields, | ||
CognitiveSearchSuggesterName: process.env.CognitiveSearchSuggesterName | ||
}; | ||
|
||
context.res = { | ||
body: `const ServerSideConfig = ${JSON.stringify(serverSideConfig)}`, | ||
|
||
headers: { | ||
"Content-Type": "application/javascript; charset=UTF-8" | ||
} | ||
}; | ||
}; | ||
|
||
export default httpTrigger; |
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,20 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"authLevel": "anonymous", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "req", | ||
"methods": [ | ||
"get" | ||
], | ||
"route": "lookup/{key}" | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "res" | ||
} | ||
], | ||
"scriptFile": "../dist/lookup/index.js" | ||
} |
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,20 @@ | ||
import { AzureFunction, Context, HttpRequest } from "@azure/functions" | ||
import axios from 'axios'; | ||
|
||
const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise<void> { | ||
|
||
const searchApiUrl = `https://${process.env.SearchServiceName}.search.windows.net/indexes/${process.env.SearchIndexName}/docs`; | ||
const url = req.url.replace(/^http(s)?:\/\/[^/]+\/api\/lookup/i, searchApiUrl); | ||
|
||
const searchApiResponse = await axios.get(`${url}?api-version=2019-05-06`, { | ||
headers: { | ||
"api-key": process.env.SearchApiKey, | ||
} }); | ||
|
||
context.res = { | ||
status: searchApiResponse.status, | ||
body: searchApiResponse.data, | ||
}; | ||
}; | ||
|
||
export default httpTrigger; |
Oops, something went wrong.