@@ -46,37 +46,22 @@ Future<HttpServer> createServer(InternetAddress addr, int port) async {
4646 Company ('4' )..name = 'Toyota' ,
4747 ].forEach (companies.insert);
4848
49- final controller = CarsController ({
50- 'companies' : companies,
51- 'cities ': cities ,
52- 'models ': models ,
53- 'jobs ': JobDAO ()
54- });
55-
56- final urlDesign = StandardURLDesign ( Uri . parse ( 'http://localhost:$ port ' ));
57-
58- final jsonApiServer =
59- JsonApiServer (urlDesign, controller, StandardDocumentBuilder (urlDesign ));
49+ final controller = CarsController (
50+ {
51+ 'companies ': companies ,
52+ 'cities ': cities ,
53+ 'models ': models,
54+ 'jobs' : JobDAO ()
55+ },
56+ (query) => NumberedPage (
57+ int . parse (
58+ PageParameters . fromQuery (query).parameters[ 'number' ] ?? '1' ),
59+ 1 ));
6060
6161 final httpServer = await HttpServer .bind (addr, port);
62+ final jsonApiServer =
63+ Server (Routing (Uri .parse ('http://localhost:$port ' )), controller);
6264
6365 httpServer.forEach (jsonApiServer.process);
64-
6566 return httpServer;
6667}
67-
68- class Url {
69- static final _design = StandardURLDesign (Uri .parse ('http://localhost:8080' ));
70-
71- static Uri collection (String type) =>
72- _design.collection (CollectionTarget (type));
73-
74- static Uri resource (String type, String id) =>
75- _design.resource (ResourceTarget (type, id));
76-
77- static Uri related (String type, String id, String relationship) =>
78- _design.related (RelatedTarget (type, id, relationship));
79-
80- static Uri relationship (String type, String id, String relationship) =>
81- _design.relationship (RelationshipTarget (type, id, relationship));
82- }
0 commit comments