@@ -28,7 +28,7 @@ Add Arcade to your `pubspec.yaml`:
2828
2929``` yaml
3030dependencies :
31- arcade : ^0.3.1
31+ arcade : ^<latest-version>
3232` ` `
3333
3434Then install the dependencies:
@@ -50,7 +50,7 @@ Future<void> main() async {
5050 init: () {
5151 // Define your routes here
5252 route.get('/').handle((context) => 'Hello, Arcade!');
53-
53+
5454 route.get('/api/health').handle((context) {
5555 return {'status': 'ok', 'timestamp': DateTime.now().toIso8601String()};
5656 });
@@ -66,6 +66,7 @@ dart run bin/server.dart
6666```
6767
6868You should see:
69+
6970```
7071Server running on port 3000
7172```
@@ -97,6 +98,7 @@ route.<method>(path).<hooks>?.handle(handler);
9798```
9899
99100For example:
101+
100102``` dart
101103// Simple GET route
102104route.get('/users').handle((context) => 'List of users');
@@ -126,7 +128,7 @@ Every handler receives a `RequestContext` object that provides access to:
126128route.get('/users/:id').handle((context) {
127129 final userId = context.pathParameters['id'];
128130 final filter = context.queryParameters['filter'];
129-
131+
130132 return {
131133 'userId': userId,
132134 'filter': filter,
@@ -142,12 +144,12 @@ route.get('/users/:id').handle((context) {
142144``` dart
143145route.post('/api/users').handle((context) async {
144146 final result = await context.jsonMap();
145-
147+
146148 if (result case BodyParseSuccess(:final value)) {
147149 // Process the JSON data
148150 final name = value['name'];
149151 final email = value['email'];
150-
152+
151153 return {'id': 123, 'name': name, 'email': email};
152154 } else {
153155 context.statusCode = 400;
@@ -161,11 +163,11 @@ route.post('/api/users').handle((context) async {
161163``` dart
162164route.get('/api/protected').handle((context) {
163165 final token = context.requestHeaders.value('authorization');
164-
166+
165167 if (token == null) {
166168 throw UnauthorizedException();
167169 }
168-
170+
169171 return {'secret': 'data'};
170172});
171173
@@ -175,7 +177,7 @@ overrideErrorHandler((context, error, stackTrace) {
175177 context.statusCode = 401;
176178 return {'error': 'Unauthorized'};
177179 }
178-
180+
179181 context.statusCode = 500;
180182 return {'error': 'Internal server error'};
181183});
@@ -225,7 +227,7 @@ import 'dart:io';
225227Future<void> main() async {
226228 final port = int.parse(Platform.environment['PORT'] ?? '3000');
227229 final dbUrl = Platform.environment['DATABASE_URL'] ?? 'localhost';
228-
230+
229231 await runServer(
230232 port: port,
231233 init: () {
@@ -254,4 +256,4 @@ If you run into issues:
2542562 . Look at the [ example applications] ( https://github.com/dartarcade/arcade/tree/main/samples )
2552573 . Open an issue on [ GitHub] ( https://github.com/dartarcade/arcade/issues )
256258
257- Happy coding with Arcade!
259+ Happy coding with Arcade!
0 commit comments