Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format code using Dart 3.7 formatter #3161

Merged
merged 6 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 43 additions & 24 deletions pkgs/dart_services/lib/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,27 @@ import 'src/sdk.dart';
final Logger _logger = Logger('services');

Future<void> main(List<String> args) async {
final parser = ArgParser()
..addOption('port', valueHelp: 'port', help: 'The port to listen on.')
..addOption('redis-url', valueHelp: 'url', help: 'The redis server url.')
..addOption('storage-bucket',
valueHelp: 'name',
help: 'The name of the Cloud Storage bucket for compilation artifacts.',
defaultsTo: 'nnbd_artifacts')
..addFlag('help',
abbr: 'h', negatable: false, help: 'Show this usage information.');
final parser =
ArgParser()
..addOption('port', valueHelp: 'port', help: 'The port to listen on.')
..addOption(
'redis-url',
valueHelp: 'url',
help: 'The redis server url.',
)
..addOption(
'storage-bucket',
valueHelp: 'name',
help:
'The name of the Cloud Storage bucket for compilation artifacts.',
defaultsTo: 'nnbd_artifacts',
)
..addFlag(
'help',
abbr: 'h',
negatable: false,
help: 'Show this usage information.',
);

final results = parser.parse(args);
if (results['help'] as bool) {
Expand Down Expand Up @@ -66,18 +78,23 @@ Future<void> main(List<String> args) async {
.map((entry) => '${entry.key}:${entry.value}')
.join(',');

_logger.info('''
_logger.info(
'''
Starting dart-services:
port: $port
sdkPath: ${sdk.dartSdkPath}
redisServerUri: $redisServerUri
Cloud Run Environment variables: $cloudRunEnvVars'''
.trim());
Cloud Run Environment variables: $cloudRunEnvVars'''.trim(),
);

await GitHubOAuthHandler.initFromEnvironmentalVars();

final server =
await EndpointsServer.serve(port, sdk, redisServerUri, storageBucket);
final server = await EndpointsServer.serve(
port,
sdk,
redisServerUri,
storageBucket,
);

_logger.info('Listening on port ${server.port}');
}
Expand All @@ -89,8 +106,11 @@ class EndpointsServer {
String? redisServerUri,
String storageBucket,
) async {
final endpointsServer =
EndpointsServer._(sdk, redisServerUri, storageBucket);
final endpointsServer = EndpointsServer._(
sdk,
redisServerUri,
storageBucket,
);
await endpointsServer._init();

endpointsServer.server = await shelf.serve(
Expand All @@ -113,15 +133,14 @@ class EndpointsServer {
// https://cloud.google.com/run/docs/reference/container-contract#env-vars
final serverVersion = Platform.environment['K_REVISION'];

final cache = redisServerUri == null
? NoopCache()
: RedisCache(redisServerUri, sdk, serverVersion);
final cache =
redisServerUri == null
? NoopCache()
: RedisCache(redisServerUri, sdk, serverVersion);

commonServer = CommonServerApi(CommonServerImpl(
sdk,
cache,
storageBucket: storageBucket,
));
commonServer = CommonServerApi(
CommonServerImpl(sdk, cache, storageBucket: storageBucket),
);

// Set cache for GitHub OAuth and add GitHub OAuth routes to our router.
GitHubOAuthHandler.setCache(cache);
Expand Down
Loading