halkyon/halkyon_learn_server/lib/server.dart

51 lines
1.9 KiB
Dart
Raw Normal View History

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/generated/serverpod.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: [
// Use JWT for authentication keys towards the server.
JwtConfigFromPasswords(),
],
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_learn',
),
],
);
// 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();
}