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: README.md
+21-40Lines changed: 21 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -107,7 +107,7 @@ To create our Nitric project, we have to create a `nitric.yaml` file. The handle
107
107
name: my_profile_api
108
108
services:
109
109
- match: bin/my_profile_api.dart
110
-
start: dart run bin/my_profile_api.dart
110
+
start: dart run $SERVICE_PATH
111
111
```
112
112
113
113
## Create a Profile class
@@ -141,34 +141,34 @@ class Profile {
141
141
Applications built with Nitric can contain many APIs, let's start by adding one to this project to serve as the public endpoint. Rename `bin/my_profile_api.dart` to `bin/profiles.dart`
// Define a collection named 'profiles', then request reading and writing permissions.
155
-
final profiles = collection<Profile>("profiles").requires([
156
-
CollectionPermission.writing,
157
-
CollectionPermission.deleting,
158
-
CollectionPermission.reading
154
+
// Define a key value store named 'profiles', then request getting, setting and deleting permissions.
155
+
final profiles = store("profiles").requires([
156
+
KeyValuePermission.getting,
157
+
KeyValuePermission.setting,
158
+
KeyValuePermission.deleting
159
159
]);
160
160
}
161
161
```
162
162
163
-
Here we're creating an API named `public` and a collection named `profiles`, then requesting read, write, and delete permissions which allows our function to access the collection.
163
+
Here we're creating an API named `public` and a key value store named `profiles`, then requesting get, set, and delete permissions which allows our function to access the key value store.
164
164
165
165
<Note>
166
-
Resources in Nitric like `api` and `collection` represent high-level cloud
166
+
Resources in Nitric like `api` and `key value store` represent high-level cloud
167
167
resources. When your app is deployed Nitric automatically converts these
168
168
requests into appropriate resources for the specific
169
169
[provider](https://nitric.io/docs/reference/providers). Nitric also takes care of adding the IAM
170
170
roles, policies, etc. that grant the requested access. For example the
171
-
`collection`resource uses DynamoDB in AWS or FireStore on Google Cloud.
171
+
`key value stores`resource uses DynamoDB in AWS or FireStore on Google Cloud.
Now that you have an API defined with handlers for each of its methods, it's time to test it locally.
256
243
257
244
```bash
258
-
npm run dev
245
+
nitric start
259
246
```
260
247
261
-
<Note>
262
-
the `dev` script starts the Nitric Server using `nitric start`, which provides
263
-
local interfaces to emulate cloud resources, then runs your functions and
264
-
allows them to connect.
265
-
</Note>
266
-
267
248
Once it starts, the application will receive requests via the API port. You can use the Local Dashboard or any HTTP client to test the API. We'll keep it running for our tests. If you want to update your functions, just save them, they'll be reloaded automatically.
268
249
269
250
## Test the API
@@ -354,7 +335,7 @@ If you want to go a bit deeper and create some other resources with Nitric, why
354
335
Define a bucket named `profilesImg` with reading/writing permissions.
355
336
356
337
```dart
357
-
final profilesImg = bucket("profilesImg").requires([BucketPermission.reading, BucketPermission.writing]);
338
+
final profilesImg = Nitric.bucket("profilesImg").requires([BucketPermission.reading, BucketPermission.writing]);
0 commit comments