GithubHelp home page GithubHelp logo

isabella232 / kituracontracts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kitura/kituracontracts

0.0 0.0 0.0 1.81 MB

A library containing type definitions shared by client and server Kitura code.

License: Apache License 2.0

Ruby 0.38% Swift 99.62%

kituracontracts's Introduction

Kitura

APIDoc Build Status - Master macOS Linux Apache 2 Slack Status

KituraContracts

Summary

KituraContracts is a library containing type definitions shared by client (e.g. KituraKit) and server (e.g. Kitura) code. These shared type definitions include Codable Closure Aliases, RequestError, QueryEncoder, QueryDecoder, Coder, Identifier Protocol and Extensions to String and Int, which add conformity to the Identifier protocol.

Usage

KituraContracts represents the types and protocols that are common to both the Kitura server and KituraKit client side library. If you are using Kitura or KituraKit, your project does not need to depend on KituraContracts explicitly.

Add dependencies

Add the KituraContracts package to the dependencies within your application’s Package.swift file. Substitute "x.x.x" with the latest KituraContracts release.

.package(url: "https://github.com/Kitura/KituraContracts.git", from: "x.x.x")

Add KituraContracts to your target's dependencies:

.target(name: "example", dependencies: ["KituraContracts"]),

Import package

import KituraContracts

Example

This example, shows how to use a shared type definition for RequestError within a router POST method on users. If no errors occurred and you have a User you can respond with the user and pass nil as the RequestError? value. If there has been an error you can respond with an appropriate error and pass nil for the User?.

public struct User: Codable {
    ...
}

router.post("/users") { (user: User, respondWith: (User?, RequestError?) -> Void) in

    if databaseConnectionIsOk {
        ...
        respondWith(user, nil)
    } else {
        ...
        respondWith(nil, .internalServerError)
    }
}

Swift version

The 1.x.x releases were tested on macOS and Linux using the Swift 4.1 binaries. Please note that this is the default version of Swift that is included in Xcode 9.3.

API Documentation

For more information visit our API reference.

Community

We love to talk server-side Swift and Kitura. Join our Slack to meet the team!

License

This library is licensed under Apache 2.0. Full license text is available in LICENSE.

kituracontracts's People

Contributors

rolivieri avatar djones6 avatar dannys42 avatar tunniclm avatar andrew-lees11 avatar shihabmehboob avatar enriquel8 avatar ianpartridge avatar kyemaloy97 avatar mbarnach avatar helenmasters avatar mcritz avatar hactar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.