Skip to content

Releases: twof/VaporCRUDRouter

Vapor 4 Support

27 Nov 01:00
e9e12d9
Compare
Choose a tag to compare

What's Changed

New Contributors

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

27 Oct 08:01
70cfa3b
Compare
Choose a tag to compare

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

27 Oct 05:44
eb50c01
Compare
Choose a tag to compare

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

26 Oct 20:29
5e243fe
Compare
Choose a tag to compare

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

04 Oct 02:16
Compare
Choose a tag to compare

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

02 Oct 05:40
Compare
Choose a tag to compare

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

01 Oct 21:58
Compare
Choose a tag to compare

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

30 Sep 01:39
Compare
Choose a tag to compare
1.1.0

Default to using model name for routes

1.0.0

29 Sep 01:09
Compare
Choose a tag to compare
initial commit