mirror of
https://github.com/timokz/flutter-vienna-hackathon-25.git
synced 2025-11-08 21:04:20 +01:00
Compare commits
2 commits
c36081eddf
...
07870891da
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07870891da | ||
| fb8ba7e6d1 |
21 changed files with 94 additions and 634 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
||||||
wien_talks/wien_talks_flutter/pubspec.lock
|
wien_talks/wien_talks_flutter/pubspec.lock
|
||||||
|
wien_talks/wien_talks_flutter/android/app/google-services.json
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
include defines.mk
|
include defines.mk
|
||||||
|
|
||||||
|
|
||||||
.PHONY := local
|
.PHONY: local
|
||||||
local:
|
local:
|
||||||
$(MAKE) -C wien_talks_server local
|
$(MAKE) -C wien_talks_server local
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,29 +11,10 @@
|
||||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||||
import 'package:serverpod_client/serverpod_client.dart' as _i1;
|
import 'package:serverpod_client/serverpod_client.dart' as _i1;
|
||||||
import 'dart:async' as _i2;
|
import 'dart:async' as _i2;
|
||||||
import 'package:wien_talks_client/src/protocol/greeting.dart' as _i3;
|
import 'package:wien_talks_client/src/protocol/quotes/quote.dart' as _i3;
|
||||||
import 'package:wien_talks_client/src/protocol/quotes/quote.dart' as _i4;
|
import 'package:wien_talks_client/src/protocol/quotes/create_quote.dart' as _i4;
|
||||||
import 'package:wien_talks_client/src/protocol/quotes/create_quote.dart' as _i5;
|
import 'package:serverpod_auth_client/serverpod_auth_client.dart' as _i5;
|
||||||
import 'package:serverpod_auth_client/serverpod_auth_client.dart' as _i6;
|
import 'protocol.dart' as _i6;
|
||||||
import 'protocol.dart' as _i7;
|
|
||||||
|
|
||||||
/// This is an example endpoint that returns a greeting message through
|
|
||||||
/// its [hello] method.
|
|
||||||
/// {@category Endpoint}
|
|
||||||
class EndpointGreeting extends _i1.EndpointRef {
|
|
||||||
EndpointGreeting(_i1.EndpointCaller caller) : super(caller);
|
|
||||||
|
|
||||||
@override
|
|
||||||
String get name => 'greeting';
|
|
||||||
|
|
||||||
/// Returns a personalized greeting message: "Hello {name}".
|
|
||||||
_i2.Future<_i3.Greeting> hello(String name) =>
|
|
||||||
caller.callServerEndpoint<_i3.Greeting>(
|
|
||||||
'greeting',
|
|
||||||
'hello',
|
|
||||||
{'name': name},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// {@category Endpoint}
|
/// {@category Endpoint}
|
||||||
class EndpointQuote extends _i1.EndpointRef {
|
class EndpointQuote extends _i1.EndpointRef {
|
||||||
|
|
@ -42,37 +23,37 @@ class EndpointQuote extends _i1.EndpointRef {
|
||||||
@override
|
@override
|
||||||
String get name => 'quote';
|
String get name => 'quote';
|
||||||
|
|
||||||
_i2.Future<void> updateQuote(_i4.Quote quote) =>
|
_i2.Future<void> updateQuote(_i3.Quote quote) =>
|
||||||
caller.callServerEndpoint<void>(
|
caller.callServerEndpoint<void>(
|
||||||
'quote',
|
'quote',
|
||||||
'updateQuote',
|
'updateQuote',
|
||||||
{'quote': quote},
|
{'quote': quote},
|
||||||
);
|
);
|
||||||
|
|
||||||
_i2.Stream<_i4.Quote> quoteUpdates() =>
|
_i2.Stream<_i3.Quote> quoteUpdates() =>
|
||||||
caller.callStreamingServerEndpoint<_i2.Stream<_i4.Quote>, _i4.Quote>(
|
caller.callStreamingServerEndpoint<_i2.Stream<_i3.Quote>, _i3.Quote>(
|
||||||
'quote',
|
'quote',
|
||||||
'quoteUpdates',
|
'quoteUpdates',
|
||||||
{},
|
{},
|
||||||
{},
|
{},
|
||||||
);
|
);
|
||||||
|
|
||||||
_i2.Future<_i4.Quote> createQuote(_i5.CreateQuoteRequest req) =>
|
_i2.Future<_i3.Quote> createQuote(_i4.CreateQuoteRequest req) =>
|
||||||
caller.callServerEndpoint<_i4.Quote>(
|
caller.callServerEndpoint<_i3.Quote>(
|
||||||
'quote',
|
'quote',
|
||||||
'createQuote',
|
'createQuote',
|
||||||
{'req': req},
|
{'req': req},
|
||||||
);
|
);
|
||||||
|
|
||||||
_i2.Future<_i4.Quote> getQuoteById(int id) =>
|
_i2.Future<_i3.Quote> getQuoteById(int id) =>
|
||||||
caller.callServerEndpoint<_i4.Quote>(
|
caller.callServerEndpoint<_i3.Quote>(
|
||||||
'quote',
|
'quote',
|
||||||
'getQuoteById',
|
'getQuoteById',
|
||||||
{'id': id},
|
{'id': id},
|
||||||
);
|
);
|
||||||
|
|
||||||
_i2.Future<List<_i4.Quote>> getAllQuotes() =>
|
_i2.Future<List<_i3.Quote>> getAllQuotes() =>
|
||||||
caller.callServerEndpoint<List<_i4.Quote>>(
|
caller.callServerEndpoint<List<_i3.Quote>>(
|
||||||
'quote',
|
'quote',
|
||||||
'getAllQuotes',
|
'getAllQuotes',
|
||||||
{},
|
{},
|
||||||
|
|
@ -81,10 +62,10 @@ class EndpointQuote extends _i1.EndpointRef {
|
||||||
|
|
||||||
class Modules {
|
class Modules {
|
||||||
Modules(Client client) {
|
Modules(Client client) {
|
||||||
auth = _i6.Caller(client);
|
auth = _i5.Caller(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
late final _i6.Caller auth;
|
late final _i5.Caller auth;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Client extends _i1.ServerpodClientShared {
|
class Client extends _i1.ServerpodClientShared {
|
||||||
|
|
@ -103,7 +84,7 @@ class Client extends _i1.ServerpodClientShared {
|
||||||
bool? disconnectStreamsOnLostInternetConnection,
|
bool? disconnectStreamsOnLostInternetConnection,
|
||||||
}) : super(
|
}) : super(
|
||||||
host,
|
host,
|
||||||
_i7.Protocol(),
|
_i6.Protocol(),
|
||||||
securityContext: securityContext,
|
securityContext: securityContext,
|
||||||
authenticationKeyManager: authenticationKeyManager,
|
authenticationKeyManager: authenticationKeyManager,
|
||||||
streamingConnectionTimeout: streamingConnectionTimeout,
|
streamingConnectionTimeout: streamingConnectionTimeout,
|
||||||
|
|
@ -113,22 +94,16 @@ class Client extends _i1.ServerpodClientShared {
|
||||||
disconnectStreamsOnLostInternetConnection:
|
disconnectStreamsOnLostInternetConnection:
|
||||||
disconnectStreamsOnLostInternetConnection,
|
disconnectStreamsOnLostInternetConnection,
|
||||||
) {
|
) {
|
||||||
greeting = EndpointGreeting(this);
|
|
||||||
quote = EndpointQuote(this);
|
quote = EndpointQuote(this);
|
||||||
modules = Modules(this);
|
modules = Modules(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
late final EndpointGreeting greeting;
|
|
||||||
|
|
||||||
late final EndpointQuote quote;
|
late final EndpointQuote quote;
|
||||||
|
|
||||||
late final Modules modules;
|
late final Modules modules;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, _i1.EndpointRef> get endpointRefLookup => {
|
Map<String, _i1.EndpointRef> get endpointRefLookup => {'quote': quote};
|
||||||
'greeting': greeting,
|
|
||||||
'quote': quote,
|
|
||||||
};
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, _i1.ModuleEndpointCaller> get moduleLookup =>
|
Map<String, _i1.ModuleEndpointCaller> get moduleLookup =>
|
||||||
|
|
|
||||||
|
|
@ -1,95 +0,0 @@
|
||||||
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
|
|
||||||
/* To generate run: "serverpod generate" */
|
|
||||||
|
|
||||||
// ignore_for_file: implementation_imports
|
|
||||||
// ignore_for_file: library_private_types_in_public_api
|
|
||||||
// ignore_for_file: non_constant_identifier_names
|
|
||||||
// ignore_for_file: public_member_api_docs
|
|
||||||
// ignore_for_file: type_literal_in_constant_pattern
|
|
||||||
// ignore_for_file: use_super_parameters
|
|
||||||
|
|
||||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
|
||||||
import 'package:serverpod_client/serverpod_client.dart' as _i1;
|
|
||||||
|
|
||||||
/// A greeting message which can be sent to or from the server.
|
|
||||||
abstract class Greeting implements _i1.SerializableModel {
|
|
||||||
Greeting._({
|
|
||||||
required this.message,
|
|
||||||
required this.author,
|
|
||||||
required this.timestamp,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory Greeting({
|
|
||||||
required String message,
|
|
||||||
required String author,
|
|
||||||
required DateTime timestamp,
|
|
||||||
}) = _GreetingImpl;
|
|
||||||
|
|
||||||
factory Greeting.fromJson(Map<String, dynamic> jsonSerialization) {
|
|
||||||
return Greeting(
|
|
||||||
message: jsonSerialization['message'] as String,
|
|
||||||
author: jsonSerialization['author'] as String,
|
|
||||||
timestamp:
|
|
||||||
_i1.DateTimeJsonExtension.fromJson(jsonSerialization['timestamp']),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The greeting message.
|
|
||||||
String message;
|
|
||||||
|
|
||||||
/// The author of the greeting message.
|
|
||||||
String author;
|
|
||||||
|
|
||||||
/// The time when the message was created.
|
|
||||||
DateTime timestamp;
|
|
||||||
|
|
||||||
/// Returns a shallow copy of this [Greeting]
|
|
||||||
/// with some or all fields replaced by the given arguments.
|
|
||||||
@_i1.useResult
|
|
||||||
Greeting copyWith({
|
|
||||||
String? message,
|
|
||||||
String? author,
|
|
||||||
DateTime? timestamp,
|
|
||||||
});
|
|
||||||
@override
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return {
|
|
||||||
'message': message,
|
|
||||||
'author': author,
|
|
||||||
'timestamp': timestamp.toJson(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return _i1.SerializationManager.encode(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _GreetingImpl extends Greeting {
|
|
||||||
_GreetingImpl({
|
|
||||||
required String message,
|
|
||||||
required String author,
|
|
||||||
required DateTime timestamp,
|
|
||||||
}) : super._(
|
|
||||||
message: message,
|
|
||||||
author: author,
|
|
||||||
timestamp: timestamp,
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Returns a shallow copy of this [Greeting]
|
|
||||||
/// with some or all fields replaced by the given arguments.
|
|
||||||
@_i1.useResult
|
|
||||||
@override
|
|
||||||
Greeting copyWith({
|
|
||||||
String? message,
|
|
||||||
String? author,
|
|
||||||
DateTime? timestamp,
|
|
||||||
}) {
|
|
||||||
return Greeting(
|
|
||||||
message: message ?? this.message,
|
|
||||||
author: author ?? this.author,
|
|
||||||
timestamp: timestamp ?? this.timestamp,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -10,12 +10,10 @@
|
||||||
|
|
||||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||||
import 'package:serverpod_client/serverpod_client.dart' as _i1;
|
import 'package:serverpod_client/serverpod_client.dart' as _i1;
|
||||||
import 'greeting.dart' as _i2;
|
import 'quotes/create_quote.dart' as _i2;
|
||||||
import 'quotes/create_quote.dart' as _i3;
|
import 'quotes/quote.dart' as _i3;
|
||||||
import 'quotes/quote.dart' as _i4;
|
import 'package:wien_talks_client/src/protocol/quotes/quote.dart' as _i4;
|
||||||
import 'package:wien_talks_client/src/protocol/quotes/quote.dart' as _i5;
|
import 'package:serverpod_auth_client/serverpod_auth_client.dart' as _i5;
|
||||||
import 'package:serverpod_auth_client/serverpod_auth_client.dart' as _i6;
|
|
||||||
export 'greeting.dart';
|
|
||||||
export 'quotes/create_quote.dart';
|
export 'quotes/create_quote.dart';
|
||||||
export 'quotes/quote.dart';
|
export 'quotes/quote.dart';
|
||||||
export 'client.dart';
|
export 'client.dart';
|
||||||
|
|
@ -33,23 +31,17 @@ class Protocol extends _i1.SerializationManager {
|
||||||
Type? t,
|
Type? t,
|
||||||
]) {
|
]) {
|
||||||
t ??= T;
|
t ??= T;
|
||||||
if (t == _i2.Greeting) {
|
if (t == _i2.CreateQuoteRequest) {
|
||||||
return _i2.Greeting.fromJson(data) as T;
|
return _i2.CreateQuoteRequest.fromJson(data) as T;
|
||||||
}
|
}
|
||||||
if (t == _i3.CreateQuoteRequest) {
|
if (t == _i3.Quote) {
|
||||||
return _i3.CreateQuoteRequest.fromJson(data) as T;
|
return _i3.Quote.fromJson(data) as T;
|
||||||
}
|
}
|
||||||
if (t == _i4.Quote) {
|
if (t == _i1.getType<_i2.CreateQuoteRequest?>()) {
|
||||||
return _i4.Quote.fromJson(data) as T;
|
return (data != null ? _i2.CreateQuoteRequest.fromJson(data) : null) as T;
|
||||||
}
|
}
|
||||||
if (t == _i1.getType<_i2.Greeting?>()) {
|
if (t == _i1.getType<_i3.Quote?>()) {
|
||||||
return (data != null ? _i2.Greeting.fromJson(data) : null) as T;
|
return (data != null ? _i3.Quote.fromJson(data) : null) as T;
|
||||||
}
|
|
||||||
if (t == _i1.getType<_i3.CreateQuoteRequest?>()) {
|
|
||||||
return (data != null ? _i3.CreateQuoteRequest.fromJson(data) : null) as T;
|
|
||||||
}
|
|
||||||
if (t == _i1.getType<_i4.Quote?>()) {
|
|
||||||
return (data != null ? _i4.Quote.fromJson(data) : null) as T;
|
|
||||||
}
|
}
|
||||||
if (t == _i1.getType<List<String>?>()) {
|
if (t == _i1.getType<List<String>?>()) {
|
||||||
return (data != null
|
return (data != null
|
||||||
|
|
@ -61,11 +53,11 @@ class Protocol extends _i1.SerializationManager {
|
||||||
? (data as List).map((e) => deserialize<String>(e)).toList()
|
? (data as List).map((e) => deserialize<String>(e)).toList()
|
||||||
: null) as T;
|
: null) as T;
|
||||||
}
|
}
|
||||||
if (t == List<_i5.Quote>) {
|
if (t == List<_i4.Quote>) {
|
||||||
return (data as List).map((e) => deserialize<_i5.Quote>(e)).toList() as T;
|
return (data as List).map((e) => deserialize<_i4.Quote>(e)).toList() as T;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return _i6.Protocol().deserialize<T>(data, t);
|
return _i5.Protocol().deserialize<T>(data, t);
|
||||||
} on _i1.DeserializationTypeNotFoundException catch (_) {}
|
} on _i1.DeserializationTypeNotFoundException catch (_) {}
|
||||||
return super.deserialize<T>(data, t);
|
return super.deserialize<T>(data, t);
|
||||||
}
|
}
|
||||||
|
|
@ -74,16 +66,13 @@ class Protocol extends _i1.SerializationManager {
|
||||||
String? getClassNameForObject(Object? data) {
|
String? getClassNameForObject(Object? data) {
|
||||||
String? className = super.getClassNameForObject(data);
|
String? className = super.getClassNameForObject(data);
|
||||||
if (className != null) return className;
|
if (className != null) return className;
|
||||||
if (data is _i2.Greeting) {
|
if (data is _i2.CreateQuoteRequest) {
|
||||||
return 'Greeting';
|
|
||||||
}
|
|
||||||
if (data is _i3.CreateQuoteRequest) {
|
|
||||||
return 'CreateQuoteRequest';
|
return 'CreateQuoteRequest';
|
||||||
}
|
}
|
||||||
if (data is _i4.Quote) {
|
if (data is _i3.Quote) {
|
||||||
return 'Quote';
|
return 'Quote';
|
||||||
}
|
}
|
||||||
className = _i6.Protocol().getClassNameForObject(data);
|
className = _i5.Protocol().getClassNameForObject(data);
|
||||||
if (className != null) {
|
if (className != null) {
|
||||||
return 'serverpod_auth.$className';
|
return 'serverpod_auth.$className';
|
||||||
}
|
}
|
||||||
|
|
@ -96,18 +85,15 @@ class Protocol extends _i1.SerializationManager {
|
||||||
if (dataClassName is! String) {
|
if (dataClassName is! String) {
|
||||||
return super.deserializeByClassName(data);
|
return super.deserializeByClassName(data);
|
||||||
}
|
}
|
||||||
if (dataClassName == 'Greeting') {
|
|
||||||
return deserialize<_i2.Greeting>(data['data']);
|
|
||||||
}
|
|
||||||
if (dataClassName == 'CreateQuoteRequest') {
|
if (dataClassName == 'CreateQuoteRequest') {
|
||||||
return deserialize<_i3.CreateQuoteRequest>(data['data']);
|
return deserialize<_i2.CreateQuoteRequest>(data['data']);
|
||||||
}
|
}
|
||||||
if (dataClassName == 'Quote') {
|
if (dataClassName == 'Quote') {
|
||||||
return deserialize<_i4.Quote>(data['data']);
|
return deserialize<_i3.Quote>(data['data']);
|
||||||
}
|
}
|
||||||
if (dataClassName.startsWith('serverpod_auth.')) {
|
if (dataClassName.startsWith('serverpod_auth.')) {
|
||||||
data['className'] = dataClassName.substring(15);
|
data['className'] = dataClassName.substring(15);
|
||||||
return _i6.Protocol().deserializeByClassName(data);
|
return _i5.Protocol().deserializeByClassName(data);
|
||||||
}
|
}
|
||||||
return super.deserializeByClassName(data);
|
return super.deserializeByClassName(data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,75 +47,6 @@ class MyApp extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
|
||||||
const MyHomePage({super.key, required this.title});
|
|
||||||
|
|
||||||
final String title;
|
|
||||||
|
|
||||||
@override
|
|
||||||
MyHomePageState createState() => MyHomePageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyHomePageState extends State<MyHomePage> {
|
|
||||||
/// Holds the last result or null if no result exists yet.
|
|
||||||
String? _resultMessage;
|
|
||||||
|
|
||||||
/// Holds the last error message that we've received from the server or null
|
|
||||||
/// if no error exists yet.
|
|
||||||
String? _errorMessage;
|
|
||||||
|
|
||||||
final _textEditingController = TextEditingController();
|
|
||||||
|
|
||||||
/// Calls the `hello` method of the `greeting` endpoint. Will set either the
|
|
||||||
/// `_resultMessage` or `_errorMessage` field, depending on if the call
|
|
||||||
/// is successful.
|
|
||||||
void _callHello() async {
|
|
||||||
try {
|
|
||||||
final result = await client.greeting.hello(_textEditingController.text);
|
|
||||||
setState(() {
|
|
||||||
_errorMessage = null;
|
|
||||||
_resultMessage = result.message;
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
setState(() {
|
|
||||||
_errorMessage = '$e';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(title: Text(widget.title)),
|
|
||||||
body: Padding(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 16.0),
|
|
||||||
child: TextField(
|
|
||||||
controller: _textEditingController,
|
|
||||||
decoration: const InputDecoration(hintText: 'Enter your name'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 16.0),
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: _callHello,
|
|
||||||
child: const Text('Send to Server'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ResultDisplay(
|
|
||||||
resultMessage: _resultMessage,
|
|
||||||
errorMessage: _errorMessage,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// ResultDisplays shows the result of the call. Either the returned result
|
/// ResultDisplays shows the result of the call. Either the returned result
|
||||||
/// from the `example.greeting` endpoint method or an error message.
|
/// from the `example.greeting` endpoint method or an error message.
|
||||||
class ResultDisplay extends StatelessWidget {
|
class ResultDisplay extends StatelessWidget {
|
||||||
|
|
|
||||||
|
|
@ -11,21 +11,6 @@ class NewsScreen extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var column = Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
HeadingText(text: "Latest news"),
|
|
||||||
...[Text("News 1"), Text("News 2")],
|
|
||||||
SizedBox(
|
|
||||||
height: 30,
|
|
||||||
),
|
|
||||||
OutlinedButton(
|
|
||||||
onPressed: () {
|
|
||||||
context.pushNamed("create_event");
|
|
||||||
},
|
|
||||||
child: Text("Submit your own event")),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
return ScreenWidget(
|
return ScreenWidget(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import Foundation
|
||||||
import connectivity_plus
|
import connectivity_plus
|
||||||
import file_picker
|
import file_picker
|
||||||
import file_selector_macos
|
import file_selector_macos
|
||||||
|
import google_sign_in_ios
|
||||||
import location
|
import location
|
||||||
import path_provider_foundation
|
import path_provider_foundation
|
||||||
import shared_preferences_foundation
|
import shared_preferences_foundation
|
||||||
|
|
@ -17,6 +18,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin"))
|
ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin"))
|
||||||
FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
|
FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
|
||||||
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
||||||
|
FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin"))
|
||||||
LocationPlugin.register(with: registry.registrar(forPlugin: "LocationPlugin"))
|
LocationPlugin.register(with: registry.registrar(forPlugin: "LocationPlugin"))
|
||||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ dependencies:
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^1.0.8
|
cupertino_icons: ^1.0.8
|
||||||
|
google_sign_in: ^7.1.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_lints: '>=3.0.0 <7.0.0'
|
flutter_lints: '>=3.0.0 <7.0.0'
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ COMPOSE_PROJECT := $(shell basename $(shell pwd))
|
||||||
.env: .env.template
|
.env: .env.template
|
||||||
cp -a .env.template .env
|
cp -a .env.template .env
|
||||||
|
|
||||||
.PHONY := local local-env local-stop local-down local-clean
|
.PHONY: local local-env local-stop local-down local-clean
|
||||||
local: .env
|
local: .env
|
||||||
docker compose -f $(COMPOSE_FILE_LOCAL) up -d
|
docker compose -f $(COMPOSE_FILE_LOCAL) up -d
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
import 'package:serverpod/serverpod.dart';
|
import 'package:serverpod/serverpod.dart';
|
||||||
import 'package:serverpod_auth_server/serverpod_auth_server.dart' as auth;
|
import 'package:serverpod_auth_server/serverpod_auth_server.dart' as auth;
|
||||||
import 'package:wien_talks_server/src/birthday_reminder.dart';
|
|
||||||
import 'package:wien_talks_server/src/web/routes/root.dart';
|
import 'package:wien_talks_server/src/web/routes/root.dart';
|
||||||
|
|
||||||
import 'src/generated/endpoints.dart';
|
import 'src/generated/endpoints.dart';
|
||||||
import 'src/generated/protocol.dart';
|
|
||||||
|
|
||||||
// This is the starting point of your Serverpod server. In most cases, you will
|
// This is the starting point of your Serverpod server. In most cases, you will
|
||||||
// only need to make additions to this file if you add future calls, are
|
// only need to make additions to this file if you add future calls, are
|
||||||
|
|
@ -14,7 +12,7 @@ void run(List<String> args) async {
|
||||||
// Initialize Serverpod and connect it with your generated code.
|
// Initialize Serverpod and connect it with your generated code.
|
||||||
final pod = Serverpod(
|
final pod = Serverpod(
|
||||||
args,
|
args,
|
||||||
Protocol(),
|
auth.Protocol(),
|
||||||
Endpoints(),
|
Endpoints(),
|
||||||
authenticationHandler: auth.authenticationHandler,
|
authenticationHandler: auth.authenticationHandler,
|
||||||
);
|
);
|
||||||
|
|
@ -38,28 +36,8 @@ void run(List<String> args) async {
|
||||||
// the background. Their schedule is persisted to the database, so you will
|
// the background. Their schedule is persisted to the database, so you will
|
||||||
// not lose them if the server is restarted.
|
// not lose them if the server is restarted.
|
||||||
|
|
||||||
pod.registerFutureCall(
|
|
||||||
BirthdayReminder(),
|
|
||||||
FutureCallNames.birthdayReminder.name,
|
|
||||||
);
|
|
||||||
|
|
||||||
// You can schedule future calls for a later time during startup. But you can
|
// You can schedule future calls for a later time during startup. But you can
|
||||||
// also schedule them in any endpoint or webroute through the session object.
|
// also schedule them in any endpoint or webroute through the session object.
|
||||||
// there is also [futureCallAtTime] if you want to schedule a future call at a
|
// there is also [futureCallAtTime] if you want to schedule a future call at a
|
||||||
// specific time.
|
// specific time.
|
||||||
await pod.futureCallWithDelay(
|
|
||||||
FutureCallNames.birthdayReminder.name,
|
|
||||||
Greeting(
|
|
||||||
message: 'Hello!',
|
|
||||||
author: 'Serverpod Server',
|
|
||||||
timestamp: DateTime.now(),
|
|
||||||
),
|
|
||||||
Duration(seconds: 5),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Names of all future calls in the server.
|
|
||||||
///
|
|
||||||
/// This is better than using a string literal, as it will reduce the risk of
|
|
||||||
/// typos and make it easier to refactor the code.
|
|
||||||
enum FutureCallNames { birthdayReminder }
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
import 'package:wien_talks_server/src/generated/protocol.dart';
|
|
||||||
import 'package:serverpod/serverpod.dart';
|
|
||||||
|
|
||||||
/// This is a simple example of a future call that logs a birthday reminder.
|
|
||||||
///
|
|
||||||
/// In a real-world application, you would implement the logic to send a
|
|
||||||
/// an email or a push notification to the user.
|
|
||||||
class BirthdayReminder extends FutureCall<Greeting> {
|
|
||||||
@override
|
|
||||||
Future<void> invoke(Session session, Greeting? object) async {
|
|
||||||
// This is where you would implement the logic to send a birthday reminder.
|
|
||||||
// For example, you could send an email or a notification to the user.
|
|
||||||
// You can access the user information from the `object` parameter if
|
|
||||||
// needed.
|
|
||||||
|
|
||||||
session.log('${object?.message} Remember to send a birthday card!');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -10,54 +10,23 @@
|
||||||
|
|
||||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||||
import 'package:serverpod/serverpod.dart' as _i1;
|
import 'package:serverpod/serverpod.dart' as _i1;
|
||||||
import '../greeting_endpoint.dart' as _i2;
|
import '../quotes/quotes_endpoint.dart' as _i2;
|
||||||
import '../quotes/quotes_endpoint.dart' as _i3;
|
import 'package:wien_talks_server/src/generated/quotes/quote.dart' as _i3;
|
||||||
import 'package:wien_talks_server/src/generated/quotes/quote.dart' as _i4;
|
|
||||||
import 'package:wien_talks_server/src/generated/quotes/create_quote.dart'
|
import 'package:wien_talks_server/src/generated/quotes/create_quote.dart'
|
||||||
as _i5;
|
as _i4;
|
||||||
import 'package:serverpod_auth_server/serverpod_auth_server.dart' as _i6;
|
import 'package:serverpod_auth_server/serverpod_auth_server.dart' as _i5;
|
||||||
|
|
||||||
class Endpoints extends _i1.EndpointDispatch {
|
class Endpoints extends _i1.EndpointDispatch {
|
||||||
@override
|
@override
|
||||||
void initializeEndpoints(_i1.Server server) {
|
void initializeEndpoints(_i1.Server server) {
|
||||||
var endpoints = <String, _i1.Endpoint>{
|
var endpoints = <String, _i1.Endpoint>{
|
||||||
'greeting': _i2.GreetingEndpoint()
|
'quote': _i2.QuoteEndpoint()
|
||||||
..initialize(
|
|
||||||
server,
|
|
||||||
'greeting',
|
|
||||||
null,
|
|
||||||
),
|
|
||||||
'quote': _i3.QuoteEndpoint()
|
|
||||||
..initialize(
|
..initialize(
|
||||||
server,
|
server,
|
||||||
'quote',
|
'quote',
|
||||||
null,
|
null,
|
||||||
),
|
|
||||||
};
|
|
||||||
connectors['greeting'] = _i1.EndpointConnector(
|
|
||||||
name: 'greeting',
|
|
||||||
endpoint: endpoints['greeting']!,
|
|
||||||
methodConnectors: {
|
|
||||||
'hello': _i1.MethodConnector(
|
|
||||||
name: 'hello',
|
|
||||||
params: {
|
|
||||||
'name': _i1.ParameterDescription(
|
|
||||||
name: 'name',
|
|
||||||
type: _i1.getType<String>(),
|
|
||||||
nullable: false,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
call: (
|
|
||||||
_i1.Session session,
|
|
||||||
Map<String, dynamic> params,
|
|
||||||
) async =>
|
|
||||||
(endpoints['greeting'] as _i2.GreetingEndpoint).hello(
|
|
||||||
session,
|
|
||||||
params['name'],
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
},
|
};
|
||||||
);
|
|
||||||
connectors['quote'] = _i1.EndpointConnector(
|
connectors['quote'] = _i1.EndpointConnector(
|
||||||
name: 'quote',
|
name: 'quote',
|
||||||
endpoint: endpoints['quote']!,
|
endpoint: endpoints['quote']!,
|
||||||
|
|
@ -67,7 +36,7 @@ class Endpoints extends _i1.EndpointDispatch {
|
||||||
params: {
|
params: {
|
||||||
'quote': _i1.ParameterDescription(
|
'quote': _i1.ParameterDescription(
|
||||||
name: 'quote',
|
name: 'quote',
|
||||||
type: _i1.getType<_i4.Quote>(),
|
type: _i1.getType<_i3.Quote>(),
|
||||||
nullable: false,
|
nullable: false,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
@ -75,7 +44,7 @@ class Endpoints extends _i1.EndpointDispatch {
|
||||||
_i1.Session session,
|
_i1.Session session,
|
||||||
Map<String, dynamic> params,
|
Map<String, dynamic> params,
|
||||||
) async =>
|
) async =>
|
||||||
(endpoints['quote'] as _i3.QuoteEndpoint).updateQuote(
|
(endpoints['quote'] as _i2.QuoteEndpoint).updateQuote(
|
||||||
session,
|
session,
|
||||||
params['quote'],
|
params['quote'],
|
||||||
),
|
),
|
||||||
|
|
@ -85,7 +54,7 @@ class Endpoints extends _i1.EndpointDispatch {
|
||||||
params: {
|
params: {
|
||||||
'req': _i1.ParameterDescription(
|
'req': _i1.ParameterDescription(
|
||||||
name: 'req',
|
name: 'req',
|
||||||
type: _i1.getType<_i5.CreateQuoteRequest>(),
|
type: _i1.getType<_i4.CreateQuoteRequest>(),
|
||||||
nullable: false,
|
nullable: false,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
@ -93,7 +62,7 @@ class Endpoints extends _i1.EndpointDispatch {
|
||||||
_i1.Session session,
|
_i1.Session session,
|
||||||
Map<String, dynamic> params,
|
Map<String, dynamic> params,
|
||||||
) async =>
|
) async =>
|
||||||
(endpoints['quote'] as _i3.QuoteEndpoint).createQuote(
|
(endpoints['quote'] as _i2.QuoteEndpoint).createQuote(
|
||||||
session,
|
session,
|
||||||
params['req'],
|
params['req'],
|
||||||
),
|
),
|
||||||
|
|
@ -111,7 +80,7 @@ class Endpoints extends _i1.EndpointDispatch {
|
||||||
_i1.Session session,
|
_i1.Session session,
|
||||||
Map<String, dynamic> params,
|
Map<String, dynamic> params,
|
||||||
) async =>
|
) async =>
|
||||||
(endpoints['quote'] as _i3.QuoteEndpoint).getQuoteById(
|
(endpoints['quote'] as _i2.QuoteEndpoint).getQuoteById(
|
||||||
session,
|
session,
|
||||||
params['id'],
|
params['id'],
|
||||||
),
|
),
|
||||||
|
|
@ -123,7 +92,7 @@ class Endpoints extends _i1.EndpointDispatch {
|
||||||
_i1.Session session,
|
_i1.Session session,
|
||||||
Map<String, dynamic> params,
|
Map<String, dynamic> params,
|
||||||
) async =>
|
) async =>
|
||||||
(endpoints['quote'] as _i3.QuoteEndpoint).getAllQuotes(session),
|
(endpoints['quote'] as _i2.QuoteEndpoint).getAllQuotes(session),
|
||||||
),
|
),
|
||||||
'quoteUpdates': _i1.MethodStreamConnector(
|
'quoteUpdates': _i1.MethodStreamConnector(
|
||||||
name: 'quoteUpdates',
|
name: 'quoteUpdates',
|
||||||
|
|
@ -135,10 +104,10 @@ class Endpoints extends _i1.EndpointDispatch {
|
||||||
Map<String, dynamic> params,
|
Map<String, dynamic> params,
|
||||||
Map<String, Stream> streamParams,
|
Map<String, Stream> streamParams,
|
||||||
) =>
|
) =>
|
||||||
(endpoints['quote'] as _i3.QuoteEndpoint).quoteUpdates(session),
|
(endpoints['quote'] as _i2.QuoteEndpoint).quoteUpdates(session),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
modules['serverpod_auth'] = _i6.Endpoints()..initializeEndpoints(server);
|
modules['serverpod_auth'] = _i5.Endpoints()..initializeEndpoints(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,105 +0,0 @@
|
||||||
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
|
|
||||||
/* To generate run: "serverpod generate" */
|
|
||||||
|
|
||||||
// ignore_for_file: implementation_imports
|
|
||||||
// ignore_for_file: library_private_types_in_public_api
|
|
||||||
// ignore_for_file: non_constant_identifier_names
|
|
||||||
// ignore_for_file: public_member_api_docs
|
|
||||||
// ignore_for_file: type_literal_in_constant_pattern
|
|
||||||
// ignore_for_file: use_super_parameters
|
|
||||||
|
|
||||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
|
||||||
import 'package:serverpod/serverpod.dart' as _i1;
|
|
||||||
|
|
||||||
/// A greeting message which can be sent to or from the server.
|
|
||||||
abstract class Greeting
|
|
||||||
implements _i1.SerializableModel, _i1.ProtocolSerialization {
|
|
||||||
Greeting._({
|
|
||||||
required this.message,
|
|
||||||
required this.author,
|
|
||||||
required this.timestamp,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory Greeting({
|
|
||||||
required String message,
|
|
||||||
required String author,
|
|
||||||
required DateTime timestamp,
|
|
||||||
}) = _GreetingImpl;
|
|
||||||
|
|
||||||
factory Greeting.fromJson(Map<String, dynamic> jsonSerialization) {
|
|
||||||
return Greeting(
|
|
||||||
message: jsonSerialization['message'] as String,
|
|
||||||
author: jsonSerialization['author'] as String,
|
|
||||||
timestamp:
|
|
||||||
_i1.DateTimeJsonExtension.fromJson(jsonSerialization['timestamp']),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The greeting message.
|
|
||||||
String message;
|
|
||||||
|
|
||||||
/// The author of the greeting message.
|
|
||||||
String author;
|
|
||||||
|
|
||||||
/// The time when the message was created.
|
|
||||||
DateTime timestamp;
|
|
||||||
|
|
||||||
/// Returns a shallow copy of this [Greeting]
|
|
||||||
/// with some or all fields replaced by the given arguments.
|
|
||||||
@_i1.useResult
|
|
||||||
Greeting copyWith({
|
|
||||||
String? message,
|
|
||||||
String? author,
|
|
||||||
DateTime? timestamp,
|
|
||||||
});
|
|
||||||
@override
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return {
|
|
||||||
'message': message,
|
|
||||||
'author': author,
|
|
||||||
'timestamp': timestamp.toJson(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Map<String, dynamic> toJsonForProtocol() {
|
|
||||||
return {
|
|
||||||
'message': message,
|
|
||||||
'author': author,
|
|
||||||
'timestamp': timestamp.toJson(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return _i1.SerializationManager.encode(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _GreetingImpl extends Greeting {
|
|
||||||
_GreetingImpl({
|
|
||||||
required String message,
|
|
||||||
required String author,
|
|
||||||
required DateTime timestamp,
|
|
||||||
}) : super._(
|
|
||||||
message: message,
|
|
||||||
author: author,
|
|
||||||
timestamp: timestamp,
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Returns a shallow copy of this [Greeting]
|
|
||||||
/// with some or all fields replaced by the given arguments.
|
|
||||||
@_i1.useResult
|
|
||||||
@override
|
|
||||||
Greeting copyWith({
|
|
||||||
String? message,
|
|
||||||
String? author,
|
|
||||||
DateTime? timestamp,
|
|
||||||
}) {
|
|
||||||
return Greeting(
|
|
||||||
message: message ?? this.message,
|
|
||||||
author: author ?? this.author,
|
|
||||||
timestamp: timestamp ?? this.timestamp,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -12,11 +12,9 @@
|
||||||
import 'package:serverpod/serverpod.dart' as _i1;
|
import 'package:serverpod/serverpod.dart' as _i1;
|
||||||
import 'package:serverpod/protocol.dart' as _i2;
|
import 'package:serverpod/protocol.dart' as _i2;
|
||||||
import 'package:serverpod_auth_server/serverpod_auth_server.dart' as _i3;
|
import 'package:serverpod_auth_server/serverpod_auth_server.dart' as _i3;
|
||||||
import 'greeting.dart' as _i4;
|
import 'quotes/create_quote.dart' as _i4;
|
||||||
import 'quotes/create_quote.dart' as _i5;
|
import 'quotes/quote.dart' as _i5;
|
||||||
import 'quotes/quote.dart' as _i6;
|
import 'package:wien_talks_server/src/generated/quotes/quote.dart' as _i6;
|
||||||
import 'package:wien_talks_server/src/generated/quotes/quote.dart' as _i7;
|
|
||||||
export 'greeting.dart';
|
|
||||||
export 'quotes/create_quote.dart';
|
export 'quotes/create_quote.dart';
|
||||||
export 'quotes/quote.dart';
|
export 'quotes/quote.dart';
|
||||||
|
|
||||||
|
|
@ -130,23 +128,17 @@ class Protocol extends _i1.SerializationManagerServer {
|
||||||
Type? t,
|
Type? t,
|
||||||
]) {
|
]) {
|
||||||
t ??= T;
|
t ??= T;
|
||||||
if (t == _i4.Greeting) {
|
if (t == _i4.CreateQuoteRequest) {
|
||||||
return _i4.Greeting.fromJson(data) as T;
|
return _i4.CreateQuoteRequest.fromJson(data) as T;
|
||||||
}
|
}
|
||||||
if (t == _i5.CreateQuoteRequest) {
|
if (t == _i5.Quote) {
|
||||||
return _i5.CreateQuoteRequest.fromJson(data) as T;
|
return _i5.Quote.fromJson(data) as T;
|
||||||
}
|
}
|
||||||
if (t == _i6.Quote) {
|
if (t == _i1.getType<_i4.CreateQuoteRequest?>()) {
|
||||||
return _i6.Quote.fromJson(data) as T;
|
return (data != null ? _i4.CreateQuoteRequest.fromJson(data) : null) as T;
|
||||||
}
|
}
|
||||||
if (t == _i1.getType<_i4.Greeting?>()) {
|
if (t == _i1.getType<_i5.Quote?>()) {
|
||||||
return (data != null ? _i4.Greeting.fromJson(data) : null) as T;
|
return (data != null ? _i5.Quote.fromJson(data) : null) as T;
|
||||||
}
|
|
||||||
if (t == _i1.getType<_i5.CreateQuoteRequest?>()) {
|
|
||||||
return (data != null ? _i5.CreateQuoteRequest.fromJson(data) : null) as T;
|
|
||||||
}
|
|
||||||
if (t == _i1.getType<_i6.Quote?>()) {
|
|
||||||
return (data != null ? _i6.Quote.fromJson(data) : null) as T;
|
|
||||||
}
|
}
|
||||||
if (t == _i1.getType<List<String>?>()) {
|
if (t == _i1.getType<List<String>?>()) {
|
||||||
return (data != null
|
return (data != null
|
||||||
|
|
@ -158,8 +150,8 @@ class Protocol extends _i1.SerializationManagerServer {
|
||||||
? (data as List).map((e) => deserialize<String>(e)).toList()
|
? (data as List).map((e) => deserialize<String>(e)).toList()
|
||||||
: null) as T;
|
: null) as T;
|
||||||
}
|
}
|
||||||
if (t == List<_i7.Quote>) {
|
if (t == List<_i6.Quote>) {
|
||||||
return (data as List).map((e) => deserialize<_i7.Quote>(e)).toList() as T;
|
return (data as List).map((e) => deserialize<_i6.Quote>(e)).toList() as T;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return _i3.Protocol().deserialize<T>(data, t);
|
return _i3.Protocol().deserialize<T>(data, t);
|
||||||
|
|
@ -174,13 +166,10 @@ class Protocol extends _i1.SerializationManagerServer {
|
||||||
String? getClassNameForObject(Object? data) {
|
String? getClassNameForObject(Object? data) {
|
||||||
String? className = super.getClassNameForObject(data);
|
String? className = super.getClassNameForObject(data);
|
||||||
if (className != null) return className;
|
if (className != null) return className;
|
||||||
if (data is _i4.Greeting) {
|
if (data is _i4.CreateQuoteRequest) {
|
||||||
return 'Greeting';
|
|
||||||
}
|
|
||||||
if (data is _i5.CreateQuoteRequest) {
|
|
||||||
return 'CreateQuoteRequest';
|
return 'CreateQuoteRequest';
|
||||||
}
|
}
|
||||||
if (data is _i6.Quote) {
|
if (data is _i5.Quote) {
|
||||||
return 'Quote';
|
return 'Quote';
|
||||||
}
|
}
|
||||||
className = _i2.Protocol().getClassNameForObject(data);
|
className = _i2.Protocol().getClassNameForObject(data);
|
||||||
|
|
@ -200,14 +189,11 @@ class Protocol extends _i1.SerializationManagerServer {
|
||||||
if (dataClassName is! String) {
|
if (dataClassName is! String) {
|
||||||
return super.deserializeByClassName(data);
|
return super.deserializeByClassName(data);
|
||||||
}
|
}
|
||||||
if (dataClassName == 'Greeting') {
|
|
||||||
return deserialize<_i4.Greeting>(data['data']);
|
|
||||||
}
|
|
||||||
if (dataClassName == 'CreateQuoteRequest') {
|
if (dataClassName == 'CreateQuoteRequest') {
|
||||||
return deserialize<_i5.CreateQuoteRequest>(data['data']);
|
return deserialize<_i4.CreateQuoteRequest>(data['data']);
|
||||||
}
|
}
|
||||||
if (dataClassName == 'Quote') {
|
if (dataClassName == 'Quote') {
|
||||||
return deserialize<_i6.Quote>(data['data']);
|
return deserialize<_i5.Quote>(data['data']);
|
||||||
}
|
}
|
||||||
if (dataClassName.startsWith('serverpod.')) {
|
if (dataClassName.startsWith('serverpod.')) {
|
||||||
data['className'] = dataClassName.substring(10);
|
data['className'] = dataClassName.substring(10);
|
||||||
|
|
@ -235,8 +221,8 @@ class Protocol extends _i1.SerializationManagerServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case _i6.Quote:
|
case _i5.Quote:
|
||||||
return _i6.Quote.t;
|
return _i5.Quote.t;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
greeting:
|
|
||||||
- hello:
|
|
||||||
quote:
|
quote:
|
||||||
- updateQuote:
|
- updateQuote:
|
||||||
- quoteUpdates:
|
- quoteUpdates:
|
||||||
|
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
# Yaml-files in the `models` directory specify which serializable objects
|
|
||||||
# should be generated. When you add or modify a file, you will need to run
|
|
||||||
# `serverpod generate` to make the generated classes available in the server and
|
|
||||||
# client.
|
|
||||||
#
|
|
||||||
# Please consult the documentation for more information on what you can add to
|
|
||||||
# your yaml-files.
|
|
||||||
|
|
||||||
### A greeting message which can be sent to or from the server.
|
|
||||||
class: Greeting
|
|
||||||
|
|
||||||
# Add the table key, if this class represents a row in the database.
|
|
||||||
#table: greeting
|
|
||||||
|
|
||||||
# The fields (and columns if connected to the database) of the class.
|
|
||||||
# For a list of supported types, please see the documentation.
|
|
||||||
# https://docs.serverpod.dev/concepts/working-with-endpoints
|
|
||||||
fields:
|
|
||||||
### The greeting message.
|
|
||||||
message: String
|
|
||||||
### The author of the greeting message.
|
|
||||||
author: String
|
|
||||||
### The time when the message was created.
|
|
||||||
timestamp: DateTime
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
import 'generated/protocol.dart';
|
|
||||||
import 'package:serverpod/serverpod.dart';
|
|
||||||
|
|
||||||
// This is an example endpoint of your server. It's best practice to use the
|
|
||||||
// `Endpoint` ending of the class name, but it will be removed when accessing
|
|
||||||
// the endpoint from the client. I.e., this endpoint can be accessed through
|
|
||||||
// `client.greeting` on the client side.
|
|
||||||
|
|
||||||
// After adding or modifying an endpoint, you will need to run
|
|
||||||
// `serverpod generate` to update the server and client code.
|
|
||||||
|
|
||||||
/// This is an example endpoint that returns a greeting message through
|
|
||||||
/// its [hello] method.
|
|
||||||
class GreetingEndpoint extends Endpoint {
|
|
||||||
// This method is called when the client calls the `hello` method on the
|
|
||||||
// `greeting` endpoint.
|
|
||||||
//
|
|
||||||
// The `Session` parameter contains the context of the client request.
|
|
||||||
// It provides access to the database and other server-side resources like
|
|
||||||
// secrets from your password file, the cache, storage, and server-event
|
|
||||||
// messaging.
|
|
||||||
//
|
|
||||||
// You can use any serializable type as a parameter or return type, read more
|
|
||||||
// in the [docs](https://docs.serverpod.dev/concepts/working-with-endpoints).
|
|
||||||
|
|
||||||
/// Returns a personalized greeting message: "Hello {name}".
|
|
||||||
Future<Greeting> hello(Session session, String name) async {
|
|
||||||
return Greeting(
|
|
||||||
message: 'Hello $name',
|
|
||||||
author: 'Serverpod',
|
|
||||||
timestamp: DateTime.now(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:serverpod/serverpod.dart';
|
import 'package:serverpod/serverpod.dart';
|
||||||
import 'package:wien_talks_server/src/generated/protocol.dart';
|
import 'package:wien_talks_server/src/generated/protocol.dart';
|
||||||
import 'package:wien_talks_server/src/quotes/quote_util.dart';
|
import 'package:wien_talks_server/src/quotes/quote_util.dart';
|
||||||
|
|
@ -21,21 +23,14 @@ class QuoteEndpoint extends Endpoint {
|
||||||
|
|
||||||
Future<Quote> createQuote(Session session, CreateQuoteRequest req) async {
|
Future<Quote> createQuote(Session session, CreateQuoteRequest req) async {
|
||||||
final authInfo = await session.authenticated;
|
final authInfo = await session.authenticated;
|
||||||
final userId = authInfo?.userId;
|
final userId = Random().nextInt(100);
|
||||||
|
|
||||||
if (userId == null) {
|
|
||||||
throw Exception('Not signed in');
|
|
||||||
}
|
|
||||||
|
|
||||||
String text = validateQuote(req);
|
String text = validateQuote(req);
|
||||||
|
|
||||||
final quote = Quote(
|
final quote = Quote(
|
||||||
id: 0,
|
|
||||||
userId: userId,
|
userId: userId,
|
||||||
text: text,
|
text: text,
|
||||||
authorName: req.authorName?.trim().isEmpty == true
|
authorName: req.authorName,
|
||||||
? null
|
|
||||||
: req.authorName!.trim(),
|
|
||||||
lat: req.lat,
|
lat: req.lat,
|
||||||
long: req.lng,
|
long: req.lng,
|
||||||
createdAt: DateTime.now().toUtc(),
|
createdAt: DateTime.now().toUtc(),
|
||||||
|
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
import 'package:test/test.dart';
|
|
||||||
|
|
||||||
// Import the generated test helper file, it contains everything you need.
|
|
||||||
import 'test_tools/serverpod_test_tools.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
// This is an example test that uses the `withServerpod` test helper.
|
|
||||||
// `withServerpod` enables you to call your endpoints directly from the test like regular functions.
|
|
||||||
// Note that after adding or modifying an endpoint, you will need to run
|
|
||||||
// `serverpod generate` to update the test tools code.
|
|
||||||
// Refer to the docs for more information on how to use the test helper.
|
|
||||||
withServerpod('Given Greeting endpoint', (sessionBuilder, endpoints) {
|
|
||||||
test(
|
|
||||||
'when calling `hello` with name then returned greeting includes name',
|
|
||||||
() async {
|
|
||||||
// Call the endpoint method by using the `endpoints` parameter and
|
|
||||||
// pass `sessionBuilder` as a first argument. Refer to the docs on
|
|
||||||
// how to use the `sessionBuilder` to set up different test scenarios.
|
|
||||||
final greeting = await endpoints.greeting.hello(sessionBuilder, 'Bob');
|
|
||||||
expect(greeting.message, 'Hello Bob');
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -14,10 +14,9 @@
|
||||||
import 'package:serverpod_test/serverpod_test.dart' as _i1;
|
import 'package:serverpod_test/serverpod_test.dart' as _i1;
|
||||||
import 'package:serverpod/serverpod.dart' as _i2;
|
import 'package:serverpod/serverpod.dart' as _i2;
|
||||||
import 'dart:async' as _i3;
|
import 'dart:async' as _i3;
|
||||||
import 'package:wien_talks_server/src/generated/greeting.dart' as _i4;
|
import 'package:wien_talks_server/src/generated/quotes/quote.dart' as _i4;
|
||||||
import 'package:wien_talks_server/src/generated/quotes/quote.dart' as _i5;
|
|
||||||
import 'package:wien_talks_server/src/generated/quotes/create_quote.dart'
|
import 'package:wien_talks_server/src/generated/quotes/create_quote.dart'
|
||||||
as _i6;
|
as _i5;
|
||||||
import 'package:wien_talks_server/src/generated/protocol.dart';
|
import 'package:wien_talks_server/src/generated/protocol.dart';
|
||||||
import 'package:wien_talks_server/src/generated/endpoints.dart';
|
import 'package:wien_talks_server/src/generated/endpoints.dart';
|
||||||
export 'package:serverpod_test/serverpod_test_public_exports.dart';
|
export 'package:serverpod_test/serverpod_test_public_exports.dart';
|
||||||
|
|
@ -104,8 +103,6 @@ void withServerpod(
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestEndpoints {
|
class TestEndpoints {
|
||||||
late final _GreetingEndpoint greeting;
|
|
||||||
|
|
||||||
late final _QuoteEndpoint quote;
|
late final _QuoteEndpoint quote;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,10 +113,6 @@ class _InternalTestEndpoints extends TestEndpoints
|
||||||
_i2.SerializationManager serializationManager,
|
_i2.SerializationManager serializationManager,
|
||||||
_i2.EndpointDispatch endpoints,
|
_i2.EndpointDispatch endpoints,
|
||||||
) {
|
) {
|
||||||
greeting = _GreetingEndpoint(
|
|
||||||
endpoints,
|
|
||||||
serializationManager,
|
|
||||||
);
|
|
||||||
quote = _QuoteEndpoint(
|
quote = _QuoteEndpoint(
|
||||||
endpoints,
|
endpoints,
|
||||||
serializationManager,
|
serializationManager,
|
||||||
|
|
@ -127,46 +120,6 @@ class _InternalTestEndpoints extends TestEndpoints
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _GreetingEndpoint {
|
|
||||||
_GreetingEndpoint(
|
|
||||||
this._endpointDispatch,
|
|
||||||
this._serializationManager,
|
|
||||||
);
|
|
||||||
|
|
||||||
final _i2.EndpointDispatch _endpointDispatch;
|
|
||||||
|
|
||||||
final _i2.SerializationManager _serializationManager;
|
|
||||||
|
|
||||||
_i3.Future<_i4.Greeting> hello(
|
|
||||||
_i1.TestSessionBuilder sessionBuilder,
|
|
||||||
String name,
|
|
||||||
) async {
|
|
||||||
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
|
||||||
var _localUniqueSession =
|
|
||||||
(sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild(
|
|
||||||
endpoint: 'greeting',
|
|
||||||
method: 'hello',
|
|
||||||
);
|
|
||||||
try {
|
|
||||||
var _localCallContext = await _endpointDispatch.getMethodCallContext(
|
|
||||||
createSessionCallback: (_) => _localUniqueSession,
|
|
||||||
endpointPath: 'greeting',
|
|
||||||
methodName: 'hello',
|
|
||||||
parameters: _i1.testObjectToJson({'name': name}),
|
|
||||||
serializationManager: _serializationManager,
|
|
||||||
);
|
|
||||||
var _localReturnValue = await (_localCallContext.method.call(
|
|
||||||
_localUniqueSession,
|
|
||||||
_localCallContext.arguments,
|
|
||||||
) as _i3.Future<_i4.Greeting>);
|
|
||||||
return _localReturnValue;
|
|
||||||
} finally {
|
|
||||||
await _localUniqueSession.close();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _QuoteEndpoint {
|
class _QuoteEndpoint {
|
||||||
_QuoteEndpoint(
|
_QuoteEndpoint(
|
||||||
this._endpointDispatch,
|
this._endpointDispatch,
|
||||||
|
|
@ -179,7 +132,7 @@ class _QuoteEndpoint {
|
||||||
|
|
||||||
_i3.Future<void> updateQuote(
|
_i3.Future<void> updateQuote(
|
||||||
_i1.TestSessionBuilder sessionBuilder,
|
_i1.TestSessionBuilder sessionBuilder,
|
||||||
_i5.Quote quote,
|
_i4.Quote quote,
|
||||||
) async {
|
) async {
|
||||||
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
||||||
var _localUniqueSession =
|
var _localUniqueSession =
|
||||||
|
|
@ -206,8 +159,8 @@ class _QuoteEndpoint {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_i3.Stream<_i5.Quote> quoteUpdates(_i1.TestSessionBuilder sessionBuilder) {
|
_i3.Stream<_i4.Quote> quoteUpdates(_i1.TestSessionBuilder sessionBuilder) {
|
||||||
var _localTestStreamManager = _i1.TestStreamManager<_i5.Quote>();
|
var _localTestStreamManager = _i1.TestStreamManager<_i4.Quote>();
|
||||||
_i1.callStreamFunctionAndHandleExceptions(
|
_i1.callStreamFunctionAndHandleExceptions(
|
||||||
() async {
|
() async {
|
||||||
var _localUniqueSession =
|
var _localUniqueSession =
|
||||||
|
|
@ -235,9 +188,9 @@ class _QuoteEndpoint {
|
||||||
return _localTestStreamManager.outputStreamController.stream;
|
return _localTestStreamManager.outputStreamController.stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
_i3.Future<_i5.Quote> createQuote(
|
_i3.Future<_i4.Quote> createQuote(
|
||||||
_i1.TestSessionBuilder sessionBuilder,
|
_i1.TestSessionBuilder sessionBuilder,
|
||||||
_i6.CreateQuoteRequest req,
|
_i5.CreateQuoteRequest req,
|
||||||
) async {
|
) async {
|
||||||
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
||||||
var _localUniqueSession =
|
var _localUniqueSession =
|
||||||
|
|
@ -256,7 +209,7 @@ class _QuoteEndpoint {
|
||||||
var _localReturnValue = await (_localCallContext.method.call(
|
var _localReturnValue = await (_localCallContext.method.call(
|
||||||
_localUniqueSession,
|
_localUniqueSession,
|
||||||
_localCallContext.arguments,
|
_localCallContext.arguments,
|
||||||
) as _i3.Future<_i5.Quote>);
|
) as _i3.Future<_i4.Quote>);
|
||||||
return _localReturnValue;
|
return _localReturnValue;
|
||||||
} finally {
|
} finally {
|
||||||
await _localUniqueSession.close();
|
await _localUniqueSession.close();
|
||||||
|
|
@ -264,7 +217,7 @@ class _QuoteEndpoint {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_i3.Future<_i5.Quote> getQuoteById(
|
_i3.Future<_i4.Quote> getQuoteById(
|
||||||
_i1.TestSessionBuilder sessionBuilder,
|
_i1.TestSessionBuilder sessionBuilder,
|
||||||
int id,
|
int id,
|
||||||
) async {
|
) async {
|
||||||
|
|
@ -285,7 +238,7 @@ class _QuoteEndpoint {
|
||||||
var _localReturnValue = await (_localCallContext.method.call(
|
var _localReturnValue = await (_localCallContext.method.call(
|
||||||
_localUniqueSession,
|
_localUniqueSession,
|
||||||
_localCallContext.arguments,
|
_localCallContext.arguments,
|
||||||
) as _i3.Future<_i5.Quote>);
|
) as _i3.Future<_i4.Quote>);
|
||||||
return _localReturnValue;
|
return _localReturnValue;
|
||||||
} finally {
|
} finally {
|
||||||
await _localUniqueSession.close();
|
await _localUniqueSession.close();
|
||||||
|
|
@ -293,7 +246,7 @@ class _QuoteEndpoint {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_i3.Future<List<_i5.Quote>> getAllQuotes(
|
_i3.Future<List<_i4.Quote>> getAllQuotes(
|
||||||
_i1.TestSessionBuilder sessionBuilder) async {
|
_i1.TestSessionBuilder sessionBuilder) async {
|
||||||
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
||||||
var _localUniqueSession =
|
var _localUniqueSession =
|
||||||
|
|
@ -312,7 +265,7 @@ class _QuoteEndpoint {
|
||||||
var _localReturnValue = await (_localCallContext.method.call(
|
var _localReturnValue = await (_localCallContext.method.call(
|
||||||
_localUniqueSession,
|
_localUniqueSession,
|
||||||
_localCallContext.arguments,
|
_localCallContext.arguments,
|
||||||
) as _i3.Future<List<_i5.Quote>>);
|
) as _i3.Future<List<_i4.Quote>>);
|
||||||
return _localReturnValue;
|
return _localReturnValue;
|
||||||
} finally {
|
} finally {
|
||||||
await _localUniqueSession.close();
|
await _localUniqueSession.close();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue