You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/typespec/quickstart-scaffold-typescript.md
+26-20Lines changed: 26 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,20 +86,6 @@ TypeSpec defines your API in a language-agnostic way and generates the API serve
86
86
TypeSpec **emitters** are libraries that utilize various TypeSpec compiler APIs to reflect on the TypeSpec compilation process and generate artifacts.
87
87
88
88
1. Wait for the initialization to complete before continuing.
89
-
90
-
```console
91
-
Please review the following messages from emitters:
92
-
@typespec/http-server-js:
93
-
94
-
Generated JavaScript services require a service runtime:
95
-
https://nodejs.org/download
96
-
97
-
Create a JavaScript service project for your TypeSpec:
98
-
> npx hsjs-scaffold
99
-
100
-
More information on getting started:
101
-
https://aka.ms/tsp/hsjs/start
102
-
```
103
89
104
90
1. Compile the project:
105
91
@@ -194,7 +180,7 @@ Now that the basic Express.js API server is working, update the Express.js serve
194
180
```
195
181
196
182
1. Create an `./tsp-output/server/src/azure` directory to hold source code specific to Azure.
197
-
1. Create the `cosmos-client.ts` file in that directory to create a Cosmos DB client object and paste in the following code:
183
+
1. Create the `cosmosClient.ts` file in that directory to create a Cosmos DB client object and paste in the following code:
198
184
199
185
```typescript
200
186
import { CosmosClient, Database, Container } from "@azure/cosmos";
@@ -289,7 +275,7 @@ Now that the basic Express.js API server is working, update the Express.js serve
289
275
290
276
Notice the file uses the endpoint, database, and container. It doesn't need a connection string or key because it's using the Azure Identity credential `DefaultAzureCredential`. Learn more about this method of [secure authentication for both local and production](/azure/developer/javascript/sdk/authentication/overview) environments.
291
277
292
-
1. Create a new Widget controller, `./tsp-output/server/src/controllers/widgets-cosmos.ts`, and paste in the following integration code for Azure Cosmos DB.
278
+
1. Create a new Widget controller, `./tsp-output/server/src/controllers/WidgetsCosmos.ts`, and paste in the following integration code for Azure Cosmos DB.
293
279
294
280
```typescript
295
281
import { Widgets, Widget, WidgetList, AnalyzeResult,Error } from "../generated/models/all/demo-service.js";
@@ -501,12 +487,12 @@ Now that the basic Express.js API server is working, update the Express.js serve
501
487
}
502
488
```
503
489
504
-
1. Update the `./tsp-output/server/src/index.ts` to use the new controller.
490
+
1. Update the `./tsp-output/server/src/index.ts` to import the new controller, get the Azure Cosmos DB environment settings, then create the WidgetsCosmosController and pass to the router`.
505
491
506
492
```typescript
507
493
// Generated by Microsoft TypeSpec
508
494
509
-
import { WidgetsCosmosController } from "./controllers/widgets-cosmos.js";
495
+
import { WidgetsCosmosController } from "./controllers/WidgetsCosmos.js";
510
496
511
497
import { createDemoServiceRouter } from "./generated/http/router.js";
512
498
@@ -548,7 +534,7 @@ Now that the basic Express.js API server is working, update the Express.js serve
548
534
});
549
535
```
550
536
551
-
1. Compile the TypeScript into JavaScript.
537
+
1. In a terminal at `./tsp-output/server`, compile the TypeScript into JavaScript.
552
538
553
539
```console
554
540
tsc
@@ -902,7 +888,7 @@ Create the files needed to have a repeatable deployment with [Azure Developer CL
902
888
903
889
You can deploy this application to Azure using Azure Container Apps:
904
890
905
-
1. Authenticate to the Azure Developer CLI:
891
+
1. In a terminal at the root of the project, authenticate to the Azure Developer CLI:
906
892
907
893
```console
908
894
azd auth login
@@ -915,6 +901,26 @@ You can deploy this application to Azure using Azure Container Apps:
915
901
azd up
916
902
```
917
903
904
+
1. Answer the following prompts with the answers provided:
905
+
906
+
* Enter a unique environment name: `tsp-server-js`
907
+
* Select an Azure Subscription to use: select your subscription
908
+
* Select an Azure location to use: select a location near you
909
+
* Pick a resource group to use: Select *Create a new resource group*
910
+
* Enter a name for the new resource group: accept the default provided
911
+
912
+
1. Wait until the deployment completes. The response includes information similar to the following:
0 commit comments