Updated template

This commit is contained in:
thomashii 2021-05-16 18:37:27 +08:00
parent 41d83a274b
commit e986fca7bb
12 changed files with 55 additions and 135 deletions

View file

@ -1,9 +1,21 @@
[![Angel 3 Framework](./logo3.png)]
<!--- (https://angel-dart.dev) -->
[![version](https://img.shields.io/badge/pub-v4.0.0-brightgreen)](https://pub.dartlang.org/packages/framework)
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
[![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/angel_dart/discussion)
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/LICENSE)
<!---
[![The Angel Framework](https://angel-dart.github.io/assets/images/logo.png)](https://angel-dart.dev) [![The Angel Framework](https://angel-dart.github.io/assets/images/logo.png)](https://angel-dart.dev)
[![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/angel_dart/discussion) [![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/angel_dart/discussion)
[![Pub](https://img.shields.io/pub/v/angel_framework.svg)](https://pub.dartlang.org/packages/angel_framework) [![Pub](https://img.shields.io/pub/v/angel_framework.svg)](https://pub.dartlang.org/packages/angel_framework)
[![Build status](https://travis-ci.org/angel-dart/framework.svg?branch=master)](https://travis-ci.org/angel-dart/framework) [![Build status](https://travis-ci.org/angel-dart/framework.svg?branch=master)](https://travis-ci.org/angel-dart/framework)
![License](https://img.shields.io/github/license/angel-dart/framework.svg) ![License](https://img.shields.io/github/license/angel-dart/framework.svg)
-->
**A polished, production-ready backend framework in Dart.** **A polished, production-ready backend framework in Dart.**
@ -11,39 +23,20 @@
----- -----
## About ## About
Angel is a full-stack Web framework in Dart. It aims to Angel3 is a full-stack Web framework in Dart. It aims to
streamline development by providing many common features streamline development by providing many common features
out-of-the-box in a consistent manner. out-of-the-box in a consistent manner.
With features like the following, Angel is the all-in-one framework you should choose to build your next project:
* [GraphQL Support](https://github.com/angel-dart/graphql)
* [PostgreSQL ORM](https://github.com/angel-dart/orm)
* [Dependency Injection](https://docs.angel-dart.dev/guides/dependency-injection)
* And [much more](https://github.com/angel-dart)...
## Installation & Setup ## Installation & Setup
Once you have [Dart](https://www.dartlang.org/) installed, bootstrapping a project is as simple as running a few shell commands: 1. Download and install [Dart](https://www.dartlang.org/).
2. Run the following command to start Angel3 server in dev mode to *hot-reloaded* on file changes:
Install the [Angel CLI](https://github.com/angel-dart/cli):
```bash
pub global activate angel_cli
```
Bootstrap a project:
```bash
angel init hello
```
You can even have your server run and be *hot-reloaded* on file changes:
```bash ```bash
dart --observe bin/dev.dart dart --observe bin/dev.dart
``` ```
Next, check out the [detailed documentation](https://docs.angel-dart.dev/v/2.x) to learn to flesh out your project. 3. Next, check out the [detailed documentation](https://docs.angel-dart.dev/v/2.x) to learn to flesh out your project. Angel3 works the same way as the original Angel.
## Examples and Documentation ## Examples and Documentation
Visit the [documentation](https://docs.angel-dart.dev/v/2.x) Visit the [documentation](https://docs.angel-dart.dev/v/2.x)

View file

@ -1,10 +1,10 @@
import 'dart:io'; import 'dart:io';
import 'package:angel/src/pretty_logging.dart';
import 'package:angel/angel.dart';
import 'package:angel_container/mirrors.dart';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_hot/angel_hot.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:angel3_pretty_logging/angel3_pretty_logging.dart';
import 'package:angel3_container/mirrors.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_hot/angel3_hot.dart';
import 'package:myapp/myapp.dart';
void main() async { void main() async {
// Watch the config/ and web/ directories for changes, and hot-reload the server. // Watch the config/ and web/ directories for changes, and hot-reload the server.

View file

@ -1,6 +1,6 @@
import 'package:angel/angel.dart'; import 'package:angel3_container/mirrors.dart';
import 'package:angel_container/mirrors.dart'; import 'package:angel3_production/angel3_production.dart';
import 'package:angel_production/angel_production.dart'; import 'package:myapp/myapp.dart';
// NOTE: By default, the Runner class does not use the `MirrorsReflector`, or any // NOTE: By default, the Runner class does not use the `MirrorsReflector`, or any
// reflector, by default. // reflector, by default.

View file

@ -1,8 +1,8 @@
/// Your very own web application! /// Your very own web application!
library angel; library myapp;
import 'dart:async'; import 'dart:async';
import 'package:angel_framework/angel_framework.dart'; import 'package:angel3_framework/angel3_framework.dart';
import 'package:file/local.dart'; import 'package:file/local.dart';
import 'src/config/config.dart' as configuration; import 'src/config/config.dart' as configuration;
import 'src/routes/routes.dart' as routes; import 'src/routes/routes.dart' as routes;

View file

@ -1,9 +1,9 @@
/// Configuration for this Angel instance. /// Configuration for this Angel instance.
library angel.src.config; library myapp.src.config;
import 'package:angel_configuration/angel_configuration.dart'; import 'package:angel3_configuration/angel3_configuration.dart';
import 'package:angel_framework/angel_framework.dart'; import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel_jael/angel_jael.dart'; import 'package:angel3_jael/angel3_jael.dart';
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'plugins/plugins.dart' as plugins; import 'plugins/plugins.dart' as plugins;

View file

@ -1,8 +1,8 @@
/// Custom plugins go here. /// Custom plugins go here.
library angel.src.config.plugins; library myapp.src.config.plugins;
import 'dart:async'; import 'dart:async';
import 'package:angel_framework/angel_framework.dart'; import 'package:angel3_framework/angel3_framework.dart';
Future configureServer(Angel app) async { Future configureServer(Angel app) async {
// Include any plugins you have made here. // Include any plugins you have made here.

View file

@ -1,38 +0,0 @@
import 'package:angel_http_exception/angel_http_exception.dart';
import 'package:logging/logging.dart';
import 'package:io/ansi.dart';
/// Prints the contents of a [LogRecord] with pretty colors.
void prettyLog(LogRecord record) {
var code = chooseLogColor(record.level);
if (record.error == null) print(code.wrap(record.toString()));
if (record.error != null) {
var err = record.error;
if (err is AngelHttpException && err.statusCode != 500) return;
print(code.wrap(record.toString() + '\n'));
print(code.wrap(err.toString()));
if (record.stackTrace != null) {
print(code.wrap(record.stackTrace.toString()));
}
}
}
/// Chooses a color based on the logger [level].
AnsiCode chooseLogColor(Level level) {
if (level == Level.SHOUT)
return backgroundRed;
else if (level == Level.SEVERE)
return red;
else if (level == Level.WARNING)
return yellow;
else if (level == Level.INFO)
return cyan;
else if (level == Level.CONFIG ||
level == Level.FINE ||
level == Level.FINER ||
level == Level.FINEST) return lightGray;
return resetAll;
}

View file

@ -1,7 +1,7 @@
library angel.src.routes.controllers; library myapp.src.routes.controllers;
import 'dart:async'; import 'dart:async';
import 'package:angel_framework/angel_framework.dart'; import 'package:angel3_framework/angel3_framework.dart';
Future configureServer(Angel app) async { Future configureServer(Angel app) async {
/// Controllers will not function unless wired to the application! /// Controllers will not function unless wired to the application!

View file

@ -1,8 +1,8 @@
/// This app's route configuration. /// This app's route configuration.
library angel.src.routes; library myapp.src.routes;
import 'package:angel_framework/angel_framework.dart'; import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel_static/angel_static.dart'; import 'package:angel3_static/angel3_static.dart';
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'controllers/controllers.dart' as controllers; import 'controllers/controllers.dart' as controllers;

View file

@ -1,8 +1,8 @@
/// Declare services here! /// Declare services here!
library angel.services; library myapp.services;
import 'dart:async'; import 'dart:async';
import 'package:angel_framework/angel_framework.dart'; import 'package:angel3_framework/angel3_framework.dart';
/// Configure our application to use *services*. /// Configure our application to use *services*.
/// Services must be wired to the app via `app.use`. /// Services must be wired to the app via `app.use`.

View file

@ -1,57 +1,22 @@
name: angel name: myapp
version: 4.0.0 version: 4.0.0
description: An app that's going to be amazing pretty soon. description: An app that's going to be amazing pretty soon.
publish_to: none # Ensure we don't accidentally publish our private code! ;) publish_to: none # Ensure we don't accidentally publish our private code! ;)
homepage: https://github.com/dukefirehawk/angel
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.12.0 <3.0.0'
homepage: https://github.com/angel-dart/angel
dependencies: dependencies:
angel_auth: angel3_auth: ^4.0.0
git: angel3_configuration: ^4.0.0
url: https://github.com/dukefirehawk/angel.git angel3_framework: ^4.0.0
ref: sdk-2.12.x_nnbd angel3_jael: ^4.0.0
path: packages/auth angel3_production: ^3.0.0
angel_configuration: angel3_static: ^4.0.0
git: angel3_validate: ^4.0.0
url: https://github.com/dukefirehawk/angel.git angel3_pretty_logging: ^3.0.0
ref: sdk-2.12.x_nnbd
path: packages/configuration
angel_framework:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x_nnbd
path: packages/framework
angel_jael:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x_nnbd
path: packages/jael/angel_jael
angel_production:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x_nnbd
path: packages/production
angel_static:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x_nnbd
path: packages/static
angel_validate:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x_nnbd
path: packages/validate
dev_dependencies: dev_dependencies:
angel_hot: angel3_hot: ^4.0.0
git: angel3_test: ^4.0.0
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x_nnbd
path: packages/hot
angel_test:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x_nnbd
path: packages/test
io: ^1.0.0 # For pretty printing. io: ^1.0.0 # For pretty printing.
pedantic: ^1.11.0 # Enforces Dart style conventions. pedantic: ^1.11.0 # Enforces Dart style conventions.
test: ^1.17.3 # For unit testing. test: ^1.17.3 # For unit testing.

View file

@ -1,7 +1,7 @@
import 'package:angel/angel.dart'; import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel_framework/angel_framework.dart'; import 'package:angel3_test/angel3_test.dart';
import 'package:angel_test/angel_test.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:myapp/myapp.dart';
// Angel also includes facilities to make testing easier. // Angel also includes facilities to make testing easier.
// //
@ -19,7 +19,7 @@ import 'package:test/test.dart';
// here: // here:
// https://github.com/dart-lang/test // https://github.com/dart-lang/test
main() async { void main() async {
late TestClient client; late TestClient client;
setUp(() async { setUp(() async {