Skip to content

Commit

Permalink
chore: Update README
Browse files Browse the repository at this point in the history
Include the latest changes from the 0.2.0 release
  • Loading branch information
dnys1 committed Mar 9, 2024
1 parent 7c50c13 commit c7d8510
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,31 @@ The CLI will also create a folder in your project called `celest`, which will in
```shell
flutter_app/
└── celest/
├── config/
│ └── .env # Environment variables
├── functions/ # Celest Functions folder
| └── greeting.dart # Example API file
├── functions/ # Celest Functions folder
| └── greeting.dart # Example API file
├── lib/
│ │── client.dart # Generated client for your Flutter app
│ ├── models.dart # Custom API models
│ └── exceptions.dart # Custom API exceptions
└── test/ # Tests for your backend
│ │── client.dart # Generated client for your Flutter app
│ ├── models/ # Custom API models
| | └── person.dart
│ └── exceptions/ # Custom API exceptions
| └── bad_name_exception.dart
└── test/ # Tests for your backend
```

To get started building your serverless cloud function, navigate to the `<flutter_app>/celest/functions/` folder and create a file named `<api_name>.dart`. You can create as many APIs as you want in this directory. Think of each file as a way to organize and group multiple Celest Functions of similar functionality into a namespace.

Celest Functions are defined as top-level functions as shown below.

```dart
Future<String> sayHello(String name) async {
Future<String> sayHello({
required String name,
}) async {
return 'Hello, $name';
}
Future<String> sayGoodbye(String name) async {
Future<String> sayGoodbye({
required String name,
}) async {
return 'Goodbye, $name';
}
```
Expand Down Expand Up @@ -98,7 +102,7 @@ class MyApp extends StatelessWidget {
body: Center(
child: FutureBuilder(
// Call your function using the Celest client
future: celest.functions.greeting.sayHello('Celest'),
future: celest.functions.greeting.sayHello(name: 'Celest'),
builder: (_, snapshot) => switch (snapshot) {
AsyncSnapshot(:final data?) => Text(data),
AsyncSnapshot(:final error?) =>
Expand Down

0 comments on commit c7d8510

Please sign in to comment.