chore: Halkyon Todo's scaffold joins the repository in apps/todo
Its server, client and app as `serverpod create` made them, with the switch to server-side sessions that was waiting uncommitted, as files: its one commit holds the scaffold alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
649499be23
commit
314a901fa1
13 changed files with 16151 additions and 0 deletions
109
apps/todo/halkyon_todo_server/lib/server.dart
Normal file
109
apps/todo/halkyon_todo_server/lib/server.dart
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:serverpod_auth_idp_server/core.dart';
|
||||
import 'package:serverpod_auth_idp_server/providers/email.dart';
|
||||
import 'package:serverpod_cloud_storage/serverpod_cloud_storage.dart';
|
||||
|
||||
import 'src/cache_busting.dart';
|
||||
import 'src/generated/serverpod.dart';
|
||||
import 'src/web/routes/app_config_route.dart';
|
||||
|
||||
/// The starting point of the Serverpod server.
|
||||
void run(List<String> args) async {
|
||||
// Initialize Serverpod. The generated Serverpod class is already connected
|
||||
// with your project's generated code.
|
||||
final pod = Serverpod(args);
|
||||
|
||||
// Initialize authentication services for the server.
|
||||
// Token managers will be used to validate and issue authentication keys,
|
||||
// and the identity providers will be the authentication options available for users.
|
||||
pod.initializeAuthServices(
|
||||
tokenManagerBuilders: [
|
||||
// Server-side sessions: every request looks its session up in the
|
||||
// database, so signing out or deleting an account takes effect at once.
|
||||
// A session unused for 90 days expires; one in use never does.
|
||||
ServerSideSessionsConfigFromPasswords(
|
||||
defaultSessionInactivityTimeout: const Duration(days: 90),
|
||||
),
|
||||
],
|
||||
identityProviderBuilders: [
|
||||
// Configure the email identity provider for email/password authentication.
|
||||
// The default setup works with Serverpod Cloud without configuration. In
|
||||
// development the verification codes are logged to the console, and in
|
||||
// staging and production they are sent through the Serverpod Cloud email
|
||||
// service. If you want to use a custom provider for sending emails, use
|
||||
// `EmailIdpConfigFromPasswords`.
|
||||
ServerpodCloudEmailIdpConfig(
|
||||
appDisplayName: 'halkyon_todo',
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
// Serve all files in the web/static relative directory under /web.
|
||||
// These are used by the default web page.
|
||||
pod.webServer.addRoute(
|
||||
StaticRoute.withCacheBusting(cacheBustingConfig),
|
||||
cacheBustingConfig.mountPrefix,
|
||||
);
|
||||
|
||||
// Setup the app config route.
|
||||
// We build this configuration based on the servers api url and serve it to
|
||||
// the flutter app.
|
||||
pod.webServer.addRoute(
|
||||
AppConfigRoute(apiConfig: pod.config.apiServer),
|
||||
'/assets/assets/config.json',
|
||||
);
|
||||
|
||||
// Checks if the flutter web app has been built and serves it if it has.
|
||||
final appDir = Directory(Uri(path: 'web/app').toFilePath());
|
||||
if (appDir.existsSync()) {
|
||||
// Serve the flutter web app under /.
|
||||
pod.webServer.addRoute(
|
||||
FlutterRoute(
|
||||
appDir,
|
||||
// If building the Flutter app with WASM, set the below parameter to
|
||||
// true and add the --wasm flag to the flutter build command.
|
||||
enableWasmHeaders: false,
|
||||
),
|
||||
'/',
|
||||
);
|
||||
} else {
|
||||
// If the flutter web app has not been built, serve the build app page.
|
||||
final defaultRoute = StaticRoute.file(
|
||||
File(
|
||||
Uri(path: 'web/pages/build_flutter_app.html').toFilePath(),
|
||||
),
|
||||
);
|
||||
|
||||
pod.webServer.addMiddleware(
|
||||
FallbackMiddleware(
|
||||
fallback: defaultRoute,
|
||||
on: (response) => response.statusCode == 404,
|
||||
).call,
|
||||
'/',
|
||||
);
|
||||
|
||||
pod.webServer.addRoute(
|
||||
defaultRoute,
|
||||
'/**',
|
||||
);
|
||||
}
|
||||
|
||||
// Configure cloud storage.
|
||||
// This setup works with Serverpod Cloud without extra configuration.
|
||||
// If you want to use a custom provider for cloud storage, replace these
|
||||
// with your preferred provider.
|
||||
pod.addCloudStorage(
|
||||
await ServerpodCloudProvider.private(
|
||||
fallback: () => DatabaseCloudStorage('private'),
|
||||
),
|
||||
);
|
||||
pod.addCloudStorage(
|
||||
await ServerpodCloudProvider.public(
|
||||
fallback: () => DatabaseCloudStorage('public'),
|
||||
),
|
||||
);
|
||||
|
||||
// Start the server.
|
||||
await pod.start();
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
import 'package:serverpod_auth_idp_server/providers/email.dart';
|
||||
|
||||
/// By extending [EmailIdpBaseEndpoint], the email identity provider endpoints
|
||||
/// are made available on the server and enable the corresponding sign-in widget
|
||||
/// on the client.
|
||||
class EmailIdpEndpoint extends EmailIdpBaseEndpoint {}
|
||||
10
apps/todo/halkyon_todo_server/lib/src/cache_busting.dart
Normal file
10
apps/todo/halkyon_todo_server/lib/src/cache_busting.dart
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:serverpod/serverpod.dart';
|
||||
|
||||
/// Cache busting configuration.
|
||||
/// Used in WidgetRoutes to cache-bust asset paths.
|
||||
final cacheBustingConfig = CacheBustingConfig(
|
||||
mountPrefix: '/web',
|
||||
fileSystemRoot: Directory(Uri(path: 'web/static').toFilePath()),
|
||||
);
|
||||
248
apps/todo/halkyon_todo_server/lib/src/generated/endpoints.dart
Normal file
248
apps/todo/halkyon_todo_server/lib/src/generated/endpoints.dart
Normal file
|
|
@ -0,0 +1,248 @@
|
|||
/* 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;
|
||||
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 '../auth/email_idp_endpoint.dart' as _iuc1hd5t;
|
||||
import '../greetings/greeting_endpoint.dart' as _il624ik7;
|
||||
|
||||
class Endpoints extends _is.EndpointDispatch {
|
||||
@override
|
||||
void initializeEndpoints(_is.Server server) {
|
||||
var endpoints = <String, _is.Endpoint>{
|
||||
'emailIdp': _iuc1hd5t.EmailIdpEndpoint()
|
||||
..initialize(
|
||||
server,
|
||||
'emailIdp',
|
||||
null,
|
||||
),
|
||||
'greeting': _il624ik7.GreetingEndpoint()
|
||||
..initialize(
|
||||
server,
|
||||
'greeting',
|
||||
null,
|
||||
),
|
||||
};
|
||||
connectors['emailIdp'] = _is.EndpointConnector(
|
||||
name: 'emailIdp',
|
||||
endpoint: endpoints['emailIdp']!,
|
||||
methodConnectors: {
|
||||
'login': _is.MethodConnector(
|
||||
name: 'login',
|
||||
params: {
|
||||
'email': _is.ParameterDescription(
|
||||
name: 'email',
|
||||
type: _is.getType<String>(),
|
||||
nullable: false,
|
||||
),
|
||||
'password': _is.ParameterDescription(
|
||||
name: 'password',
|
||||
type: _is.getType<String>(),
|
||||
nullable: false,
|
||||
),
|
||||
},
|
||||
call:
|
||||
(
|
||||
_is.Session session,
|
||||
Map<String, dynamic> params,
|
||||
) async =>
|
||||
(endpoints['emailIdp'] as _iuc1hd5t.EmailIdpEndpoint).login(
|
||||
session,
|
||||
email: params['email'],
|
||||
password: params['password'],
|
||||
),
|
||||
),
|
||||
'startRegistration': _is.MethodConnector(
|
||||
name: 'startRegistration',
|
||||
params: {
|
||||
'email': _is.ParameterDescription(
|
||||
name: 'email',
|
||||
type: _is.getType<String>(),
|
||||
nullable: false,
|
||||
),
|
||||
},
|
||||
call:
|
||||
(
|
||||
_is.Session session,
|
||||
Map<String, dynamic> params,
|
||||
) async => (endpoints['emailIdp'] as _iuc1hd5t.EmailIdpEndpoint)
|
||||
.startRegistration(
|
||||
session,
|
||||
email: params['email'],
|
||||
),
|
||||
),
|
||||
'verifyRegistrationCode': _is.MethodConnector(
|
||||
name: 'verifyRegistrationCode',
|
||||
params: {
|
||||
'accountRequestId': _is.ParameterDescription(
|
||||
name: 'accountRequestId',
|
||||
type: _is.getType<_is.UuidValue>(),
|
||||
nullable: false,
|
||||
),
|
||||
'verificationCode': _is.ParameterDescription(
|
||||
name: 'verificationCode',
|
||||
type: _is.getType<String>(),
|
||||
nullable: false,
|
||||
),
|
||||
},
|
||||
call:
|
||||
(
|
||||
_is.Session session,
|
||||
Map<String, dynamic> params,
|
||||
) async => (endpoints['emailIdp'] as _iuc1hd5t.EmailIdpEndpoint)
|
||||
.verifyRegistrationCode(
|
||||
session,
|
||||
accountRequestId: params['accountRequestId'],
|
||||
verificationCode: params['verificationCode'],
|
||||
),
|
||||
),
|
||||
'finishRegistration': _is.MethodConnector(
|
||||
name: 'finishRegistration',
|
||||
params: {
|
||||
'registrationToken': _is.ParameterDescription(
|
||||
name: 'registrationToken',
|
||||
type: _is.getType<String>(),
|
||||
nullable: false,
|
||||
),
|
||||
'password': _is.ParameterDescription(
|
||||
name: 'password',
|
||||
type: _is.getType<String>(),
|
||||
nullable: false,
|
||||
),
|
||||
},
|
||||
call:
|
||||
(
|
||||
_is.Session session,
|
||||
Map<String, dynamic> params,
|
||||
) async => (endpoints['emailIdp'] as _iuc1hd5t.EmailIdpEndpoint)
|
||||
.finishRegistration(
|
||||
session,
|
||||
registrationToken: params['registrationToken'],
|
||||
password: params['password'],
|
||||
),
|
||||
),
|
||||
'startPasswordReset': _is.MethodConnector(
|
||||
name: 'startPasswordReset',
|
||||
params: {
|
||||
'email': _is.ParameterDescription(
|
||||
name: 'email',
|
||||
type: _is.getType<String>(),
|
||||
nullable: false,
|
||||
),
|
||||
},
|
||||
call:
|
||||
(
|
||||
_is.Session session,
|
||||
Map<String, dynamic> params,
|
||||
) async => (endpoints['emailIdp'] as _iuc1hd5t.EmailIdpEndpoint)
|
||||
.startPasswordReset(
|
||||
session,
|
||||
email: params['email'],
|
||||
),
|
||||
),
|
||||
'verifyPasswordResetCode': _is.MethodConnector(
|
||||
name: 'verifyPasswordResetCode',
|
||||
params: {
|
||||
'passwordResetRequestId': _is.ParameterDescription(
|
||||
name: 'passwordResetRequestId',
|
||||
type: _is.getType<_is.UuidValue>(),
|
||||
nullable: false,
|
||||
),
|
||||
'verificationCode': _is.ParameterDescription(
|
||||
name: 'verificationCode',
|
||||
type: _is.getType<String>(),
|
||||
nullable: false,
|
||||
),
|
||||
},
|
||||
call:
|
||||
(
|
||||
_is.Session session,
|
||||
Map<String, dynamic> params,
|
||||
) async => (endpoints['emailIdp'] as _iuc1hd5t.EmailIdpEndpoint)
|
||||
.verifyPasswordResetCode(
|
||||
session,
|
||||
passwordResetRequestId: params['passwordResetRequestId'],
|
||||
verificationCode: params['verificationCode'],
|
||||
),
|
||||
),
|
||||
'finishPasswordReset': _is.MethodConnector(
|
||||
name: 'finishPasswordReset',
|
||||
params: {
|
||||
'finishPasswordResetToken': _is.ParameterDescription(
|
||||
name: 'finishPasswordResetToken',
|
||||
type: _is.getType<String>(),
|
||||
nullable: false,
|
||||
),
|
||||
'newPassword': _is.ParameterDescription(
|
||||
name: 'newPassword',
|
||||
type: _is.getType<String>(),
|
||||
nullable: false,
|
||||
),
|
||||
},
|
||||
call:
|
||||
(
|
||||
_is.Session session,
|
||||
Map<String, dynamic> params,
|
||||
) async => (endpoints['emailIdp'] as _iuc1hd5t.EmailIdpEndpoint)
|
||||
.finishPasswordReset(
|
||||
session,
|
||||
finishPasswordResetToken:
|
||||
params['finishPasswordResetToken'],
|
||||
newPassword: params['newPassword'],
|
||||
),
|
||||
),
|
||||
'hasAccount': _is.MethodConnector(
|
||||
name: 'hasAccount',
|
||||
params: {},
|
||||
call:
|
||||
(
|
||||
_is.Session session,
|
||||
Map<String, dynamic> params,
|
||||
) async => (endpoints['emailIdp'] as _iuc1hd5t.EmailIdpEndpoint)
|
||||
.hasAccount(session),
|
||||
),
|
||||
},
|
||||
);
|
||||
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()
|
||||
..initializeEndpoints(server);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
/* 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,
|
||||
);
|
||||
}
|
||||
}
|
||||
199
apps/todo/halkyon_todo_server/lib/src/generated/protocol.dart
Normal file
199
apps/todo/halkyon_todo_server/lib/src/generated/protocol.dart
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
/* 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: dead_code, unnecessary_type_check
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'package:serverpod/protocol.dart' as _isp;
|
||||
import 'package:serverpod/serverpod.dart' as _is;
|
||||
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._();
|
||||
|
||||
factory Protocol() => _instance;
|
||||
|
||||
static final Protocol _instance = Protocol._().._registerHostProtocols();
|
||||
|
||||
static List<_isp.TableDefinition> get targetTableDefinitions => [
|
||||
..._iais.Protocol.targetTableDefinitions,
|
||||
..._iacs.Protocol.targetTableDefinitions,
|
||||
..._isp.Protocol.targetTableDefinitions,
|
||||
];
|
||||
|
||||
static String? getClassNameFromObjectJson(dynamic data) {
|
||||
if (data is! Map) return null;
|
||||
final className = data['__className__'] as String?;
|
||||
return className;
|
||||
}
|
||||
|
||||
@override
|
||||
T deserialize<T>(
|
||||
dynamic data, [
|
||||
Type? t,
|
||||
]) {
|
||||
t ??= T;
|
||||
|
||||
final dataClassName = getClassNameFromObjectJson(data);
|
||||
if (dataClassName != null && dataClassName != getClassNameForType(t)) {
|
||||
try {
|
||||
return deserializeByClassName({
|
||||
'className': dataClassName,
|
||||
'data': data,
|
||||
});
|
||||
} on _is.DeserializationClassNameNotFoundException catch (_) {
|
||||
// If the className is not recognized (e.g., older client receiving
|
||||
// data with a new subtype), fall back to deserializing without the
|
||||
// className, using the expected type T.
|
||||
}
|
||||
}
|
||||
|
||||
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 (_) {}
|
||||
try {
|
||||
return _iacs.Protocol().deserialize<T>(data, t);
|
||||
} on _is.DeserializationTypeNotFoundException catch (_) {}
|
||||
try {
|
||||
return _isp.Protocol().deserialize<T>(data, t);
|
||||
} on _is.DeserializationTypeNotFoundException catch (_) {}
|
||||
return super.deserialize<T>(data, t);
|
||||
}
|
||||
|
||||
static String? getClassNameForType(Type type) {
|
||||
return switch (type) {
|
||||
_izw8z7ou.Greeting => 'Greeting',
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String? getClassNameForObject(Object? data) {
|
||||
String? className = super.getClassNameForObject(data);
|
||||
if (className != null) return className;
|
||||
|
||||
if (data is Map<String, dynamic> && data['__className__'] is String) {
|
||||
return (data['__className__'] as String).replaceFirst(
|
||||
'halkyon_todo.',
|
||||
'',
|
||||
);
|
||||
}
|
||||
|
||||
switch (data) {
|
||||
case _izw8z7ou.Greeting():
|
||||
return 'Greeting';
|
||||
}
|
||||
className = _iais.Protocol().getClassNameForObject(data);
|
||||
if (className != null) {
|
||||
return className.contains('.')
|
||||
? className
|
||||
: 'serverpod_auth_idp.$className';
|
||||
}
|
||||
className = _iacs.Protocol().getClassNameForObject(data);
|
||||
if (className != null) {
|
||||
return className.contains('.')
|
||||
? className
|
||||
: 'serverpod_auth_core.$className';
|
||||
}
|
||||
className = _isp.Protocol().getClassNameForObject(data);
|
||||
if (className != null) {
|
||||
return className.contains('.') ? className : 'serverpod.$className';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
dynamic deserializeByClassName(Map<String, dynamic> data) {
|
||||
var dataClassName = data['className'];
|
||||
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);
|
||||
}
|
||||
if (dataClassName.startsWith('serverpod_auth_core.')) {
|
||||
data['className'] = dataClassName.substring(20);
|
||||
return _iacs.Protocol().deserializeByClassName(data);
|
||||
}
|
||||
if (dataClassName.startsWith('serverpod.')) {
|
||||
data['className'] = dataClassName.substring(10);
|
||||
return _isp.Protocol().deserializeByClassName(data);
|
||||
}
|
||||
return super.deserializeByClassName(data);
|
||||
}
|
||||
|
||||
void _registerHostProtocols() {
|
||||
_iais.Protocol().registerHostProtocol('halkyon_todo', this);
|
||||
_iacs.Protocol().registerHostProtocol('halkyon_todo', this);
|
||||
}
|
||||
|
||||
@override
|
||||
_is.Table? getTableForType(Type t) {
|
||||
{
|
||||
var table = _iais.Protocol().getTableForType(t);
|
||||
if (table != null) {
|
||||
return table;
|
||||
}
|
||||
}
|
||||
{
|
||||
var table = _iacs.Protocol().getTableForType(t);
|
||||
if (table != null) {
|
||||
return table;
|
||||
}
|
||||
}
|
||||
{
|
||||
var table = _isp.Protocol().getTableForType(t);
|
||||
if (table != null) {
|
||||
return table;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
List<_isp.TableDefinition> getTargetTableDefinitions() =>
|
||||
targetTableDefinitions;
|
||||
|
||||
@override
|
||||
String getModuleName() => 'halkyon_todo';
|
||||
|
||||
/// Maps any `Record`s known to this [Protocol] to their JSON representation
|
||||
///
|
||||
/// Throws in case the record type is not known.
|
||||
///
|
||||
/// This method will return `null` (only) for `null` inputs.
|
||||
Map<String, dynamic>? mapRecordToJson(Record? record) {
|
||||
if (record == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return _iais.Protocol().mapRecordToJson(record);
|
||||
} catch (_) {}
|
||||
try {
|
||||
return _iacs.Protocol().mapRecordToJson(record);
|
||||
} catch (_) {}
|
||||
throw Exception('Unsupported record type ${record.runtimeType}');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
emailIdp:
|
||||
- login:
|
||||
- startRegistration:
|
||||
- verifyRegistrationCode:
|
||||
- finishRegistration:
|
||||
- startPasswordReset:
|
||||
- verifyPasswordResetCode:
|
||||
- finishPasswordReset:
|
||||
- hasAccount:
|
||||
greeting:
|
||||
- hello:
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/* 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 'dart:io' as _idi;
|
||||
import 'package:serverpod/serverpod.dart' as _is;
|
||||
import 'endpoints.dart' as _iavctuc6;
|
||||
import 'protocol.dart' as _il2as5qe;
|
||||
export 'package:serverpod/serverpod.dart' hide Serverpod;
|
||||
|
||||
/// The Serverpod server for this project.
|
||||
///
|
||||
/// Pre-configured with the generated Protocol serialization manager and
|
||||
/// Endpoints, so a server can be created with just the command line
|
||||
/// arguments:
|
||||
///
|
||||
/// ```dart
|
||||
/// final pod = Serverpod(args);
|
||||
/// ```
|
||||
class Serverpod extends _is.Serverpod {
|
||||
Serverpod(
|
||||
List<String> args, {
|
||||
_idi.Directory? serverDirectory,
|
||||
_is.ServerpodConfig? config,
|
||||
_is.ServerpodConfig Function(_is.ServerpodConfig)? configOverride,
|
||||
_is.AuthenticationHandler? authenticationHandler,
|
||||
_is.HealthCheckHandler? healthCheckHandler,
|
||||
_is.HealthConfig? healthConfig,
|
||||
_is.Headers? httpResponseHeaders,
|
||||
_is.Headers? httpOptionsResponseHeaders,
|
||||
_is.SecurityContextConfig? securityContextConfig,
|
||||
_is.ExperimentalFeatures? experimentalFeatures,
|
||||
_is.RuntimeParametersListBuilder? runtimeParametersBuilder,
|
||||
_is.DatabaseInterceptor? databaseInterceptor,
|
||||
}) : super(
|
||||
args,
|
||||
_il2as5qe.Protocol(),
|
||||
_iavctuc6.Endpoints(),
|
||||
serverDirectory: serverDirectory,
|
||||
config: config,
|
||||
configOverride: configOverride,
|
||||
authenticationHandler: authenticationHandler,
|
||||
healthCheckHandler: healthCheckHandler,
|
||||
healthConfig: healthConfig,
|
||||
httpResponseHeaders: httpResponseHeaders,
|
||||
httpOptionsResponseHeaders: httpOptionsResponseHeaders,
|
||||
securityContextConfig: securityContextConfig,
|
||||
experimentalFeatures: experimentalFeatures,
|
||||
runtimeParametersBuilder: runtimeParametersBuilder,
|
||||
databaseInterceptor: databaseInterceptor,
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
# 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
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
import 'package:serverpod/serverpod.dart';
|
||||
|
||||
class AppConfigWidget extends JsonWidget {
|
||||
final String apiUrl;
|
||||
|
||||
AppConfigWidget({
|
||||
required this.apiUrl,
|
||||
}) : super(object: {'apiUrl': apiUrl});
|
||||
}
|
||||
|
||||
class AppConfigRoute extends WidgetRoute {
|
||||
AppConfigWidget widget;
|
||||
|
||||
AppConfigRoute({
|
||||
required final ServerConfig apiConfig,
|
||||
}) : widget = AppConfigWidget(apiUrl: apiConfig.apiUrl.toString());
|
||||
|
||||
@override
|
||||
Future<WebWidget> build(Session session, Request request) async {
|
||||
return widget;
|
||||
}
|
||||
}
|
||||
|
||||
extension on ServerConfig {
|
||||
Uri get apiUrl => Uri(
|
||||
scheme: publicScheme,
|
||||
host: publicHost,
|
||||
port: publicPort,
|
||||
);
|
||||
}
|
||||
12
apps/todo/halkyon_todo_server/lib/src/web/routes/root.dart
Normal file
12
apps/todo/halkyon_todo_server/lib/src/web/routes/root.dart
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import 'package:halkyon_todo_server/src/cache_busting.dart';
|
||||
import 'package:halkyon_todo_server/src/web/widgets/built_with_serverpod_page.dart';
|
||||
import 'package:serverpod/serverpod.dart';
|
||||
|
||||
class RootRoute extends WidgetRoute {
|
||||
RootRoute() : super(cacheBustingConfig: cacheBustingConfig);
|
||||
|
||||
@override
|
||||
Future<TemplateWidget> build(Session session, Request request) async {
|
||||
return BuiltWithServerpodPageWidget();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
import 'package:serverpod/serverpod.dart';
|
||||
|
||||
/// A widget that displays the Serverpod version and the current run mode.
|
||||
/// It uses the built_with_serverpod.html template to render the page.
|
||||
/// The [name] of the template should correspond to a template file in your
|
||||
/// server's web/templates directory.
|
||||
class BuiltWithServerpodPageWidget extends TemplateWidget {
|
||||
BuiltWithServerpodPageWidget() : super(name: 'built_with_serverpod') {
|
||||
values = {'served': DateTime.now(), 'runmode': Serverpod.instance.runMode};
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue