astra_cli 1.0.0-dev.16 copy "astra_cli: ^1.0.0-dev.16" to clipboard
astra_cli: ^1.0.0-dev.16 copied to clipboard

unlistedoutdated

The astra and shelf command line tool.

Pub Package License

The astra and shelf command line tool. Inspired by uvicorn.

WIP, Unstable

ToDo #

  • Verbose output 🔥
  • Logging 🔥
  • Tests 🔥
  • Environment variables & configuration file
  • Commands:
    • create
    • generate
    • build
    • ...
  • ...

Experimenting #

  • Serving package URI (if possible) 🤔
  • build_runner integration

Quickstart #

Install using dart pub:

$ dart pub global activate astra_cli

Create an application with lib/[package].dart file:

import 'dart:io';

import 'package:astra/core.dart';

Response application(Request request) {
  return Response.ok('hello world!');
}

Run the server:

$ astra serve

Usage #

Run serve command to serve your application:

Serve Astra/Shelf application.

Usage: astra serve [options]
-h, --help                                Print this usage information.

Application options:
-t, --target=<application>                Application target.
    --target-path=<lib/[package].dart>    Application target location.
                                          Must be within application root folder.
-C, --directory=<.>                       Application root folder.
-D, --define=<key=value>                  Define an environment declaration.
-v, --verbose                             Print detailed logging.

Server options:
    --server-type=<h1x>                   Server type.

          [h1x]                           HTTP/1.x Shelf server.

-j, --concurrency=<1>                     Number of isolates.
-a, --address=<localhost>                 Bind server to this address.
                                          Bind will perform a InternetAddress.lookup and use the first value in the list.
-p, --port=<8080>                         Bind server to this port.
                                          If port has the value 0 an ephemeral port will be chosen by the system.
                                          The actual port used can be retrieved using the port getter.
    --backlog=<0>                         Number of connections to hold in backlog.
                                          If it has the value of 0 a reasonable value will be chosen by the system.
    --shared                              Specifies whether additional servers can bind to the same combination of address, port and v6Only.
                                          If it's true and more servers are bound to the port, then the incoming connections will be distributed among all the bound servers.
    --v6Only                              Restrict IP addresses to version 6 (IPv6) only.
                                          If an IP version 6 (IPv6) address is used, both IP version 6 (IPv6) and version 4 (IPv4) connections will be accepted.
    --ssl-key=<file.key>                  SSL key file.
    --ssl-cert=<file.crt>                 SSL certificate file.
    --ssl-key-password=<password>         SSL keyfile password.

Debugging options:
    --debug
    --hot
-w, --watch
    --service-port=<8181>
    --enable-asserts

Run "astra help" to see global options.

Running programmatically #

To run server directly from your application:

bin/main.dart

import 'package:astra/serve.dart';
import 'package:example/example.dart';

Future<void> main() async {
  var server = await application.serve('localhost', 8080);
  print('Serving at ${server.url} ...');
}
0
likes
0
points
15
downloads

Publisher

unverified uploader

Weekly Downloads

The astra and shelf command line tool.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

analyzer, args, astra, async, path, pubspec, stream_transform, vm_service, watcher

More

Packages that depend on astra_cli