Hey, currently I dont seem to be able to find a way to give req and res in Future<void> start(final req, final res) a type which is pretty annoying. Are there any types for req and res I can use?`Something like AppwriteRequest or AppwriteResponse
We've had discussions about exposing the types. For now, maybe you can copy and paste this and cast the variables in your function body.
https://github.com/open-runtimes/open-runtimes/blob/main/runtimes/dart-2.17/function_types.dart
Casting doesnt work, 'im getting type 'Response' is not a subtype of type 'AppwriteResponse' in type cast'
class AppwriteRequest {
final Map<String, dynamic> variables;
final Map<String, dynamic> headers;
final String payload;
AppwriteRequest({
this.variables = const {},
this.headers = const {},
this.payload = '',
});
}
class AppwriteResponse {
int _status = 200;
dynamic _text;
int get status => _status;
dynamic get body => _text;
AppwriteResponse send(String? text, {int status = 200}) {
_text = text;
_status = status;
return this;
}
AppwriteResponse json(Map<String, dynamic> json, {int status = 200}) {
_text = json;
_status = status;
return this;
}
}
Womp. It still might be possible with a lot of hacking...
Yep, got it to work with this fancy hacky method:
T? castOrNull<T>(dynamic x) => x is T ? x : null;
AppwriteRequest? req = castOrNull<AppwriteRequest>(requ);
AppwriteResponse? res = castOrNull<AppwriteResponse>(resp);
Nvm, doesnt work :/
😕 ya...it might not be worth it to try and do that at the moment
Recommended threads
- Scheduled works locking the entire Maria...
I have a scheduled function and apparently that or something is locking the entire MariaDB database and Appwrite is giving MariaDB errors. This error persists e...
- Python Function not working
I am getting this issue as well. Doesnt look like there was a solution as you guys were not able to replicate. Below is my code as well as the error. I started...
- I can't share code between functions
Operating System: MacOS Appwrite Version: self-hosted 1.8.1 Appwrite CLI Version: 13.2.1 I want to split code up to share it between my functions. At the momen...