Skip to content

Commit

Permalink
Merge pull request #8 from RicardoRB/0.5.0-alpha
Browse files Browse the repository at this point in the history
0.5.0 alpha
  • Loading branch information
RicardoRB committed Oct 19, 2023
2 parents 92cbc35 + 472611f commit 1e85084
Show file tree
Hide file tree
Showing 343 changed files with 11,290 additions and 9,386 deletions.
52 changes: 38 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,54 @@ You can check the documentation at [dartness docs](https://ricardorb.github.io/d
$ dart create -t console your_project_name
```

1. Add dartness into the pubspec.yaml
### 1. Add dartness into the pubspec.yaml

```yaml
dependencies:
dartness_server: ^0.4.5-alpha
dartness_server: ^0.5.0-alpha

dev_dependencies:
build_runner: ^2.2.0
dartness_generator: ^0.1.2-alpha
dartness_generator: ^0.4.6-alpha
```
2. Create the file in "bin/main.dart"
### 2.Create the file in "src/app.dart"
```dart
void main() async {
final app = Dartness(
port: 3000,
);
await app.create();
}
@Application(
module: Module(
metadata: ModuleMetadata(
controllers: [],
providers: [],
exports: [],
imports: [],
),
),
options: DartnessApplicationOptions(
port: int.fromEnvironment(
'port',
defaultValue: 8080,
),
),
)
class App {}
```

### 4.Generate the code

```bash
$ dart run build_runner build
```

### 5.Modify "bin/main.dart"
```dart
void main(List<String> args) async {
await App().init();
}
```

3. Run the server
### 6.Run the server

```bash
$ dart run bin/main.dart
Expand Down Expand Up @@ -99,13 +123,13 @@ Server listening on port 3000
- <del>Middleware</del>
- <del>Interceptor</del>
- Websockets
2. Exceptions
2. <del>Exceptions</del>
- <del>Exception Handler</del>
3. Security
- Roles
- CORS
4. Dependency Injection
- Injectable
4. <del>Dependency Injection</del>
- <del>Injectable</del>
5. Scheduling
- Annotation
6. Database
Expand Down
54 changes: 39 additions & 15 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ the [/examples folder](https://github.com/RicardoRB/dartness/tree/master/example

## Requisites

Install [Dart SDK](https://dart.dev/get-dart) version >=2.17.0
Install [Dart SDK](https://dart.dev/get-dart) version >=3.0.0

```bash
$ dart --version
Expand All @@ -47,30 +47,54 @@ You can check the documentation at [dartness docs](https://ricardorb.github.io/d
$ dart create -t console your_project_name
```

1. Add dartness into the pubspec.yaml
### 1. Add dartness into the pubspec.yaml

```yaml
dependencies:
dartness_server: ^0.4.3-alpha
dartness_server: ^0.5.0-alpha

dev_dependencies:
build_runner: ^2.2.0
dartness_generator: ^0.1.0-alpha
dartness_generator: ^0.4.6-alpha
```
2. Create the file in "bin/main.dart"
### 2.Create the file in "src/app.dart"
```dart
void main() async {
final app = Dartness(
port: 3000,
);
await app.create();
}
@Application(
module: Module(
metadata: ModuleMetadata(
controllers: [],
providers: [],
exports: [],
imports: [],
),
),
options: DartnessApplicationOptions(
port: int.fromEnvironment(
'port',
defaultValue: 8080,
),
),
)
class App {}
```

### 4.Generate the code

```bash
$ dart run build_runner build
```

### 5.Modify "bin/main.dart"
```dart
void main(List<String> args) async {
await App().init();
}
```

3. Run the server
### 6.Run the server

```bash
$ dart run bin/main.dart
Expand Down Expand Up @@ -99,13 +123,13 @@ Server listening on port 3000
- <del>Middleware</del>
- <del>Interceptor</del>
- Websockets
2. Exceptions
2. <del>Exceptions</del>
- <del>Exception Handler</del>
3. Security
- Roles
- CORS
4. Dependency Injection
- Injectable
4. <del>Dependency Injection</del>
- <del>Injectable</del>
5. Scheduling
- Annotation
6. Database
Expand Down
32 changes: 22 additions & 10 deletions docs/exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,26 @@ This new created class accepts an instance of the class from where have been cre
must be used in the `errorHandlers` param. You can see an example in the following code:

```dart
void main() async {
final errorHandlers = [
ExampleDartnessErrorHandler(ExampleErrorHandler()),
];
final app = Dartness(
port: 3000,
errorHandlers: errorHandlers,
);
await app.create();
}
@Application(
module: Module(
metadata: ModuleMetadata(
controllers: [],
providers: [
ProviderMetadata(
classType: MyException,
),
],
exports: [],
imports: [],
),
),
options: DartnessApplicationOptions(
port: int.fromEnvironment(
'port',
defaultValue: 8080,
),
),
)
class App {}
```
66 changes: 45 additions & 21 deletions docs/first_steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,32 @@ Please make sure that [Dart SDK](https://dart.dev/get-dart) version >=2.17.0 is
$ dart create -t console your_project_name
```

1. Add dartness into the pubspec.yaml
### 1. Add dartness into the pubspec.yaml

```yaml
dependencies:
dartness_server: ^0.4.3-alpha
dartness_server: ^0.5.0-alpha

dev_dependencies:
build_runner: ^2.2.0
dartness_generator: ^0.1.0-alpha
dartness_generator: ^0.4.6-alpha
```
2. Create the file in "bin/main.dart" or whatever file that runs your application.
### 2. Create the file in "bin/app.dart" or whatever file that you consider that you root application is.
```dart
void main() async {
final app = Dartness(
port: 3000,
);
await app.create();
}
@Application(
options: DartnessApplicationOptions(
port: int.fromEnvironment(
'port',
defaultValue: 8080,
),
),
)
class App {}
```

## Generate the code
### 3. Generate the code

Dartness uses the code generation feature provided by the package `code_builder`, this is the way that dart is able to
use reflection since `dart:mirrors` is unstable and not supported in order to compile your package.
Expand All @@ -57,7 +60,7 @@ $ dart run build_runner build
> * [dart:mirrors](https://api.dart.dev/stable/2.17.6/dart-mirrors/dart-mirrors-library.html)
> * [discontinuing support for dart:mirrors](https://github.com/dart-lang/sdk/issues/44489)
## Adding a controller
### 4. Adding a controller

In order to create a controller, you need to import it and add it to the `Dartness` app. You can do
it in two different ways, either adding it when you create the dartness app by the `controllers` param or after
Expand All @@ -77,15 +80,36 @@ This new created class accepts an instance of the class from where have been cre
must be used in the `controllers` param. You can see an example in the following code:

```dart
void main() async {
final controllers = [
CityDartnessController(CityController(CityService())),
];
final app = Dartness(
port: 3000,
controllers: controllers,
);
await app.create();
@Application(
module: Module(
metadata: ModuleMetadata(
controllers: [
ProviderMetadata(
classType: CityController,
),
],
),
),
options: DartnessApplicationOptions(
port: int.fromEnvironment(
'port',
defaultValue: 8080,
),
),
)
class App {}
```

### 5. Generate the code

```bash
$ dart run build_runner build
```

### 6. Modify "bin/main.dart"
```dart
void main(List<String> args) async {
await App().init();
}
```

Expand Down
27 changes: 13 additions & 14 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
<meta charset="UTF-8">
<title>Document</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
</head>
<body>
<div id="app"></div>
<script>
<div id="app"></div>
<script>
window.$docsify = {
name: 'Dartness',
repo: '',
loadSidebar: true,
name: '',
repo: ''
}
</script>
<!-- Docsify v4 -->
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
</script>
<!-- Docsify v4 -->
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
</body>
</html>
31 changes: 22 additions & 9 deletions docs/interceptor.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,30 @@ class MyInterceptor implements DartnessInterceptor {

## Applying interceptor

In order to apply your interceptor, you need to add it to the `interpcetors` list in the `DartnessServer` class. This
In order to apply your interceptor, you need to add it to the `interpcetors` list in the `Module` annotation. This
will create a global interceptors and are used across the whole application, for every controller and every route
handler.

```dart
void main() async {
final app = Dartness(
port: 3000,
interceptors: [MyInterceptor()],
);
// As optional, you can also use app.addInterceptor(MyInterceptor());
await app.create();
}
@Application(
module: Module(
metadata: ModuleMetadata(
controllers: [],
providers: [
ProviderMetadata(
classType: MyInterceptor,
),
],
exports: [],
imports: [],
),
),
options: DartnessApplicationOptions(
port: int.fromEnvironment(
'port',
defaultValue: 8080,
),
),
)
class App {}
```
Loading

0 comments on commit 1e85084

Please sign in to comment.