diff --git a/.dockerignore b/.dockerignore index faf23bd..003c2d9 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,10 +1,11 @@ .dart_tool .idea -.pub .vscode +.metals +.git +.github +.packages logs/ test/ build/ -.analysis-options -.packages -*.g.dart \ No newline at end of file +pubspec.lock \ No newline at end of file diff --git a/AUTHORS.md b/AUTHORS.md deleted file mode 100644 index ac95ab5..0000000 --- a/AUTHORS.md +++ /dev/null @@ -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. diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c9985b..74a3368 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index b34fbca..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -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 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index c84bc87..91ac9d2 100644 --- a/Dockerfile +++ b/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 + diff --git a/README.md b/README.md index 6da72da..3e7ed2f 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/bin/dev.dart b/bin/dev.dart index 926466c..1d695f2 100644 --- a/bin/dev.dart +++ b/bin/dev.dart @@ -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}'); } diff --git a/bin/prod.dart b/bin/prod.dart index efd1e5e..4c861af 100644 --- a/bin/prod.dart +++ b/bin/prod.dart @@ -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 args) => - Runner('{{angel}}', configureServer, reflector: MirrorsReflector()) - .run(args); + Runner('Angel3', configureServer, reflector: MirrorsReflector()).run(args); diff --git a/config/default.yaml b/config/default.yaml index ead2e14..fed19e9 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -10,3 +10,4 @@ postgres: password: App1970# use_ssl: false time_zone: UTC + diff --git a/lib/src/config/plugins/orm.dart b/lib/src/config/plugins/orm.dart index be286f8..66d66d5 100644 --- a/lib/src/config/plugins/orm.dart +++ b/lib/src/config/plugins/orm.dart @@ -6,15 +6,18 @@ import 'package:angel3_orm_postgres/angel3_orm_postgres.dart'; import 'package:postgres/postgres.dart'; Future 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(executor) - ..shutdownHooks.add((_) => connection.close()); + app + ..container.registerSingleton(executor) + ..shutdownHooks.add((_) => connection.close()); + } catch (e) { + app.logger.severe("Failed to connect to PostgreSQL. ORM disabled.", e); + } } Future connectToPostgres(Map configuration) async { diff --git a/lib/src/models/greeting.dart b/lib/src/models/greeting.dart index b07c747..89eb1f2 100644 --- a/lib/src/models/greeting.dart +++ b/lib/src/models/greeting.dart @@ -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'; diff --git a/lib/src/routes/routes.dart b/lib/src/routes/routes.dart index 25d82ff..cd0bbf1 100644 --- a/lib/src/routes/routes.dart +++ b/lib/src/routes/routes.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()!; + var executor = req.container!.make(); 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()!; + var executor = req.container!.make(); 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()!; + var executor = req.container!.make(); var query = GreetingQuery()..where!.message.equals(message); return query.get(executor); }); diff --git a/pubspec.yaml b/pubspec.yaml index 0cda9fb..46c9338 100644 --- a/pubspec.yaml +++ b/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 - - - diff --git a/views/layout.jael b/views/layout.jael index ea0714b..7a2c5cd 100644 --- a/views/layout.jael +++ b/views/layout.jael @@ -3,8 +3,8 @@ {{ title ?? 'Angel' }} - - + +