Update to support v6.0.0

This commit is contained in:
thomashii 2022-03-15 13:25:51 +08:00
parent b5fea5806d
commit b1bd5c341e
14 changed files with 190 additions and 92 deletions

View file

@ -1,10 +1,11 @@
.dart_tool
.idea
.pub
.vscode
.metals
.git
.github
.packages
logs/
test/
build/
.analysis-options
.packages
*.g.dart
pubspec.lock

View file

@ -1,12 +0,0 @@
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.

View file

@ -2,8 +2,4 @@
## 1.0.0
* Changed to use `angel3` packages
* Updated to support NNBD
* Updated README
* Updated default `postgresql` setup
* Updated linter to `package:lints`
* Initial version

View file

@ -1,24 +0,0 @@
# 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,24 @@
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

View file

@ -5,7 +5,7 @@ This is an ORM starter application for [Angel3 framework](https://angel3-framewo
## Installation & Setup
1. Download and install [Dart](https://dart.dev/get-dart).
2. Install `postgresql` version 9, 10, 11 or 12. **postgresql 13 is not working as the driver do not support SCRAM**
2. Install `postgresql` version 10, 11, 12 and 13
3. Create a new user and database in postgres using `psql` cli. For example:
```sql
@ -46,13 +46,13 @@ This is an ORM starter application for [Angel3 framework](https://angel3-framewo
3. Insert a message into DB:
```
```bash
curl -H "Content-Type: application/json" -X POST -d '{"message":"OK_Message" }' "http://localhost:3000/greetings/"
```
or
```
```bash
curl -X POST -d 'message=OK_Message2' "http://localhost:3000/greetings/"
```
@ -61,7 +61,7 @@ This is an ORM starter application for [Angel3 framework](https://angel3-framewo
```
http://localhost:3000/greetings/
```
### Production
1. Run the following command:

View file

@ -11,7 +11,7 @@ void main() async {
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 @@ void main() async {
var server = await hot.startServer('127.0.0.1', 3000);
print(
'{{angel}} server listening at http://${server.address.address}:${server.port}');
'[angel] server listening at http://${server.address.address}:${server.port}');
}

View file

@ -26,5 +26,5 @@ import 'package:angel3_production/angel3_production.dart';
//
// https://gitter.im/angel_dart/discussion
void main(List<String> args) =>
Runner('{{angel}}', configureServer, reflector: MirrorsReflector())
Runner('[Angel3]', configureServer, reflector: MirrorsReflector())
.run(args);

View file

@ -10,3 +10,4 @@ postgres:
password: App1970#
useSSL: false
time_zone: UTC

View file

@ -6,15 +6,18 @@ import 'package:angel3_orm_postgres/angel3_orm_postgres.dart';
import 'package:postgres/postgres.dart';
Future<void> configureServer(Angel app) async {
var connection = await connectToPostgres(app.configuration);
await connection.open();
try {
var connection = await connectToPostgres(app.configuration);
await connection.open();
var logger = app.environment.isProduction ? null : app.logger;
var executor = PostgreSqlExecutor(connection, logger: logger);
var executor = PostgreSqlExecutor(connection, logger: app.logger);
app
..container!.registerSingleton<QueryExecutor>(executor)
..shutdownHooks.add((_) => connection.close());
app
..container.registerSingleton<QueryExecutor>(executor)
..shutdownHooks.add((_) => connection.close());
} catch (e) {
app.logger.severe("Failed to connect to PostgreSQL. ORM disabled.", e);
}
}
Future<PostgreSQLConnection> connectToPostgres(Map configuration) async {

View file

@ -1,5 +1,4 @@
import 'package:angel3_migration/angel3_migration.dart';
import 'package:angel3_model/angel3_model.dart';
import 'package:angel3_serialize/angel3_serialize.dart';
import 'package:angel3_orm/angel3_orm.dart';
import 'package:optional/optional.dart';

View file

@ -19,7 +19,7 @@ AngelConfigurer configureServer(FileSystem fileSystem) {
app.get('/', (req, res) => res.render('hello'));
app.get('/greetings', (req, res) {
var executor = req.container!.make<QueryExecutor>()!;
var executor = req.container!.make<QueryExecutor>();
var query = GreetingQuery();
return query.get(executor);
});
@ -30,7 +30,7 @@ AngelConfigurer configureServer(FileSystem fileSystem) {
if (!req.bodyAsMap.containsKey('message')) {
throw AngelHttpException.badRequest(message: 'Missing "message".');
} else {
var executor = req.container!.make<QueryExecutor>()!;
var executor = req.container!.make<QueryExecutor>();
var message = req.bodyAsMap['message'].toString();
var query = GreetingQuery()..values.message = message;
var optional = await query.insert(executor);
@ -40,7 +40,7 @@ AngelConfigurer configureServer(FileSystem fileSystem) {
app.get('/greetings/:message', (req, res) {
var message = req.params['message'] as String;
var executor = req.container!.make<QueryExecutor>()!;
var executor = req.container!.make<QueryExecutor>();
var query = GreetingQuery()..where!.message.equals(message);
return query.get(executor);
});

View file

@ -3,32 +3,156 @@ version: 1.0.0
description: An ORM starter application for Angel3 framework
publish_to: none
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.15.0 <3.0.0'
dependencies:
angel3_auth: ^4.0.0
angel3_configuration: ^4.1.0
angel3_framework: ^4.2.0
angel3_jael: ^4.2.0
angel3_migration: ^4.0.0
angel3_orm: ^4.0.0
angel3_orm_postgres: ^3.0.0
angel3_serialize: ^4.1.0
angel3_production: ^3.1.0
angel3_static: ^4.1.0
angel3_validate: ^4.0.0
angel3_auth: ^6.0.0
angel3_configuration: ^6.0.0
angel3_framework: ^6.0.0
angel3_jael: ^6.0.0
angel3_migration: ^6.0.0
angel3_orm: ^6.0.0
angel3_orm_postgres: ^6.0.0
angel3_serialize: ^6.0.0
angel3_production: ^6.0.0
angel3_static: ^6.0.0
angel3_validate: ^6.0.0
belatuk_pretty_logging: ^4.0.0
optional: ^6.0.0
logging: ^1.0.0
dev_dependencies:
angel3_hot: ^4.2.0
angel3_migration_runner: ^4.0.0
angel3_orm_generator: ^4.1.0
angel3_serialize_generator: ^4.2.0
angel3_test: ^4.0.0
angel3_hot: ^6.0.0
angel3_migration_runner: ^6.0.0
angel3_orm_generator: ^6.0.0
angel3_serialize_generator: ^6.0.0
angel3_test: ^6.0.0
build_runner: ^2.0.3
io: ^1.0.0
test: ^1.17.5
lints: ^1.0.0
dependency_overrides:
angel3_container:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/container/angel_container
angel3_framework:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/framework
angel3_http_exception:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/http_exception
angel3_model:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/model
angel3_route:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/route
angel3_mock_request:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/mock_request
angel3_auth:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/auth
angel3_client:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/client
angel3_websocket:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/websocket
angel3_validate:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/validate
angel3_configuration:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/configuration
angel3_test:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/test
jael3:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/jael/jael
angel3_jael:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/jael/angel_jael
jael3_preprocessor:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/jael/jael_preprocessor
angel3_serialize:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/serialize/angel_serialize
angel3_serialize_generator:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/serialize/angel_serialize_generator
angel3_hot:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/hot
angel3_static:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/static
angel3_production:
path: ../belatuk/packages/production
# git:
# url: https://github.com/dukefirehawk/angel.git
# ref: release/6.0.0
# path: packages/production
angel3_orm:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/orm/angel_orm
angel3_orm_generator:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/orm/angel_orm_generator
angel3_orm_postgres:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/orm/angel_orm_postgres
angel3_migration:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/orm/angel_migration
angel3_migration_runner:
git:
url: https://github.com/dukefirehawk/angel.git
ref: release/6.0.0
path: packages/orm/angel_migration_runner

View file

@ -3,8 +3,8 @@
<head>
<title>{{ title ?? 'Angel' }}</title>
<link href="https://fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="/css/site.css">
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Lato:100" >
<link rel="stylesheet" type="text/css" href="/css/site.css">
<link rel="icon" href="/images/favicon.png">
</head>
<body>