Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update README #73

Merged
merged 1 commit into from
Mar 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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