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
1 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();
|
||||
}
|
||||
Loading…
Reference in a new issue