|
1 | 1 | --- |
2 | 2 | title: "Quickstart: Create a new TypeScript API project with TypeSpec" |
3 | | -description: Learn how to generate and set up a new RESTful TypeScrip API project using TypeSpec to scaffold consistent client and server code for cloud services. |
| 3 | +description: Learn how to generate and set up a new RESTful TypeScript API project using TypeSpec to scaffold consistent client and server code for cloud services. |
4 | 4 | ms.topic: quickstart |
5 | 5 | ms.date: 04/30/2025 |
6 | 6 | ms.custom: devx-track-typespec, devx-track-js, devx-track-ts |
@@ -110,7 +110,7 @@ TypeSpec defines your API in a language-agnostic way and generates the API serve |
110 | 110 | 1. TypeSpec generates the default project in `./tsp-output`, creating two separate folders: |
111 | 111 |
|
112 | 112 | * **schema** is the OpenApi 3 specification. Notice that the few lines in `./main.tsp` generated over 200 lines of OpenApi specification for you. |
113 | | - * **server** is the generated middleware. This can be incorporated into a Node.js server project. |
| 113 | + * **server** is the generated middleware. This middleware can be incorporated into a Node.js server project. |
114 | 114 | * `./tsp-output/js/src/generated/models/all/demo-service.ts` defines the interfaces for the Widgets API. |
115 | 115 | * `./tsp-output/js/src/generated/http/openapi3.ts` defines the Open API spec as a TypeScript file and is regenerated every time you compile your TypeSpec project. |
116 | 116 | |
@@ -147,7 +147,7 @@ Use the TypeSpec files to configure the API server generation to scaffold the en |
147 | 147 | npx hsjs-scaffold |
148 | 148 | ``` |
149 | 149 |
|
150 | | -1. Change into the new `/./tsp-output/server` directory: |
| 150 | +1. Change into the new `./tsp-output/server` directory: |
151 | 151 |
|
152 | 152 | ```console |
153 | 153 | cd ./tsp-output/server |
@@ -179,7 +179,7 @@ Use the TypeSpec files to configure the API server generation to scaffold the en |
179 | 179 |
|
180 | 180 | ## Change persistence to Azure Cosmos DB no-sql |
181 | 181 |
|
182 | | -Now that the basic Express.js API server is working, update the Express.js server to work with [Azure Cosmos DB](/azure/cosmos-db/) for a persistent data store. This includes changes to the `index.ts` to use Cosmos DB integration in the middleware. All changes should happen outside the `./src/generated` directory. |
| 182 | +Now that the basic Express.js API server is working, update the Express.js server to work with [Azure Cosmos DB](/azure/cosmos-db/) for a persistent data store. This includes changes to the `index.ts` to use Cosmos DB integration in the middleware. All changes should happen outside the `./tsp-output/server/src/generated` directory. |
183 | 183 |
|
184 | 184 | 1. In the `./tsp-output/server` directory, add [Azure Cosmos DB](/azure/cosmos-db/) to the project: |
185 | 185 |
|
@@ -287,9 +287,9 @@ Now that the basic Express.js API server is working, update the Express.js serve |
287 | 287 | }; |
288 | 288 | ``` |
289 | 289 |
|
290 | | - Notice the file uses the endpoint, database, and container. It doesn't need a connection string or key because it is 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. |
| 290 | + 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 | 291 |
|
292 | | -1. Create a new Widget controller, `./src/controllers/widgets-cosmos.ts`, with the following code to integrate Azure Cosmos DB. |
| 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. |
293 | 293 |
|
294 | 294 | ```typescript |
295 | 295 | import { Widgets, Widget, WidgetList, AnalyzeResult,Error } from "../generated/models/all/demo-service.js"; |
@@ -504,7 +504,7 @@ Now that the basic Express.js API server is working, update the Express.js serve |
504 | 504 | } |
505 | 505 | ``` |
506 | 506 |
|
507 | | -1. Update the `./src/index.ts` to use the new controller. |
| 507 | +1. Update the `./tsp-output/server/src/index.ts` to use the new controller. |
508 | 508 |
|
509 | 509 | ```typescript |
510 | 510 | // Generated by Microsoft TypeSpec |
@@ -930,7 +930,7 @@ Once deployed, you can: |
930 | 930 | Now that you have the entire end to end process working, continue to build your API: |
931 | 931 |
|
932 | 932 | * Learn more about the [TypeSpec language](https://typespec.io/docs/language-basics/overview/) to add more APIs and API layer features in the `./main.tsp`. |
933 | | -* Add additional [emitters](https://typespec.io/docs/extending-typespec/emitters-basics/) and configure their parameters in the `./tspconfig.yaml`. |
| 933 | +* Add more [emitters](https://typespec.io/docs/extending-typespec/emitters-basics/) and configure their parameters in the `./tspconfig.yaml`. |
934 | 934 | * As you add more features in your TypeSpec files, support those changes with source code in the server project. |
935 | 935 | * Continue to use [passwordless authentication](/azure/developer/javascript/sdk/authentication/overview) with Azure Identity. |
936 | 936 |
|
|
0 commit comments