Skip to content

Commit

Permalink
Merge pull request #1 from lakshmansha/feature/azfn
Browse files Browse the repository at this point in the history
Feature/azfn
  • Loading branch information
lakshmansha committed May 4, 2024
2 parents d91056f + 44b99a0 commit 7ae69f5
Show file tree
Hide file tree
Showing 14 changed files with 292 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/" # App source code path
api_location: "" # Api source code path - optional
api_location: "/api" # Api source code path - optional
output_location: "dist" # Built app content directory - optional
###### End of Repository/Build Configurations ######

Expand Down
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"ms-azuretools.vscode-azurefunctions"
]
}
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
"name": "Launch Chrome against localhost",
"url": "http://localhost:5200",
"webRoot": "${workspaceFolder}"
},
{
"name": "Attach to Node Functions",
"type": "node",
"request": "attach",
"port": 9229,
"preLaunchTask": "func: host start"
}
]
}
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{
"angular.enable-strict-mode-prompt": false
"angular.enable-strict-mode-prompt": false,
"azureFunctions.deploySubpath": "api",
"azureFunctions.postDeployTask": "npm install (functions)",
"azureFunctions.projectLanguage": "JavaScript",
"azureFunctions.projectRuntime": "~4",
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.projectLanguageModel": 4,
"azureFunctions.preDeployTask": "npm prune (functions)"
}
33 changes: 33 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "func",
"label": "func: host start",
"command": "host start",
"problemMatcher": "$func-node-watch",
"isBackground": true,
"dependsOn": "npm install (functions)",
"options": {
"cwd": "${workspaceFolder}/api"
}
},
{
"type": "shell",
"label": "npm install (functions)",
"command": "npm install",
"options": {
"cwd": "${workspaceFolder}/api"
}
},
{
"type": "shell",
"label": "npm prune (functions)",
"command": "npm prune --production",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/api"
}
}
]
}
10 changes: 10 additions & 0 deletions api/.funcignore
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
99 changes: 99 additions & 0 deletions api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TypeScript output
dist
out

# Azure Functions artifacts
bin
obj
appsettings.json
local.settings.json

# Azurite artifacts
__blobstorage__
__queuestorage__
__azurite_db*__.json
15 changes: 15 additions & 0 deletions api/host.json
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": "[1.*, 2.0.0)"
}
}
13 changes: 13 additions & 0 deletions api/local.settings.sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "node",
"AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
"EnvName": "CDEV - JSON",
"IsFirebase": false,
"FireBaseAPIKey": "AIzaSyCubx8YGktd3hNv6_8wKGdRYaCqsmN3JU4",
"IsRestAPI": true,
"RESTLoggingUrl": "https://ngangularpracticesapi.azurewebsites.net/logger"
}
}
61 changes: 61 additions & 0 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "api",
"version": "1.0.0",
"description": "",
"scripts": {
"start": "func start",
"test": "echo \"No tests yet...\""
},
"dependencies": {
"@azure/functions": "^4.0.0"
},
"devDependencies": {},
"main": "src/functions/*.js"
}
21 changes: 21 additions & 0 deletions api/src/functions/GetConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { app } = require('@azure/functions');

app.http('GetConfig', {
methods: ['GET', 'POST'],
authLevel: 'anonymous',
handler: async (request, context) => {
context.log(`Http function processed request for url "${request.url}"`);

const name = request.query.get('name') || await request.text() || 'world';

const config = {
"EnvName": process.env['EnvName'],
"IsFirebase": process.env['IsFirebase'],
"FireBaseAPIKey": process.env['FireBaseAPIKey'],
"IsRestAPI": process.env['IsRestAPI'],
"RESTLoggingUrl": process.env['RESTLoggingUrl']
}

return { body: config };
}
});
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"build": "ng build --prod",
"test": "ng test --code-coverage",
"lint": "ng lint",
"e2e": "ng e2e"
"e2e": "ng e2e",
"spa": "swa start dist/angular-basic --api-location api"
},
"private": true,
"dependencies": {
Expand All @@ -31,6 +32,7 @@
"@angular-devkit/build-angular": "~0.1000.6",
"@angular/cli": "~10.0.6",
"@angular/compiler-cli": "~10.0.9",
"@azure/static-web-apps-cli": "^1.1.7",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
Expand All @@ -48,4 +50,4 @@
"tslint": "~6.1.0",
"typescript": "~3.9.5"
}
}
}
2 changes: 1 addition & 1 deletion src/app/core/app-config/app-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class AppConfigService {
constructor(private http: HttpClient) { }

public loadConfig() {
return this.http.get('./assets/config/config.json')
return this.http.get('/api/GetConfig')
.toPromise()
.then((config: any) => {

Expand Down

0 comments on commit 7ae69f5

Please sign in to comment.