Skip to content

Commit aa90e14

Browse files
fix: remove useless entrypoint parameter from minimal application
1 parent 24fa8d9 commit aa90e14

7 files changed

Lines changed: 93 additions & 4 deletions

File tree

.website/.vitepress/config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ export default defineConfig({
253253
collapsed: true,
254254
items: [
255255
{ text: 'Testing', link: 'testing' },
256+
{ text: 'Minimal Application', link: 'minimal_application' },
256257
// { text: 'Liquify', link: 'liquify' },
257258
]
258259
},
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Minimal Application
2+
3+
Serinus is optimal for building scalable and maintainable applications. However, sometimes you just need to drop down to the bare minimum and get things working as quickly as possible. This guide will show you how to create a minimal Serinus application with just a few lines of code.
4+
5+
## Create a Minimal Application
6+
7+
To create a minimal Serinus application, you can use the following code:
8+
9+
```dart
10+
import 'package:serinus/serinus.dart';
11+
12+
Future<void> main() async {
13+
final application = await serinus.createMinimalApplication();
14+
await application.serve();
15+
}
16+
```
17+
18+
As you can see, we are using the `createMinimalApplication` method from the Serinus factory to create a new instance of the application. All the parameters are optional and will be set to default values if not provided.
19+
20+
## Add some routes
21+
22+
You can easily add routes to your minimal application using some application methods. Here's an example of how to add a simple route that returns a "Hello, World!" message:
23+
24+
```dart
25+
import 'package:serinus/serinus.dart';
26+
27+
Future<void> main() async {
28+
final application = await serinus.createMinimalApplication();
29+
30+
application.get('/hello', (RequestContext context) async {
31+
return 'Hello, World!';
32+
});
33+
34+
await application.serve();
35+
}
36+
```
37+
38+
In this example, we are adding a GET route at the path `/hello` that returns a simple string message. You can add as many routes as you need using the various HTTP methods provided by Serinus.
39+
40+
## Add Middleware
41+
42+
You can also add middleware to your minimal application to handle tasks such as logging, authentication, or request parsing. Here's an example of how to add a simple logging middleware:
43+
44+
```dart
45+
import 'package:serinus/serinus.dart';
46+
47+
Future<void> main() async {
48+
final application = await serinus.createMinimalApplication();
49+
50+
application.useMiddleware(LogMiddleware());
51+
52+
application.get('/hello', (RequestContext context) async {
53+
return 'Hello, World!';
54+
});
55+
56+
await application.serve();
57+
}
58+
```
59+
60+
The minimal application is a great way to quickly get started with Serinus and build simple applications without the need for complex configurations or setups. You can always add more features and functionality as your application grows.
61+
62+
## All minimal application methods
63+
64+
| Methods | Description |
65+
| --- | --- |
66+
| `get` | Creates a new GET route for the given path and handler. |
67+
| `post` | Creates a new POST route for the given path and handler. |
68+
| `put` | Creates a new PUT route for the given path and handler. |
69+
| `delete` | Creates a new DELETE route for the given path and handler. |
70+
| `patch` | Creates a new PATCH route for the given path and handler. |
71+
| `options` | Creates a new OPTIONS route for the given path and handler. |
72+
| `head` | Creates a new HEAD route for the given path and handler. |
73+
| `all` | Creates a new route for all HTTP methods for the given path and handler. |
74+
| `useMiddleware` | Adds a middleware to the application. |
75+
| `provide` | Provides a dependency to the application. |
76+
| `import` | Imports a module into the application. |
77+
| `serve` | Starts serving the application on the configured host and port. |
78+
79+
All of these methods are available on the minimal application instance and can be used to build your application as needed. Also as you can see you can start by using the `provide` and `import` methods to set up your application's dependencies and modules, and when you app grows you can easily move these imports in your entrypoint module and use the `createApplication` method to create a more structured application.

packages/serinus/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 2.1.3
4+
5+
**Released on:** 25-02-2026
6+
7+
### Fixes
8+
9+
- Remove useless `entrypoint` parameter from the `createMinimalApplication` method in the `SerinusFactory` class. This parameter is not needed for the creation of a minimal application and its presence can cause confusion for developers. Removing it simplifies the API and improves the developer experience when creating minimal applications with Serinus.
10+
311
## 2.1.2
412

513
**Released on:** 22-02-2026

packages/serinus/bin/serinus.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ class MyModelProvider extends ModelProvider {
124124

125125
void main(List<String> arguments) async {
126126
final application = await serinus.createMinimalApplication(
127-
entrypoint: AppModule(),
128127
host: InternetAddress.anyIPv4.address,
129128
port: 3002,
130129
logger: ConsoleLogger(prefix: 'Serinus New Logger'),

packages/serinus/lib/src/core/factory.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ final class SerinusFactory {
8181

8282
/// The [createMinimalApplication] method is used to create a new instance of the [SerinusMinimalApplication] class.
8383
Future<SerinusMinimalApplication> createMinimalApplication({
84-
required Module entrypoint,
8584
String host = 'localhost',
8685
int port = 3000,
8786
Set<LogLevel>? logLevels,

packages/serinus/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Serinus is a framework written in Dart
44
documentation: https://serinus.app
55
homepage: https://serinus.app
66
repository: https://github.com/francescovallone/serinus
7-
version: 2.1.2
7+
version: 2.1.3
88
funding:
99
- https://github.com/sponsors/francescovallone
1010
topics:

packages/serinus/test/router/router_test.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ void main() async {
125125
final result = router.lookup('/posts/123/comments', HttpMethod.get);
126126
expect(result, isA<FoundRoute>());
127127
final found = result as FoundRoute<RouterEntry>;
128-
expect(found.values.first.context.path, equals('/posts/:postId/comments'));
128+
expect(
129+
found.values.first.context.path,
130+
equals('/posts/:postId/comments'),
131+
);
129132
expect(found.params['postId'], equals('123'));
130133
},
131134
);

0 commit comments

Comments
 (0)