Skip to content

Commit

Permalink
chore: added Azure
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Dec 2, 2024
1 parent e41fbb5 commit 61c8985
Show file tree
Hide file tree
Showing 13 changed files with 113 additions and 88 deletions.
10 changes: 10 additions & 0 deletions .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
9 changes: 7 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"recommendations": ["arcanis.vscode-zipfs", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
}
"recommendations": [
"ms-azuretools.vscode-azurefunctions",
"arcanis.vscode-zipfs",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}
13 changes: 11 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
{
"typescript.enablePromptUseWorkspaceTsdk": true,
"cSpell.words": ["smee"]
}
"cSpell.words": [
"smee"
],
"azureFunctions.deploySubpath": ".",
"azureFunctions.postDeployTask": "npm install (functions)",
"azureFunctions.projectLanguage": "TypeScript",
"azureFunctions.projectRuntime": "~4",
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.projectLanguageModel": 4,
"azureFunctions.preDeployTask": "npm prune (functions)"
}
Binary file modified bun.lockb
Binary file not shown.
15 changes: 15 additions & 0 deletions 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": "[4.*, 5.0.0)"
}
}
7 changes: 7 additions & 0 deletions local.settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "node"
}
}
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": false,
"description": "The kernel for UbiquityOS.",
"module": "dist/index.mjs",
"main": "dist/index.js",
"main": "dist/src/functions/*.js",
"typings": "dist/index.d.ts",
"files": [
"dist"
Expand Down Expand Up @@ -32,7 +32,10 @@
"jest:test": "jest --coverage",
"plugin:hello-world": "tsx tests/__mocks__/hello-world-plugin.ts",
"setup-kv": "bun --env-file=.dev.vars scripts/setup-kv-namespace.ts",
"setup": "tsx ./scripts/setup.ts"
"setup": "tsx ./scripts/setup.ts",
"start": "func start",
"prestart": "bun run build",
"build": "tsc"
},
"keywords": [
"typescript",
Expand All @@ -42,6 +45,7 @@
"open-source"
],
"dependencies": {
"@azure/functions": "^4.6.0",
"@cfworker/json-schema": "2.0.1",
"@octokit/auth-app": "7.1.0",
"@octokit/core": "6.1.2",
Expand Down
81 changes: 0 additions & 81 deletions src/api/index.ts

This file was deleted.

15 changes: 15 additions & 0 deletions src/functions/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { app, HttpRequest, HttpResponseInit, InvocationContext } from "@azure/functions";

export async function myFunc(request: HttpRequest, context: InvocationContext): Promise<HttpResponseInit> {
context.log(`Http function processed request for url "${request.url}"`);

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

return { body: `Hello, ${name}!` };
}

app.http("my-func", {
methods: ["GET", "POST"],
authLevel: "anonymous",
handler: myFunc,
});
20 changes: 20 additions & 0 deletions src/functions/function.json
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/src/functions/app.js"
}
15 changes: 15 additions & 0 deletions src/functions/http-trigger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { app, HttpRequest, HttpResponseInit, InvocationContext } from "@azure/functions";

export async function httpTrigger(request: HttpRequest, context: InvocationContext): Promise<HttpResponseInit> {
context.log(`Http function processed request for url "${request.url}"`);

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

return { body: `Hello, ${name}!` };
}

app.http("httpTrigger1", {
methods: ["GET", "POST"],
authLevel: "anonymous",
handler: httpTrigger,
});
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { app } from "@azure/functions";

app.setup({
enableHttpStream: true,
});
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"rootDir": ".",
// "removeComments": true, /* Disable emitting comments. */
"noEmit": true /* Disable emitting files from a compilation. */,
// "noEmit": true /* Disable emitting files from a compilation. */,
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
Expand Down

0 comments on commit 61c8985

Please sign in to comment.