initial
This commit is contained in:
21
res/unpub-server/lib/server.dart
Normal file
21
res/unpub-server/lib/server.dart
Normal file
@ -0,0 +1,21 @@
|
||||
import 'dart:io';
|
||||
import 'package:mongo_dart/mongo_dart.dart';
|
||||
import 'package:unpub/unpub.dart' as unpub;
|
||||
|
||||
Future<void> main(List<String> args) async {
|
||||
final String port = Platform.environment['UNPUB_PORT']!;
|
||||
final String dbUri = Platform.environment['UNPUB_DB_URI']!;
|
||||
final String? proxyUri = Platform.environment['UNPUB_REVERSE_PROXY_URI'];
|
||||
|
||||
final Db db = Db(dbUri);
|
||||
await db.open();
|
||||
|
||||
final unpub.App app = unpub.App(
|
||||
metaStore: unpub.MongoStore(db),
|
||||
packageStore: unpub.FileStore('/unpub-packages'),
|
||||
proxy_origin: proxyUri != null ? Uri.parse(proxyUri) : null,
|
||||
);
|
||||
|
||||
final server = await app.serve('0.0.0.0', int.parse(port));
|
||||
print('Serving at http://${server.address.host}:${server.port}');
|
||||
}
|
||||
Reference in New Issue
Block a user