Skip to content

Releases: twof/VaporCRUDRouter

Vapor 4 Support

Choose a tag to compare

@twof twof released this 27 Nov 01:00
e9e12d9

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

Choose a tag to compare

@twof twof released this 27 Oct 08:01
70cfa3b

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

Choose a tag to compare

@twof twof released this 27 Oct 05:44
eb50c01

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

Choose a tag to compare

@twof twof released this 26 Oct 20:29
5e243fe

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

Choose a tag to compare

@twof twof released this 04 Oct 02:16

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

Choose a tag to compare

@twof twof released this 02 Oct 05:40

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

Choose a tag to compare

@twof twof released this 01 Oct 21:58

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

Choose a tag to compare

@twof twof released this 30 Sep 01:39
1.1.0

Default to using model name for routes

1.0.0

Choose a tag to compare

@twof twof released this 29 Sep 01:09
initial commit