Releases: twof/VaporCRUDRouter
Releases · twof/VaporCRUDRouter
Vapor 4 Support
What's Changed
- fixed an issue on children crud generation by @FedeGens in #7
- Update to Vapor-beta.3 / Fluent-beta.2 by @simonedelmann in #9
- Vapor 4 Support by @twof in #10
New Contributors
- @FedeGens made their first contribution in #7
- @simonedelmann made their first contribution in #9
Full Changelog: 1.7.0...4.0.0
This change should be largely non-breaking. The only breaking change is that the library now requires Vapor 4. All public APIs are unchanged.
All `.crud` methods no longer throw
All public APIs were (unnecessarily) throwing, which meant they all looked like
try router.crud(register: Todo.self)
All public API calls can now be slightly simplified to
router.crud(register: Todo.self)
Relations can now recurse infinitely
Nest your routes to your heart's content 😄
try router.crud(register: User.self, .only([.read])) { controller in
try controller.crud(children: \.todos, .only([.read])) { childrenController in
try childrenController.crud(siblings: \.tags, .only([.read])) { siblingsController in
try siblingsController.crud(siblings: \.todos, .only([.read]))
}
}
}
produces
GET/user/:id
GET/user/:id/todo/:id
GET/user/:id/todo/:id/tag/:id
GET/user/:id/todo/:id/tag/:id/todo/:id
Introduce method exclusion/inclusion
Including or Excluding Specific Routes
If you'd like to register a Model
, but you don't want every route to be available, you can specify the ones you want, or exclude the ones you don't.
try router.crud(register: Todo.self, .except([.create, .delete])) { controller in
try controller.crud(parent: \.owner, .only([.read]))
}
results in
PUT /todo/int
GET /todo/int
GET /todo
GET /todo/int/tag/int
API renaming
Shortened all public APIs from crudRegister()
to
try router.crud(register: User.self) { controller in
try controller.crud(children: \.todos)
}
Enable nested exposure of Siblings
Siblings can now be exposed alongside Children and Parents
try router.crudRegister(for: Todo.self) { controller in
try controller.crudRegister(forSiblings: \.tags)
}
try router.crudRegister(for: Tag.self) { controller in
try controller.crudRegister(forSiblings: \.todos)
}
exposes
GET /todo/:id
GET /todo
POST /todo
PUT /todo/:id
DELETE /todo/:id
GET /todo/:id/tag/:id
GET /todo/:id/tag
POST /todo/:id/tag
PUT /todo/:id/tag/:id
DELETE /todo/:id/tag/:id
GET /tag/:id
GET /tag
POST/tag
PUT /tag/:id
DELETE /tag/:id
GET /tag/:id/todo/:id
GET /tag/:id/todo
POST /tag/:id/todo
PUT /tag/:id/todo/:id
DELETE /tag/:id/todo/:id
Enable nested exposure of Children and Parents
Siblings to come. Just working out some kinks
try router.crudRegister(for: Todo.self) { controller in
try controller.crudRegister(at: "owner", forParent: \.owner)
}
try router.crudRegister(for: User.self) { controller in
try controller.crudRegister(forChildren: \.todos)
}
try router.crudRegister(for: Tag.self)
Default route paths to model names
1.1.0 Default to using model name for routes