Compare commits
27 commits
angel3-orm
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
d6a81afab5 | ||
|
fd4abfaf43 | ||
|
d171e49fc2 | ||
|
debada01f2 | ||
|
4bdddcdfed | ||
|
023d239c1f | ||
|
6867696218 | ||
|
f46ec8058d | ||
|
597ea5323a | ||
|
8a6bd74bf2 | ||
|
2f8dd31c6a | ||
|
dfd864f0b7 | ||
|
9e66a1af47 | ||
|
be518fa3c0 | ||
|
197e4c95e5 | ||
|
89dde22a52 | ||
|
539696222d | ||
|
c19f92ba35 | ||
|
d74bde03e2 | ||
|
e986fca7bb | ||
|
41d83a274b | ||
|
528dca2db9 | ||
|
93cdb671d5 | ||
|
ff8b0e60a8 | ||
|
00b14878a8 | ||
|
4f1913d517 | ||
|
a8dc7ef515 |
24 changed files with 85 additions and 477 deletions
|
@ -1,11 +1,10 @@
|
|||
.dart_tool
|
||||
.idea
|
||||
.pub
|
||||
.vscode
|
||||
.metals
|
||||
.git
|
||||
.github
|
||||
.packages
|
||||
logs/
|
||||
test/
|
||||
build/
|
||||
pubspec.lock
|
||||
.analysis-options
|
||||
.packages
|
||||
*.g.dart
|
3
.github/FUNDING.yml
vendored
Normal file
3
.github/FUNDING.yml
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
# These are supported funding model platforms
|
||||
|
||||
github: [thosakwe]
|
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -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
|
||||
|
||||
|
@ -78,7 +81,7 @@ crashlytics-build.properties
|
|||
fabric.properties
|
||||
|
||||
### VSCode template
|
||||
.vscode/
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
|
@ -88,5 +91,3 @@ logs/
|
|||
*.pem
|
||||
.DS_Store
|
||||
server_log.txt
|
||||
|
||||
.metals/
|
||||
|
|
12
AUTHORS.md
Normal file
12
AUTHORS.md
Normal 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.
|
|
@ -2,4 +2,6 @@
|
|||
|
||||
## 1.0.0
|
||||
|
||||
* Initial version
|
||||
* Changed to use `angel3` packages
|
||||
* Updated to support NNBD
|
||||
* Updated linter to `package:lints`
|
||||
|
|
25
CONTRIBUTING.md
Normal file
25
CONTRIBUTING.md
Normal 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
|
|
@ -20,5 +20,4 @@ EXPOSE 3000
|
|||
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
|
||||
|
||||
#CMD dart ./bin/prod.dart -p 3000 -a 0.0.0.0 -j 50
|
52
README.md
52
README.md
|
@ -1,37 +1,11 @@
|
|||
# ORM Starter Application for Angel3 framework
|
||||
|
||||
This is an ORM starter application for [Angel3 framework](https://angel3-framework.web.app) which is a full-stack Web framework in Dart. The default database is `postgresql`. `mysql` support is still in active development.
|
||||
# Basic Starter Application for Angel3 framework
|
||||
|
||||
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
|
||||
|
||||
1. Download and install [Dart](https://dart.dev/get-dart).
|
||||
2. Install `postgresql` version 10, 11, 12 and 13
|
||||
3. Create a new user and database in postgres using `psql` cli. For example:
|
||||
|
||||
```sql
|
||||
postgres=# create database appdb;
|
||||
postgres=# create user appuser with encrypted password 'App1970#';
|
||||
postgres=# grant all privileges on database appdb to appuser;
|
||||
```
|
||||
|
||||
4. Update the `postgres` section in the `config/default.yaml` file with the newly created user and database name.
|
||||
|
||||
```yaml
|
||||
postgres:
|
||||
host: localhost
|
||||
port: 5432
|
||||
database_name: appdb
|
||||
username: appuser
|
||||
password: App1970#
|
||||
useSSL: false
|
||||
time_zone: UTC
|
||||
```
|
||||
|
||||
5. Run the migration to generate `migrations` and `greetings` tables in the database.
|
||||
|
||||
```bash
|
||||
dart bin/migrate.dart up
|
||||
```
|
||||
|
||||
### Development
|
||||
|
||||
|
@ -43,24 +17,6 @@ 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/"
|
||||
```
|
||||
|
||||
4. Query DB:
|
||||
|
||||
```
|
||||
http://localhost:3000/greetings/
|
||||
```
|
||||
|
||||
### Production
|
||||
|
||||
1. Run the following command:
|
||||
|
@ -76,5 +32,3 @@ This is an ORM starter application for [Angel3 framework](https://angel3-framewo
|
|||
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.
|
||||
|
||||
Examples and complete projects can be found [here](https://angel3-framework.web.app/#/examples).
|
||||
|
||||
You can also view the [API Documentation](https://pub.dev/documentation/angel3_framework/latest/).
|
||||
|
|
|
@ -1 +1 @@
|
|||
include: package:lints/recommended.yaml
|
||||
include: package:lints/recommended.yaml
|
|
@ -1,10 +1,10 @@
|
|||
import 'dart:io';
|
||||
import 'package:angel/angel.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:logging/logging.dart';
|
||||
import 'package:angel/angel.dart';
|
||||
|
||||
void main() async {
|
||||
// Watch the config/ and web/ directories for changes, and hot-reload the server.
|
||||
|
@ -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}');
|
||||
'[Angel3] server listening at http://${server.address.address}:${server.port}');
|
||||
}
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
import 'package:angel/src/config/plugins/orm.dart';
|
||||
import 'package:angel/models.dart';
|
||||
import 'package:angel3_configuration/angel3_configuration.dart';
|
||||
import 'package:angel3_migration_runner/angel3_migration_runner.dart';
|
||||
import 'package:angel3_migration_runner/postgres.dart';
|
||||
import 'package:file/local.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
void main(List<String> args) async {
|
||||
// Enable the logging
|
||||
Logger.root.level = Level.INFO;
|
||||
Logger.root.onRecord.listen((rec) {
|
||||
print('${rec.time}: ${rec.level.name}: ${rec.loggerName}: ${rec.message}');
|
||||
|
||||
if (rec.error != null) {
|
||||
print(rec.error);
|
||||
print(rec.stackTrace);
|
||||
}
|
||||
});
|
||||
|
||||
var fs = LocalFileSystem();
|
||||
var configuration = await loadStandaloneConfiguration(fs);
|
||||
var connection = await connectToPostgres(configuration);
|
||||
var migrationRunner = PostgresMigrationRunner(connection, migrations: [
|
||||
GreetingMigration(),
|
||||
]);
|
||||
return await runMigrations(migrationRunner, args);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:angel/angel.dart';
|
||||
import 'package:angel3_container/mirrors.dart';
|
||||
import 'package:angel3_production/angel3_production.dart';
|
||||
import 'package:angel/angel.dart';
|
||||
|
||||
// NOTE: By default, the Runner class does not use the `MirrorsReflector`, or any
|
||||
// reflector, by default.
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
# Default server configuration.
|
||||
jwt_secret: INSECURE_DEFAULT_SECRET
|
||||
host: 127.0.0.1
|
||||
mongo_db: mongodb://localhost:27017/angel
|
||||
port: 3000
|
||||
postgres:
|
||||
host: localhost
|
||||
port: 5432
|
||||
database_name: appdb
|
||||
username: appuser
|
||||
password: App1970#
|
||||
use_ssl: false
|
||||
time_zone: UTC
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
export 'src/models/greeting.dart';
|
|
@ -1,3 +1,4 @@
|
|||
/// Configuration for this Angel instance.
|
||||
import 'package:angel3_configuration/angel3_configuration.dart';
|
||||
import 'package:angel3_framework/angel3_framework.dart';
|
||||
import 'package:angel3_jael/angel3_jael.dart';
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:angel3_framework/angel3_framework.dart';
|
||||
import 'package:angel3_orm/angel3_orm.dart';
|
||||
import 'package:angel3_orm_postgres/angel3_orm_postgres.dart';
|
||||
import 'package:postgres/postgres.dart';
|
||||
|
||||
Future<void> configureServer(Angel app) async {
|
||||
try {
|
||||
var connection = await connectToPostgres(app.configuration);
|
||||
await connection.open();
|
||||
|
||||
var executor = PostgreSqlExecutor(connection, logger: app.logger);
|
||||
|
||||
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 {
|
||||
var postgresConfig = configuration['postgres'] as Map? ?? {};
|
||||
var connection = PostgreSQLConnection(
|
||||
postgresConfig['host'] as String? ?? 'localhost',
|
||||
postgresConfig['port'] as int? ?? 5432,
|
||||
postgresConfig['database_name'] as String? ??
|
||||
Platform.environment['USER'] ??
|
||||
Platform.environment['USERNAME'] ??
|
||||
'',
|
||||
username: postgresConfig['username'] as String?,
|
||||
password: postgresConfig['password'] as String?,
|
||||
timeZone: postgresConfig['time_zone'] as String? ?? 'UTC',
|
||||
timeoutInSeconds: postgresConfig['timeout_in_seconds'] as int? ?? 30,
|
||||
useSSL: postgresConfig['use_ssl'] as bool? ?? false);
|
||||
return connection;
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
/// Custom plugins go here.
|
||||
import 'dart:async';
|
||||
import 'package:angel3_framework/angel3_framework.dart';
|
||||
import 'orm.dart' as orm;
|
||||
|
||||
Future configureServer(Angel app) async {
|
||||
// Include any plugins you have made here.
|
||||
await app.configure(orm.configureServer);
|
||||
}
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
import 'package:angel3_migration/angel3_migration.dart';
|
||||
import 'package:angel3_serialize/angel3_serialize.dart';
|
||||
import 'package:angel3_orm/angel3_orm.dart';
|
||||
import 'package:optional/optional.dart';
|
||||
part 'greeting.g.dart';
|
||||
|
||||
@serializable
|
||||
@orm
|
||||
abstract class _Greeting extends Model {
|
||||
@SerializableField(isNullable: false)
|
||||
String? get message;
|
||||
}
|
|
@ -1,267 +0,0 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'greeting.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// MigrationGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class GreetingMigration extends Migration {
|
||||
@override
|
||||
void up(Schema schema) {
|
||||
schema.create('greetings', (table) {
|
||||
table.serial('id').primaryKey();
|
||||
table.varChar('message');
|
||||
table.timeStamp('created_at');
|
||||
table.timeStamp('updated_at');
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void down(Schema schema) {
|
||||
schema.drop('greetings');
|
||||
}
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// OrmGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class GreetingQuery extends Query<Greeting, GreetingQueryWhere> {
|
||||
GreetingQuery({Set<String>? trampoline}) {
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = GreetingQueryWhere(this);
|
||||
}
|
||||
|
||||
@override
|
||||
final GreetingQueryValues values = GreetingQueryValues();
|
||||
|
||||
GreetingQueryWhere? _where;
|
||||
|
||||
@override
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
String get tableName {
|
||||
return 'greetings';
|
||||
}
|
||||
|
||||
@override
|
||||
List<String> get fields {
|
||||
return const ['id', 'message', 'created_at', 'updated_at'];
|
||||
}
|
||||
|
||||
@override
|
||||
GreetingQueryWhere? get where {
|
||||
return _where;
|
||||
}
|
||||
|
||||
@override
|
||||
GreetingQueryWhere newWhereClause() {
|
||||
return GreetingQueryWhere(this);
|
||||
}
|
||||
|
||||
static Greeting? parseRow(List row) {
|
||||
if (row.every((x) => x == null)) return null;
|
||||
var model = Greeting(
|
||||
id: row[0].toString(),
|
||||
message: (row[1] as String?),
|
||||
createdAt: (row[2] as DateTime?),
|
||||
updatedAt: (row[3] as DateTime?));
|
||||
return model;
|
||||
}
|
||||
|
||||
@override
|
||||
Optional<Greeting> deserialize(List row) {
|
||||
return Optional.ofNullable(parseRow(row));
|
||||
}
|
||||
}
|
||||
|
||||
class GreetingQueryWhere extends QueryWhere {
|
||||
GreetingQueryWhere(GreetingQuery query)
|
||||
: id = NumericSqlExpressionBuilder<int>(query, 'id'),
|
||||
message = StringSqlExpressionBuilder(query, 'message'),
|
||||
createdAt = DateTimeSqlExpressionBuilder(query, 'created_at'),
|
||||
updatedAt = DateTimeSqlExpressionBuilder(query, 'updated_at');
|
||||
|
||||
final NumericSqlExpressionBuilder<int> id;
|
||||
|
||||
final StringSqlExpressionBuilder message;
|
||||
|
||||
final DateTimeSqlExpressionBuilder createdAt;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt;
|
||||
|
||||
@override
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [id, message, createdAt, updatedAt];
|
||||
}
|
||||
}
|
||||
|
||||
class GreetingQueryValues extends MapQueryValues {
|
||||
@override
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
String? get id {
|
||||
return (values['id'] as String?);
|
||||
}
|
||||
|
||||
set id(String? value) => values['id'] = value;
|
||||
String? get message {
|
||||
return (values['message'] as String?);
|
||||
}
|
||||
|
||||
set message(String? value) => values['message'] = value;
|
||||
DateTime? get createdAt {
|
||||
return (values['created_at'] as DateTime?);
|
||||
}
|
||||
|
||||
set createdAt(DateTime? value) => values['created_at'] = value;
|
||||
DateTime? get updatedAt {
|
||||
return (values['updated_at'] as DateTime?);
|
||||
}
|
||||
|
||||
set updatedAt(DateTime? value) => values['updated_at'] = value;
|
||||
void copyFrom(Greeting model) {
|
||||
message = model.message;
|
||||
createdAt = model.createdAt;
|
||||
updatedAt = model.updatedAt;
|
||||
}
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonModelGenerator
|
||||
// **************************************************************************
|
||||
|
||||
@generatedSerializable
|
||||
class Greeting extends _Greeting {
|
||||
Greeting({this.id, required this.message, this.createdAt, this.updatedAt});
|
||||
|
||||
@override
|
||||
final String? id;
|
||||
|
||||
@override
|
||||
final String? message;
|
||||
|
||||
@override
|
||||
final DateTime? createdAt;
|
||||
|
||||
@override
|
||||
final DateTime? updatedAt;
|
||||
|
||||
Greeting copyWith(
|
||||
{String? id, String? message, DateTime? createdAt, DateTime? updatedAt}) {
|
||||
return Greeting(
|
||||
id: id ?? this.id,
|
||||
message: message ?? this.message,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Greeting &&
|
||||
other.id == id &&
|
||||
other.message == message &&
|
||||
other.createdAt == createdAt &&
|
||||
other.updatedAt == updatedAt;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return hashObjects([id, message, createdAt, updatedAt]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Greeting(id=$id, message=$message, createdAt=$createdAt, updatedAt=$updatedAt)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return GreetingSerializer.toMap(this);
|
||||
}
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// SerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
const GreetingSerializer greetingSerializer = GreetingSerializer();
|
||||
|
||||
class GreetingEncoder extends Converter<Greeting, Map> {
|
||||
const GreetingEncoder();
|
||||
|
||||
@override
|
||||
Map convert(Greeting model) => GreetingSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class GreetingDecoder extends Converter<Map, Greeting> {
|
||||
const GreetingDecoder();
|
||||
|
||||
@override
|
||||
Greeting convert(Map map) => GreetingSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class GreetingSerializer extends Codec<Greeting, Map> {
|
||||
const GreetingSerializer();
|
||||
|
||||
@override
|
||||
GreetingEncoder get encoder => const GreetingEncoder();
|
||||
|
||||
@override
|
||||
GreetingDecoder get decoder => const GreetingDecoder();
|
||||
static Greeting fromMap(Map map) {
|
||||
if (map['message'] == null) {
|
||||
throw FormatException("Missing required field 'message' on Greeting.");
|
||||
}
|
||||
|
||||
return Greeting(
|
||||
id: map['id'] as String?,
|
||||
message: map['message'] as String?,
|
||||
createdAt: map['created_at'] != null
|
||||
? (map['created_at'] is DateTime
|
||||
? (map['created_at'] as DateTime?)
|
||||
: DateTime.parse(map['created_at'].toString()))
|
||||
: null,
|
||||
updatedAt: map['updated_at'] != null
|
||||
? (map['updated_at'] is DateTime
|
||||
? (map['updated_at'] as DateTime?)
|
||||
: DateTime.parse(map['updated_at'].toString()))
|
||||
: null);
|
||||
}
|
||||
|
||||
static Map<String, dynamic> toMap(_Greeting model) {
|
||||
if (model.message == null) {
|
||||
throw FormatException("Missing required field 'message' on Greeting.");
|
||||
}
|
||||
|
||||
return {
|
||||
'id': model.id,
|
||||
'message': model.message,
|
||||
'created_at': model.createdAt?.toIso8601String(),
|
||||
'updated_at': model.updatedAt?.toIso8601String()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
abstract class GreetingFields {
|
||||
static const List<String> allFields = <String>[
|
||||
id,
|
||||
message,
|
||||
createdAt,
|
||||
updatedAt
|
||||
];
|
||||
|
||||
static const String id = 'id';
|
||||
|
||||
static const String message = 'message';
|
||||
|
||||
static const String createdAt = 'created_at';
|
||||
|
||||
static const String updatedAt = 'updated_at';
|
||||
}
|
|
@ -1,9 +1,8 @@
|
|||
/// This app's route configuration.
|
||||
import 'package:angel3_framework/angel3_framework.dart';
|
||||
import 'package:angel3_orm/angel3_orm.dart';
|
||||
import 'package:angel3_static/angel3_static.dart';
|
||||
import 'package:file/file.dart';
|
||||
import 'controllers/controllers.dart' as controllers;
|
||||
import '../models/greeting.dart';
|
||||
|
||||
/// Put your app routes here!
|
||||
///
|
||||
|
@ -18,33 +17,6 @@ AngelConfigurer configureServer(FileSystem fileSystem) {
|
|||
// Render `views/hello.jl` when a user visits the application root.
|
||||
app.get('/', (req, res) => res.render('hello'));
|
||||
|
||||
app.get('/greetings', (req, res) {
|
||||
var executor = req.container!.make<QueryExecutor>();
|
||||
var query = GreetingQuery();
|
||||
return query.get(executor);
|
||||
});
|
||||
|
||||
app.post('/greetings', (req, res) async {
|
||||
await req.parseBody();
|
||||
|
||||
if (!req.bodyAsMap.containsKey('message')) {
|
||||
throw AngelHttpException.badRequest(message: 'Missing "message".');
|
||||
} else {
|
||||
var executor = req.container!.make<QueryExecutor>();
|
||||
var message = req.bodyAsMap['message'].toString();
|
||||
var query = GreetingQuery()..values.message = message;
|
||||
var optional = await query.insert(executor);
|
||||
return optional.value;
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/greetings/:message', (req, res) {
|
||||
var message = req.params['message'] as String;
|
||||
var executor = req.container!.make<QueryExecutor>();
|
||||
var query = GreetingQuery()..where!.message.equals(message);
|
||||
return query.get(executor);
|
||||
});
|
||||
|
||||
// Mount static server at web in development.
|
||||
// The `CachingVirtualDirectory` variant of `VirtualDirectory` also sends `Cache-Control` headers.
|
||||
//
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/// Declare services here!
|
||||
import 'dart:async';
|
||||
import 'package:angel3_framework/angel3_framework.dart';
|
||||
|
||||
|
|
40
pubspec.yaml
40
pubspec.yaml
|
@ -1,31 +1,25 @@
|
|||
name: angel
|
||||
version: 1.0.0
|
||||
description: An ORM starter application for Angel3 framework
|
||||
description: A basic starter application template for Angel3 framework
|
||||
publish_to: none
|
||||
environment:
|
||||
sdk: '>=3.0.0 <4.0.0'
|
||||
sdk: '>=2.16.0 <3.0.0'
|
||||
dependencies:
|
||||
angel3_auth: ^8.0.0
|
||||
angel3_configuration: ^8.0.0
|
||||
angel3_framework: ^8.0.0
|
||||
angel3_jael: ^8.0.0
|
||||
angel3_migration: ^8.0.0
|
||||
angel3_orm: ^8.0.0
|
||||
angel3_orm_postgres: ^8.0.0
|
||||
angel3_serialize: ^8.0.0
|
||||
angel3_production: ^8.0.0
|
||||
angel3_static: ^8.0.0
|
||||
angel3_validate: ^8.0.0
|
||||
belatuk_pretty_logging: ^6.0.0
|
||||
optional: ^6.0.0
|
||||
logging: ^1.0.0
|
||||
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:
|
||||
angel3_hot: ^8.0.0
|
||||
angel3_migration_runner: ^8.0.0
|
||||
angel3_orm_generator: ^8.0.0
|
||||
angel3_serialize_generator: ^8.0.0
|
||||
angel3_test: ^8.0.0
|
||||
build_runner: ^2.0.3
|
||||
angel3_hot: ^6.0.0
|
||||
angel3_test: ^6.0.0
|
||||
io: ^1.0.0
|
||||
test: ^1.21.0
|
||||
lints: ^2.0.0
|
||||
lints: ^1.0.0
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:angel/angel.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.
|
||||
//
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
<head>
|
||||
<title>{{ title ?? 'Angel' }}</title>
|
||||
|
||||
<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 href="https://fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css">
|
||||
<link rel="stylesheet" href="/css/site.css">
|
||||
<link rel="icon" href="/images/favicon.png">
|
||||
</head>
|
||||
<body>
|
||||
|
|
Loading…
Reference in a new issue