Skip to content

Commit

Permalink
Format code using Dart 3.7 formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpryan committed Feb 26, 2025
1 parent 15265fe commit 97d0fe1
Show file tree
Hide file tree
Showing 54 changed files with 2,074 additions and 1,782 deletions.
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

0 comments on commit 97d0fe1

Please sign in to comment.