forked from serverpod/pixorama
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.dart
41 lines (32 loc) · 1.34 KB
/
server.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import 'package:pixorama_server/src/endpoints/pixorama_endpoint.dart';
import 'package:serverpod/serverpod.dart';
import 'package:pixorama_server/src/web/routes/root.dart';
import 'src/generated/protocol.dart';
import 'src/generated/endpoints.dart';
// This is the starting point of your Serverpod server. In most cases, you will
// only need to make additions to this file if you add future calls, are
// configuring Relic (Serverpod's web-server), or need custom setup work.
void run(List<String> args) async {
// Initialize Serverpod and connect it with your generated code.
final pod = Serverpod(
args,
Protocol(),
Endpoints(),
);
// If you are using any future calls, they need to be registered here.
// pod.registerFutureCall(ExampleFutureCall(), 'exampleFutureCall');
// Setup a default page at the web root.
pod.webServer.addRoute(RouteRoot(), '/');
pod.webServer.addRoute(RouteRoot(), '/index.html');
// Serve all files in the /static directory.
pod.webServer.addRoute(
RouteStaticDirectory(serverDirectory: 'app', basePath: '/'),
'/*',
);
// Load the image from the database before we boot up the server. This is a
// point where we can do this and other additional setup work before the
// server starts.
await PixoramaEndpoint.loadImageFromDatabase();
// Start the server.
await pod.start();
}