@@ -69,15 +69,15 @@ README.md
6969
7070As we will be generating IDs for each profile, add the uuid dependency by adding it to your ` pubspec.yaml ` .
7171
72- ``` yaml
72+ ``` bash
7373dart pub add uuid
7474```
7575
7676## Building the API
7777
7878Applications built with Nitric can contain many APIs, let's start by adding one to this project to serve as the public endpoint.
7979
80- ``` dart
80+ ``` dart title:services/api.dart
8181import 'package:nitric_sdk/nitric.dart';
8282
8383import 'package:uuid/uuid.dart';
@@ -116,7 +116,7 @@ Let's start adding features that allow our API consumers to work with profile da
116116 prefer. For simplicity we'll group them together in this guide.
117117</Note >
118118
119- ``` dart
119+ ``` dart title:services/api.dart
120120profileApi.post("/profiles", (ctx) async {
121121 final uuid = Uuid();
122122
@@ -136,7 +136,7 @@ profileApi.post("/profiles", (ctx) async {
136136
137137### Retrieve a profile with GET
138138
139- ``` dart
139+ ``` dart title:services/api.dart
140140profileApi.get("/profiles/:id", (ctx) async {
141141 final id = ctx.req.pathParams["id"]!;
142142
@@ -156,7 +156,7 @@ profileApi.get("/profiles/:id", (ctx) async {
156156
157157### Remove a profile with DELETE
158158
159- ``` dart
159+ ``` dart title:services/api.dart
160160profileApi.delete("/profiles/:id", (ctx) async {
161161 final id = ctx.req.pathParams["id"]!;
162162
@@ -235,7 +235,7 @@ nitric stack new dev aws
235235
236236Continue by checking your stack file ` nitric.dev.yaml ` and adding in your preferred region, let's use ` us-east-1 ` .
237237
238- ``` yaml
238+ ``` yaml title:nitric.dev.yaml
239239# The nitric provider to use
240240provider : nitric/aws@latest
241241# The target aws region to deploy to
@@ -273,13 +273,13 @@ If you want to go a bit deeper and create some other resources with Nitric, why
273273
274274Define a bucket named `profilesImg` with reading/writing permissions.
275275
276- ` ` ` dart
276+ ` ` ` dart title:services/api.dart
277277final profilesImg = Nitric.bucket("profilesImg").allow([BucketPermission.read, BucketPermission.write]);
278278` ` `
279279
280280# ## Get a URL to upload a profile image
281281
282- ` ` ` dart
282+ ` ` ` dart title:services/api.dart
283283profileApi.get("/profiles/:id/image/upload", (ctx) async {
284284 final id = ctx.req.pathParams["id"];
285285
@@ -294,7 +294,7 @@ profileApi.get("/profiles/:id/image/upload", (ctx) async {
294294
295295# ## Get a URL to download a profile image
296296
297- ` ` ` dart
297+ ` ` ` dart title:services/api.dart
298298profileApi.get("/profiles/:id/image/download", (ctx) async {
299299 final id = ctx.req.pathParams["id"];
300300
@@ -309,7 +309,7 @@ profileApi.get("/profiles/:id/image/download", (ctx) async {
309309
310310You can also return a redirect response that takes the HTTP client directly to the photo URL.
311311
312- ` ` ` dart
312+ ` ` ` dart title:services/api.dart
313313profileApi.get("/profiles/:id/image/view", (ctx) async {
314314 final id = ctx.req.pathParams["id"];
315315
0 commit comments