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
- Function executions via custom domain fr...
Aplogies if this was asked already. I'm self-hosting 1.9 on a self-hosted instance of Dokploy. I've made the necessary adjustments to the original compose file ...
- dynamic key missing scopes for database ...
Here are the scopes listed, I get permission errors for reading row and document. Appears to be missing since last time i checked. Database 6 Scopes policies....
- Worker functions stuck on "Fetched 0 fun...
Appwrite Version: 1.9.0 Bug Description: The appwrite-worker-functions container gets stuck in an infinite loop logging "Fetched 0 functions..." while scheduled...