chore: remove the greetings demo
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
a4fcd98e4a
commit
059f33ef80
8 changed files with 12 additions and 606 deletions
|
|
@ -17,7 +17,6 @@ import 'package:serverpod_auth_idp_server/serverpod_auth_idp_server.dart'
|
|||
as _iais;
|
||||
import '../auth/email_idp_endpoint.dart' as _iuc1hd5t;
|
||||
import '../auth/jwt_refresh_endpoint.dart' as _inwq3ztq;
|
||||
import '../greetings/greeting_endpoint.dart' as _il624ik7;
|
||||
|
||||
class Endpoints extends _is.EndpointDispatch {
|
||||
@override
|
||||
|
|
@ -35,12 +34,6 @@ class Endpoints extends _is.EndpointDispatch {
|
|||
'jwtRefresh',
|
||||
null,
|
||||
),
|
||||
'greeting': _il624ik7.GreetingEndpoint()
|
||||
..initialize(
|
||||
server,
|
||||
'greeting',
|
||||
null,
|
||||
),
|
||||
};
|
||||
connectors['emailIdp'] = _is.EndpointConnector(
|
||||
name: 'emailIdp',
|
||||
|
|
@ -248,31 +241,6 @@ class Endpoints extends _is.EndpointDispatch {
|
|||
),
|
||||
},
|
||||
);
|
||||
connectors['greeting'] = _is.EndpointConnector(
|
||||
name: 'greeting',
|
||||
endpoint: endpoints['greeting']!,
|
||||
methodConnectors: {
|
||||
'hello': _is.MethodConnector(
|
||||
name: 'hello',
|
||||
params: {
|
||||
'name': _is.ParameterDescription(
|
||||
name: 'name',
|
||||
type: _is.getType<String>(),
|
||||
nullable: false,
|
||||
),
|
||||
},
|
||||
call:
|
||||
(
|
||||
_is.Session session,
|
||||
Map<String, dynamic> params,
|
||||
) async =>
|
||||
(endpoints['greeting'] as _il624ik7.GreetingEndpoint).hello(
|
||||
session,
|
||||
params['name'],
|
||||
),
|
||||
),
|
||||
},
|
||||
);
|
||||
modules['serverpod_auth_idp'] = _iais.Endpoints()
|
||||
..initializeEndpoints(server);
|
||||
modules['serverpod_auth_core'] = _iacs.Endpoints()
|
||||
|
|
|
|||
|
|
@ -1,109 +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: invalid_use_of_internal_member
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'package:serverpod/serverpod.dart' as _is;
|
||||
|
||||
/// A greeting message which can be sent to or from the server.
|
||||
abstract class Greeting
|
||||
implements _is.SerializableModel, _is.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: _is.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.
|
||||
@_is.useResult
|
||||
Greeting copyWith({
|
||||
String? message,
|
||||
String? author,
|
||||
DateTime? timestamp,
|
||||
});
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'__className__': 'Greeting',
|
||||
'message': message,
|
||||
'author': author,
|
||||
'timestamp': timestamp.toJson(),
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJsonForProtocol() {
|
||||
return {
|
||||
'__className__': 'Greeting',
|
||||
'message': message,
|
||||
'author': author,
|
||||
'timestamp': timestamp.toJson(),
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return _is.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.
|
||||
@_is.useResult
|
||||
@override
|
||||
Greeting copyWith({
|
||||
String? message,
|
||||
String? author,
|
||||
DateTime? timestamp,
|
||||
}) {
|
||||
return Greeting(
|
||||
message: message ?? this.message,
|
||||
author: author ?? this.author,
|
||||
timestamp: timestamp ?? this.timestamp,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -17,8 +17,6 @@ import 'package:serverpod_auth_core_server/serverpod_auth_core_server.dart'
|
|||
as _iacs;
|
||||
import 'package:serverpod_auth_idp_server/serverpod_auth_idp_server.dart'
|
||||
as _iais;
|
||||
import 'greetings/greeting.dart' as _izw8z7ou;
|
||||
export 'greetings/greeting.dart';
|
||||
|
||||
class Protocol extends _is.DatabaseSerializationManager {
|
||||
Protocol._();
|
||||
|
|
@ -60,12 +58,6 @@ class Protocol extends _is.DatabaseSerializationManager {
|
|||
}
|
||||
}
|
||||
|
||||
if (t == _izw8z7ou.Greeting) {
|
||||
return _izw8z7ou.Greeting.fromJson(data) as T;
|
||||
}
|
||||
if (t == _is.getType<_izw8z7ou.Greeting?>()) {
|
||||
return (data != null ? _izw8z7ou.Greeting.fromJson(data) : null) as T;
|
||||
}
|
||||
try {
|
||||
return _iais.Protocol().deserialize<T>(data, t);
|
||||
} on _is.DeserializationTypeNotFoundException catch (_) {}
|
||||
|
|
@ -80,7 +72,6 @@ class Protocol extends _is.DatabaseSerializationManager {
|
|||
|
||||
static String? getClassNameForType(Type type) {
|
||||
return switch (type) {
|
||||
_izw8z7ou.Greeting => 'Greeting',
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
|
@ -97,10 +88,6 @@ class Protocol extends _is.DatabaseSerializationManager {
|
|||
);
|
||||
}
|
||||
|
||||
switch (data) {
|
||||
case _izw8z7ou.Greeting():
|
||||
return 'Greeting';
|
||||
}
|
||||
className = _iais.Protocol().getClassNameForObject(data);
|
||||
if (className != null) {
|
||||
return className.contains('.')
|
||||
|
|
@ -126,9 +113,6 @@ class Protocol extends _is.DatabaseSerializationManager {
|
|||
if (dataClassName is! String) {
|
||||
return super.deserializeByClassName(data);
|
||||
}
|
||||
if (dataClassName == 'Greeting') {
|
||||
return deserialize<_izw8z7ou.Greeting>(data['data']);
|
||||
}
|
||||
if (dataClassName.startsWith('serverpod_auth_idp.')) {
|
||||
data['className'] = dataClassName.substring(19);
|
||||
return _iais.Protocol().deserializeByClassName(data);
|
||||
|
|
|
|||
|
|
@ -9,5 +9,3 @@ emailIdp:
|
|||
- hasAccount:
|
||||
jwtRefresh:
|
||||
- refreshAccessToken:
|
||||
greeting:
|
||||
- hello:
|
||||
|
|
|
|||
|
|
@ -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,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');
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
@ -13,8 +13,6 @@
|
|||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _ida;
|
||||
import 'dart:io' as _idi;
|
||||
import 'package:halkyon_learn_server/src/generated/greetings/greeting.dart'
|
||||
as _if4yg514;
|
||||
import 'package:serverpod/serverpod.dart' as _is;
|
||||
import 'package:serverpod_auth_core_server/serverpod_auth_core_server.dart'
|
||||
as _iacs;
|
||||
|
|
@ -150,8 +148,6 @@ class TestEndpoints {
|
|||
late final _EmailIdpEndpoint emailIdp;
|
||||
|
||||
late final _JwtRefreshEndpoint jwtRefresh;
|
||||
|
||||
late final _GreetingEndpoint greeting;
|
||||
}
|
||||
|
||||
class _InternalTestEndpoints extends TestEndpoints
|
||||
|
|
@ -169,10 +165,6 @@ class _InternalTestEndpoints extends TestEndpoints
|
|||
endpoints,
|
||||
serializationManager,
|
||||
);
|
||||
greeting = _GreetingEndpoint(
|
||||
endpoints,
|
||||
serializationManager,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -493,45 +485,3 @@ class _JwtRefreshEndpoint {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
class _GreetingEndpoint {
|
||||
_GreetingEndpoint(
|
||||
this._endpointDispatch,
|
||||
this._serializationManager,
|
||||
);
|
||||
|
||||
final _is.EndpointDispatch _endpointDispatch;
|
||||
|
||||
final _is.SerializationManager _serializationManager;
|
||||
|
||||
_ida.Future<_if4yg514.Greeting> hello(
|
||||
_ist.TestSessionBuilder sessionBuilder,
|
||||
String name,
|
||||
) async {
|
||||
return _ist.callAwaitableFunctionAndHandleExceptions(() async {
|
||||
var _localUniqueSession =
|
||||
(sessionBuilder as _ist.InternalTestSessionBuilder).internalBuild(
|
||||
endpoint: 'greeting',
|
||||
method: 'hello',
|
||||
);
|
||||
try {
|
||||
var _localCallContext = await _endpointDispatch.getMethodCallContext(
|
||||
createSessionCallback: (_) => _localUniqueSession,
|
||||
endpointPath: 'greeting',
|
||||
methodName: 'hello',
|
||||
parameters: _ist.testObjectToJson({'name': name}),
|
||||
serializationManager: _serializationManager,
|
||||
);
|
||||
var _localReturnValue =
|
||||
await (_localCallContext.method.call(
|
||||
_localUniqueSession,
|
||||
_localCallContext.arguments,
|
||||
)
|
||||
as _ida.Future<_if4yg514.Greeting>);
|
||||
return _localReturnValue;
|
||||
} finally {
|
||||
await _localUniqueSession.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue