start method Null safety

Future start()

Initiates the server using the config.db.init, creating a handler (middleware) for the requests and starting a shelf server on the localhost

Implementation

Future start() async {
  await config.db.init();
  final handler =
      const Pipeline().addMiddleware(logRequests()).addHandler(handleRequest);

  _server = await shelf_io.serve(
    handler,
    config.host ?? InternetAddress.loopbackIPv4,
    config.port,
  );
  stdout.write('Server ${config.name} started...');
  stdout.write('Listening on ${_server.address.host}:${_server.port}');
}