Skip to content
This repository was archived by the owner on Feb 24, 2023. It is now read-only.

Commit

Permalink
feat(serverless): add start of az function backend
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhaines committed Feb 8, 2022
1 parent fb80e3a commit 07edc9d
Show file tree
Hide file tree
Showing 22 changed files with 339 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["ms-azuretools.vscode-azurefunctions"]
}
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "0.2.0",
"configurations": [
{
"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,5 +1,12 @@
{
"editor.codeActionsOnSave": {
"source.fixAll": true
}
},
"azureFunctions.deploySubpath": "src/serverlessBackend",
"azureFunctions.postDeployTask": "npm install (functions)",
"azureFunctions.projectLanguage": "TypeScript",
"azureFunctions.projectRuntime": "~4",
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.projectSubpath": "src/serverlessBackend",
"azureFunctions.preDeployTask": "npm prune (functions)"
}
43 changes: 43 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "func",
"command": "host start",
"problemMatcher": "$func-node-watch",
"isBackground": true,
"dependsOn": "npm build (functions)",
"options": {
"cwd": "${workspaceFolder}/src/serverlessBackend"
}
},
{
"type": "shell",
"label": "npm build (functions)",
"command": "npm run build",
"dependsOn": "npm install (functions)",
"problemMatcher": "$tsc",
"options": {
"cwd": "${workspaceFolder}/src/serverlessBackend"
}
},
{
"type": "shell",
"label": "npm install (functions)",
"command": "npm install",
"options": {
"cwd": "${workspaceFolder}/src/serverlessBackend"
}
},
{
"type": "shell",
"label": "npm prune (functions)",
"command": "npm prune --production",
"dependsOn": "npm build (functions)",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/src/serverlessBackend"
}
}
]
}
2 changes: 1 addition & 1 deletion DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ docker-compose -f docker-compose.yml -f local-docker-compose.yml up -d backend
docker-compose -f docker-compose.yml -f local-docker-compose.yml -p sfm exec backend alembic upgrade head
```

You can visit the backend by opening a browser to the address <http://localhost:8181>. You can open a gui to see data in your running postgres database by visiting <http://localhost:8182>. Login with the username `[email protected]` and the password `root`.
You can visit the backend by opening a browser to the address <http://localhost:8181/docs>. You can open a gui to see data in your running postgres database by visiting <http://localhost:8182>. Login with the username `[email protected]` and the password `root`.

<!--
```
Expand Down
3 changes: 3 additions & 0 deletions src/backend/sfm/routes/projects/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def get_projects(params: CustomGetParams = Depends(), db: Session = Depends(get_
"""
projects = crud.get_all(db, skip=params.skip, limit=params.limit)
print("Projects: {}".format(projects))
return projects


Expand Down Expand Up @@ -110,6 +111,8 @@ def create_project(
- **location**: Location of the owner's group. (E.g. Indianapolis, UK, Germany, etc.)
- **repo_url**: Github or Gitlab url to the corresponding project
- **on_prem**: Boolean describing if the repo is located on a "on-premises" server
- **location**: ??
- **github_id**: ??
"""
# Creates the database row and stores it in the table

Expand Down
1 change: 1 addition & 0 deletions src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"pinia": "^2.0.0-rc.8",
"primeicons": "^4.1.0",
"primevue": "^3.6.4",
"tailwindcss-truncate-multiline": "^1.0.3",
"vee-validate": "^4.4.9",
"vue": "^3.2.16",
"vue-apexcharts": "^1.6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ const props = defineProps({
VARIABLES
---------------------------------------------- */
let base = import.meta.env.VITE_API_URL;
console.log("Base Url: ", base);
const changeFailureRate = ref<changeFailureRateItem>(); // holds currently fetched deployment data
const perfStatus = ref("0-15%");
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ const projectDropdownChoices = computed(() => {
// let bearer = import.meta.env.VITE_API_AUTH_TOKEN;
const fetchProjects = () => {
axios
.get("/projects", {
.get("/projects/", {
params: { skip: 0, limit: 100 },
headers: {
"Content-Type": "application/json",
Expand All @@ -366,6 +366,7 @@ const fetchProjects = () => {
.then((response) => {
projects.value = response.data;
loaded.value = true;
console.log("Token: ", import.meta.env.VITE_API_AUTH_TOKEN);
})
.catch((error) => {
console.error("GET Projects Error: ", error);
Expand Down
7 changes: 6 additions & 1 deletion src/frontend/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ module.exports = {
// mode: "jit",
important: false,
separator: ":",
plugins: [require("@tailwindcss/forms")],
plugins: [
require("@tailwindcss/forms"),
require("@tailwindcss/forms"),
require("@tailwindcss/line-clamp"),
require("tailwindcss-truncate-multiline"),
],
theme: {
screens: {
sm: "640px",
Expand Down
5 changes: 5 additions & 0 deletions src/frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6997,6 +6997,11 @@ table@^6.0.9:
string-width "^4.2.3"
strip-ansi "^6.0.1"

tailwindcss-truncate-multiline@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/tailwindcss-truncate-multiline/-/tailwindcss-truncate-multiline-1.0.3.tgz#de3ccb99a5a44ab042dd447be640776e4753ed23"
integrity sha512-YsF5Nn2lQUCJECbU99dMDJ/XhrG8RKbSYXPmvoHnldB+HG/H8vJUqB+b5HKapvT26aQotdZLjJpC8YBGrWU12A==

tailwindcss@^2.2.7:
version "2.2.16"
resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-2.2.16.tgz#32f81bdf1758b639cb83b9d30bf7cbecdda49e5e"
Expand Down
2 changes: 2 additions & 0 deletions src/local-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ services:
- 8181:8181
volumes:
- ./backend/:/app
env_file:
- ./backend/.env

frontend:
depends_on:
Expand Down
7 changes: 7 additions & 0 deletions src/serverlessBackend/.funcignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.js.map
*.ts
.git*
.vscode
local.settings.json
test
tsconfig.json
99 changes: 99 additions & 0 deletions src/serverlessBackend/.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
17 changes: 17 additions & 0 deletions src/serverlessBackend/deployments/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": ["get"]
},
{
"type": "http",
"direction": "out",
"name": "res"
}
],
"scriptFile": "../dist/deployments/index.js"
}
19 changes: 19 additions & 0 deletions src/serverlessBackend/deployments/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { AzureFunction, Context, HttpRequest } from "@azure/functions";

const httpTrigger: AzureFunction = async function (
context: Context,
req: HttpRequest
): Promise<void> {
context.log("HTTP trigger function processed a request.");
const name = req.query.name || (req.body && req.body.name);
const responseMessage = name
? "Hello, " + name + ". This HTTP triggered function executed successfully."
: "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.";

context.res = {
// status: 200, /* Defaults to 200 */
body: responseMessage,
};
};

export default httpTrigger;
3 changes: 3 additions & 0 deletions src/serverlessBackend/deployments/sample.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "Azure"
}
15 changes: 15 additions & 0 deletions src/serverlessBackend/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": "[2.*, 3.0.0)"
}
}
52 changes: 52 additions & 0 deletions src/serverlessBackend/package-lock.json

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

Loading

0 comments on commit 07edc9d

Please sign in to comment.