commit
4839e2cef5
14 changed files with 65 additions and 96 deletions
|
@ -1,10 +1,11 @@
|
|||
.dart_tool
|
||||
.idea
|
||||
.pub
|
||||
.vscode
|
||||
.metals
|
||||
.git
|
||||
.github
|
||||
.packages
|
||||
logs/
|
||||
test/
|
||||
build/
|
||||
.analysis-options
|
||||
.packages
|
||||
*.g.dart
|
||||
pubspec.lock
|
12
AUTHORS.md
12
AUTHORS.md
|
@ -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.
|
|
@ -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
|
||||
|
|
|
@ -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
|
24
Dockerfile
24
Dockerfile
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -43,16 +43,15 @@ This is an ORM starter application for [Angel3 framework](https://angel3-framewo
|
|||
|
||||
2. Modify the code and watch the changes applied to the application
|
||||
|
||||
|
||||
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 +60,7 @@ This is an ORM starter application for [Angel3 framework](https://angel3-framewo
|
|||
```
|
||||
http://localhost:3000/greetings/
|
||||
```
|
||||
|
||||
|
||||
### Production
|
||||
|
||||
1. Run the following command:
|
||||
|
|
|
@ -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}');
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import 'package:angel3_production/angel3_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)
|
||||
//
|
||||
|
@ -26,5 +26,4 @@ import 'package:angel3_production/angel3_production.dart';
|
|||
//
|
||||
// https://gitter.im/angel_dart/discussion
|
||||
void main(List<String> args) =>
|
||||
Runner('{{angel}}', configureServer, reflector: MirrorsReflector())
|
||||
.run(args);
|
||||
Runner('Angel3', configureServer, reflector: MirrorsReflector()).run(args);
|
||||
|
|
|
@ -10,3 +10,4 @@ postgres:
|
|||
password: App1970#
|
||||
use_ssl: false
|
||||
time_zone: UTC
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
39
pubspec.yaml
39
pubspec.yaml
|
@ -3,32 +3,29 @@ 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.16.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
|
||||
test: ^1.21.0
|
||||
lints: ^1.0.0
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue