Swiftpack.co - Package - khanlou/Meridian

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.

khanlou/Meridian

Meridian is a web server written in Swift that lets you write your endpoints in a declarative way.

Meridian

Meridian is a web server written in Swift that lets you write your endpoints in a declarative way.

Here is an example endpoint:


struct SampleEndpoint: Route {
  
    @QueryParameter("sort_direction") var sortDirection: SortDirection
  
    @URLParameter(\.id) var userID
    
    @EnivronmentObject var database: Database
    
    func body() throws {
        JSON(database.fetchFollowers(of: userID, sortDirection: sortDirection))
    }
  
}

Server(errorRenderer: BasicErrorRenderer())
    .register {

        SampleEndpoint()
            .on("/api/users/\(\.id))/followers")

    }
    .environmentObject(Database())
    .listen()

Github

link
Stars: 36
Last commit: 2 weeks ago

Releases

- 2020-09-06T22:17:58

  • Route groups, with error renderer overrides
  • Method Property Wrapper
  • Header Property Wrapper
  • Path Property Wrapper
  • Support for custom property wrappers
  • URLParameter is more type aware
  • EnvironmentKey is more type aware
  • Supports OPTIONS method and CORS