Compare commits

...

27 commits

Author SHA1 Message Date
Thomas Hii
d6a81afab5
Merge pull request #7 from dukefirehawk/angel3-basic
Updated Dockfile
2022-04-26 09:23:58 +08:00
thomashii
fd4abfaf43 Updated Dockfile 2022-04-26 09:22:32 +08:00
Thomas Hii
d171e49fc2
Merge pull request #6 from dukefirehawk/angel3-basic
Angel3 basic
2022-04-26 09:18:34 +08:00
Thomas Hii
debada01f2
Merge pull request #3 from dukefirehawk/v6/angel3-basic
Updated to dart SDK 2.16.0
2022-04-26 09:15:57 +08:00
thomashii
4bdddcdfed Updated to dart SDK 2.16.0 2022-04-26 08:20:54 +08:00
thomashii
023d239c1f Merge branch 'angel3-basic' 2021-09-25 18:46:55 +08:00
thomashii
6867696218 Updated basic template 2021-09-25 18:32:05 +08:00
thomashii
f46ec8058d Updated packages 2021-08-19 08:35:00 +08:00
thomashii
597ea5323a Updated packages 2021-08-19 08:22:49 +08:00
thomashii
8a6bd74bf2 Merge branch 'angel3-basic' 2021-07-17 13:08:15 +08:00
thomashii
2f8dd31c6a Update reference 2021-07-17 13:07:46 +08:00
thomashii
dfd864f0b7 Updated README 2021-07-17 11:48:20 +08:00
thomashii
9e66a1af47 Merge branch 'angel3-basic' 2021-07-17 11:47:40 +08:00
thomashii
be518fa3c0 Updated basic 2021-07-17 11:44:51 +08:00
thomashii
197e4c95e5 Updated README 2021-06-14 09:44:53 +08:00
thomashii
89dde22a52 Updated angel3-basic 2021-06-14 08:02:15 +08:00
thomashii
539696222d Updated README 2021-06-11 12:24:54 +08:00
thomashii
c19f92ba35 Updated templates 2021-06-11 12:22:21 +08:00
thomashii
d74bde03e2 Updated CHANGELOG 2021-06-11 10:36:19 +08:00
thomashii
e986fca7bb Updated template 2021-05-16 18:37:27 +08:00
thomashii@dukefirehawk.com
41d83a274b Migrated to NNBD 2021-05-01 12:07:15 +08:00
thomashii
528dca2db9 Fixed to work with sdk 2.12.x 2021-03-09 00:19:53 +08:00
thomashii
93cdb671d5 Fixed to work with sdk 2.12.x 2021-03-08 21:38:13 +08:00
thomashii
ff8b0e60a8 Updated dependencies 2021-03-07 21:34:59 +08:00
thomashii
00b14878a8 Update bin 2021-03-07 20:45:40 +08:00
thomashii
4f1913d517 Basic templat for SDK 2.12.x 2021-03-07 20:42:48 +08:00
thomashii
a8dc7ef515 Update dependencies for development 2021-02-18 21:30:50 +08:00
24 changed files with 160 additions and 246 deletions

3
.gitignore vendored
View file

@ -11,6 +11,7 @@
.project
.pub/
.scripts-bin/
.metals/
build/
**/packages/
@ -57,6 +58,8 @@ pubspec.lock
# Mongo Explorer plugin:
.idea/mongoSettings.xml
.vscode/
## File-based project format:
*.iws

View file

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.pub" />
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component>
</module>

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="ProjectInspectionProfilesVisibleTreeState">
<entry key="Project Default">
<profile-state>
<expanded-state>
<State>
<id />
</State>
<State>
<id>General</id>
</State>
<State>
<id>XPath</id>
</State>
</expanded-state>
<selected-state>
<State>
<id>AngularJS</id>
</State>
</selected-state>
</profile-state>
</entry>
</component>
</project>

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/angel.iml" filepath="$PROJECT_DIR$/.idea/angel.iml" />
</modules>
</component>
</project>

View file

@ -1,8 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="dev.dart" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application" singleton="true" nameIsGenerated="true">
<option name="VMOptions" value="--observe" />
<option name="filePath" value="$PROJECT_DIR$/bin/dev.dart" />
<option name="workingDirectory" value="$PROJECT_DIR$" />
<method />
</configuration>
</component>

View file

@ -1,11 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="prod.dart" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application" singleton="true" nameIsGenerated="true">
<option name="checkedMode" value="false" />
<option name="envs">
<entry key="ANGEL_ENV" value="production" />
</option>
<option name="filePath" value="$PROJECT_DIR$/bin/prod.dart" />
<option name="workingDirectory" value="$PROJECT_DIR$" />
<method />
</configuration>
</component>

12
AUTHORS.md Normal file
View file

@ -0,0 +1,12 @@
Primary Authors
===============
* __[Thomas Hii](dukefirehawk.apps@gmail.com)__
Thomas is the current maintainer of the code base. He has refactored and migrated the
code base to support NNBD.
* __[Tobe O](thosakwe@gmail.com)__
Tobe has written much of the original code prior to NNBD migration. He has moved on and
is no longer involved with the project.

7
CHANGELOG.md Normal file
View file

@ -0,0 +1,7 @@
# Change Log
## 1.0.0
* Changed to use `angel3` packages
* Updated to support NNBD
* Updated linter to `package:lints`

25
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,25 @@
# Contribution
Any help from the open-source community is always welcome and needed:
1. Found an issue?
- Please [fill a bug report][tracker] with error message and steps to reproduce it.
2. Wish a feature?
- Open a feature request with use cases.
3. Are you using and liking the project?
- Create an article about your use case
- Do a post on your likes and dislikes
- Make a donation.
4. Are you a developer?
- Fix a bug and send a [pull request][pull_request]
- Implement a new feature
- Improve the Unit Tests
- Improve the [User Guide][doc] and send a [document pull request][doc_repo]
5. Have you already helped in any way?
- **Many thanks to the contributors and everybody that uses this project!**
[tracker]: https://github.com/dukefirehawk/angel/issues
[pull_request]: https://github.com/dukefirehawk/angel/pulls
[doc]: https://angel3-docs.dukefirehawk.com
[doc_repo]: https://github.com/dukefirehawk/angel3-guide/pulls

View file

@ -1,14 +1,23 @@
FROM google/dart:latest
FROM dart:latest
COPY ./ ./
# Copy all the source code
COPY ./config /app/config
COPY ./lib /app/lib
COPY ./bin /app/bin
COPY ./views /app/views
COPY ./web /app/web
COPY ./*.yaml /app/
# Install dependencies, pre-build
RUN pub get
WORKDIR /app
RUN dart pub upgrade
# Optionally build generaed sources.
# Optionally build generated sources.
# RUN pub run build_runner build
# Set environment, start server
# Set environment, start server in JIT mode
ENV ANGEL_ENV=production
EXPOSE 3000
CMD dart bin/prod.dart
CMD dart ./bin/prod.dart -p 3000 -a 0.0.0.0
# Use -j flag to set higher number of isolates
#CMD dart ./bin/prod.dart -p 3000 -a 0.0.0.0 -j 50

42
LICENSE
View file

@ -1,21 +1,29 @@
The MIT License (MIT)
BSD 3-Clause License
Copyright (c) 2016 angel-dart
Copyright (c) 2021, dukefirehawk.com
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -1,60 +1,34 @@
[![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)
[![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)
![License](https://img.shields.io/github/license/angel-dart/framework.svg)
# Basic Starter Application for Angel3 framework
**A polished, production-ready backend framework in Dart.**
*Note: This repo is an application boilerplate ,and not the underlying framework library.*
-----
## About
Angel is a full-stack Web framework in Dart. It aims to
streamline development by providing many common features
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)...
This is a basic starter application for [Angel3 framework](https://angel3-framework.web.app) which is a full-stack Web framework in Dart.
## 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://dart.dev/get-dart).
Install the [Angel CLI](https://github.com/angel-dart/cli):
### Development
```bash
pub global activate angel_cli
```
1. Run the following command to start Angel3 server in dev mode to *hot-reloaded* on file changes:
Bootstrap a project:
```bash
dart --observe bin/dev.dart
```
```bash
angel init hello
```
2. Modify the code and watch the changes applied to the application
You can even have your server run and be *hot-reloaded* on file changes:
### Production
```bash
dart --observe bin/dev.dart
```
1. Run the following command:
Next, check out the [detailed documentation](https://docs.angel-dart.dev/v/2.x) to learn to flesh out your project.
```bash
dart bin/prod.dart
```
## Examples and Documentation
Visit the [documentation](https://docs.angel-dart.dev/v/2.x)
for dozens of guides and resources, including video tutorials,
to get up and running as quickly as possible with Angel.
2. Run as docker. Edit and run the provided `Dockerfile` to build the image.
Examples and complete projects can be found
[here](https://github.com/angel-dart/examples-v2).
## Resources
Visit the [Developer Guide](https://angel3-docs.dukefirehawk.com/guides) for dozens of guides and resources, including video tutorials, to get up and running as quickly as possible with Angel3.
You can also view the [API Documentation](http://www.dartdocs.org/documentation/angel_framework/latest).
There is also an [Awesome Angel :fire:](https://github.com/angel-dart/awesome-angel) list.
Examples and complete projects can be found [here](https://angel3-framework.web.app/#/examples).

View file

@ -1,8 +1 @@
include: package:pedantic/analysis_options.yaml
analyzer:
strong-mode:
implicit-casts: false
linter:
rules:
- unnecessary_const
- unnecessary_new
include: package:lints/recommended.yaml

View file

@ -1,17 +1,17 @@
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:belatuk_pretty_logging/belatuk_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:angel/angel.dart';
main() async {
void main() async {
// Watch the config/ and web/ directories for changes, and hot-reload the server.
hierarchicalLoggingEnabled = true;
var hot = HotReloader(() async {
var logger = Logger.detached('{{angel}}')
var logger = Logger.detached('Angel3')
..level = Level.ALL
..onRecord.listen(prettyLog);
var app = Angel(logger: logger, reflector: MirrorsReflector());
@ -24,5 +24,5 @@ main() async {
var server = await hot.startServer('127.0.0.1', 3000);
print(
'{{angel}} server listening at http://${server.address.address}:${server.port}');
'[Angel3] server listening at http://${server.address.address}:${server.port}');
}

View file

@ -1,6 +1,6 @@
import 'package:angel3_container/mirrors.dart';
import 'package:angel3_production/angel3_production.dart';
import 'package:angel/angel.dart';
import 'package:angel_container/mirrors.dart';
import 'package:angel_production/angel_production.dart';
// NOTE: By default, the Runner class does not use the `MirrorsReflector`, or any
// reflector, by default.
@ -17,7 +17,7 @@ import 'package:angel_production/angel_production.dart';
// so use it if possible.
//
// However, the following alternatives exist:
// * Generation via `package:angel_container_generator`
// * Generation via `package:angel3_container_generator`
// * Creating an instance of `StaticReflector`
// * Manually implementing the `Reflector` interface (cumbersome; not recommended)
//
@ -25,6 +25,5 @@ import 'package:angel_production/angel_production.dart';
// so in the meantime, visit the Angel chat for further questions:
//
// https://gitter.im/angel_dart/discussion
main(List<String> args) =>
Runner('{{angel}}', configureServer, reflector: MirrorsReflector())
.run(args);
void main(List<String> args) =>
Runner('Angel3', configureServer, reflector: MirrorsReflector()).run(args);

View file

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

View file

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

View file

@ -1,8 +1,6 @@
/// Custom plugins go here.
library angel.src.config.plugins;
import 'dart:async';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel3_framework/angel3_framework.dart';
Future configureServer(Angel app) async {
// 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,5 @@
library angel.src.routes.controllers;
import 'dart:async';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel3_framework/angel3_framework.dart';
Future configureServer(Angel app) async {
/// Controllers will not function unless wired to the application!

View file

@ -1,16 +1,14 @@
/// This app's route configuration.
library angel.src.routes;
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_static/angel_static.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_static/angel3_static.dart';
import 'package:file/file.dart';
import 'controllers/controllers.dart' as controllers;
/// Put your app routes here!
///
/// See the wiki for information about routing, requests, and responses:
/// * https://github.com/angel-dart/angel/wiki/Basic-Routing
/// * https://github.com/angel-dart/angel/wiki/Requests-&-Responses
/// * https://angel3-docs.dukefirehawk.com/guides/basic-routing
/// * https://angel3-docs.dukefirehawk.com/guides/requests-and-responses
AngelConfigurer configureServer(FileSystem fileSystem) {
return (Angel app) async {
// Typically, you want to mount controllers first, after any global middleware.
@ -27,7 +25,7 @@ AngelConfigurer configureServer(FileSystem fileSystem) {
//
// Read the following two sources for documentation:
// * https://medium.com/the-angel-framework/serving-static-files-with-the-angel-framework-2ddc7a2b84ae
// * https://github.com/angel-dart/static
// * https://pub.dev/packages/angel3_static
if (!app.environment.isProduction) {
var vDir = VirtualDirectory(
app,
@ -43,7 +41,7 @@ AngelConfigurer configureServer(FileSystem fileSystem) {
// Set our application up to handle different errors.
//
// Read the following for documentation:
// * https://github.com/angel-dart/angel/wiki/Error-Handling
// * https://angel3-docs.dukefirehawk.com/guides/error-handling
var oldErrorHandler = app.errorHandler;
app.errorHandler = (e, req, res) async {

View file

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

View file

@ -1,20 +1,25 @@
name: angel
description: An app that's going to be amazing pretty soon.
publish_to: none # Ensure we don't accidentally publish our private code! ;)
version: 1.0.0
description: A basic starter application template for Angel3 framework
publish_to: none
environment:
sdk: '>=2.0.0-dev <3.0.0'
homepage: https://github.com/angel-dart/angel
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel_auth: ^2.0.0 # Supports stateless authentication via JWT
angel_configuration: ^2.0.0 # Loads application configuration, along with support for .env files.
angel_framework: ^2.0.0 # The core server library.
angel_jael: ^2.0.0 # Server-side templating engine
angel_production: ^1.0.0 # Production application runner.
angel_static: ^2.0.0 # Static file server
angel_validate: ^2.0.0 # Allows for validation of input data
angel3_auth: ^6.0.0
angel3_configuration: ^6.0.0
angel3_framework: ^6.0.0
angel3_jael: ^6.0.0
angel3_production: ^6.0.0
angel3_static: ^6.0.0
angel3_validate: ^6.0.0
belatuk_pretty_logging: ^4.0.0
dev_dependencies:
angel_hot: ^2.0.0 # Hot-reloading support. :)
angel_test: ^2.0.0 # Utilities for testing Angel servers.
io: ^0.3.2 # For pretty printing.
pedantic: ^1.0.0 # Enforces Dart style conventions.
test: ^1.0.0 # For unit testing.
angel3_hot: ^6.0.0
angel3_test: ^6.0.0
io: ^1.0.0
test: ^1.21.0
lints: ^1.0.0

View file

@ -1,7 +1,7 @@
import 'package:angel/angel.dart';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_test/angel_test.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_test/angel3_test.dart';
import 'package:test/test.dart';
import 'package:angel/angel.dart';
// Angel also includes facilities to make testing easier.
//
@ -19,8 +19,8 @@ import 'package:test/test.dart';
// here:
// https://github.com/dart-lang/test
main() async {
TestClient client;
void main() async {
late TestClient client;
setUp(() async {
var app = Angel();
@ -35,7 +35,7 @@ main() async {
test('index returns 200', () async {
// Request a resource at the given path.
var response = await client.get('/');
var response = await client.get(Uri.parse('/'));
// Expect a 200 response.
expect(response, hasStatus(200));