Skip to content

Commit 1fff64f

Browse files
authored
feat: support '--data-api-location' in 'swa init' (#735)
1 parent eb125dd commit 1fff64f

File tree

14 files changed

+221
-5
lines changed

14 files changed

+221
-5
lines changed

e2e/detect.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe("framework detection", () => {
4646
- samples/api/node (Node.js)
4747
- samples/api/node-ts (Node.js, TypeScript)
4848
- samples/api/python (Python)
49-
Detected app folders (62):
49+
Detected app folders (63):
5050
- samples/app/angular (Angular)
5151
- samples/app/angular-scully (Angular, Scully)
5252
- samples/app/astro (Astro)
@@ -106,6 +106,7 @@ describe("framework detection", () => {
106106
- samples/app/vuepress/docs (VuePress)
107107
- samples/app/wintersmith (Wintersmith)
108108
- samples/app/zola (Zola)
109+
- samples/db/static-mssql/src (Static HTML)
109110
- samples/ssr/angular-universal (Angular)
110111
- samples/ssr/nextjs (React, Next.js)
111112
- samples/ssr/remix (Remix)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
/test-results/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["ms-azuretools.vscode-azurefunctions"]
3+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Attach to Node Functions",
6+
"type": "node",
7+
"request": "attach",
8+
"port": 9229,
9+
"preLaunchTask": "func: host start"
10+
}
11+
]
12+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"azureFunctions.deploySubpath": "api",
3+
"azureFunctions.postDeployTask": "npm install (functions)",
4+
"azureFunctions.projectLanguage": "JavaScript",
5+
"azureFunctions.projectRuntime": "~4",
6+
"debug.internalConsoleOptions": "neverOpen",
7+
"azureFunctions.preDeployTask": "npm prune (functions)"
8+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "func",
6+
"label": "func: host start",
7+
"command": "host start",
8+
"problemMatcher": "$func-node-watch",
9+
"isBackground": true,
10+
"dependsOn": "npm install (functions)",
11+
"options": {
12+
"cwd": "${workspaceFolder}/api"
13+
}
14+
},
15+
{
16+
"type": "shell",
17+
"label": "npm install (functions)",
18+
"command": "npm install",
19+
"options": {
20+
"cwd": "${workspaceFolder}/api"
21+
}
22+
},
23+
{
24+
"type": "shell",
25+
"label": "npm prune (functions)",
26+
"command": "npm prune --production",
27+
"problemMatcher": [],
28+
"options": {
29+
"cwd": "${workspaceFolder}/api"
30+
}
31+
}
32+
]
33+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "vanilla-basic",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"start": "sirv ./src public --cors --single --no-clear --port 8000"
6+
}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Vanilla JavaScript App
2+
3+
[Azure Static Web Apps](https://docs.microsoft.com/azure/static-web-apps/overview) allows you to easily build JavaScript apps in minutes. Use this repo with the [quickstart](https://docs.microsoft.com/azure/static-web-apps/getting-started?tabs=vanilla-javascript) to build and customize a new static site.
4+
5+
This repo is used as a starter for a _very basic_ HTML web application using no front-end frameworks.
6+
7+
This repo has a dev container. This means if you open it inside a [GitHub Codespace](https://github.com/features/codespaces), or using [VS Code with the remote containers extension](https://code.visualstudio.com/docs/remote/containers), it will be opened inside a container with all the dependencies already installed.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<link rel="stylesheet" href="styles.css">
8+
<title>Static Web Apps Database Connections</title>
9+
</head>
10+
11+
<body>
12+
<div id="result"></div>
13+
<script>
14+
async function list() {
15+
const endpoint = '/data-api/rest/Person';
16+
const response = await fetch(endpoint);
17+
const data = await response.json();
18+
console.table(data.value);
19+
// get the result div element
20+
const result = document.getElementById('result');
21+
// create a pre element to show the formatted data
22+
const pre = document.createElement('pre');
23+
// use JSON.stringify to format the data with indentation and line breaks
24+
pre.textContent = JSON.stringify(data.value, null, 2);
25+
// append the pre element to the result div
26+
result.appendChild(pre);
27+
}
28+
29+
// call the list function when the window loads
30+
window.onload = list;
31+
</script>
32+
</body>
33+
34+
</html>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"$schema": "https://github.com/Azure/data-api-builder/releases/latest/download/dab.draft.schema.json",
3+
"data-source": {
4+
"database-type": "mssql",
5+
"options": {
6+
"set-session-context": false
7+
},
8+
"connection-string": "@env('DATABASE_CONNECTION_STRING')"
9+
},
10+
"runtime": {
11+
"rest": {
12+
"enabled": true,
13+
"path": "/rest"
14+
},
15+
"graphql": {
16+
"allow-introspection": true,
17+
"enabled": true,
18+
"path": "/graphql"
19+
},
20+
"host": {
21+
"mode": "production",
22+
"cors": {
23+
"origins": ["http://localhost:4280"],
24+
"allow-credentials": false
25+
},
26+
"authentication": {
27+
"provider": "StaticWebApps"
28+
}
29+
}
30+
},
31+
"entities": {
32+
"Person": {
33+
"source": "dbo.MyTestPersonTable",
34+
"permissions": [
35+
{
36+
"actions": ["*"],
37+
"role": "anonymous"
38+
}
39+
]
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)