Skip to content

Instantly share code, notes, and snippets.

View siavashalipour's full-sized avatar

Siavash siavashalipour

View GitHub Profile
@siavashalipour
siavashalipour / ViewController.swift
Created November 18, 2016 23:08
End-to-end Swift Solution with IBM Bluemix Part five - 1
//
// ViewController.swift
// KituraClient
//
// Created by Siavash Abbasalipour on 26/9/16.
// Copyright © 2016 MobileDen. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@siavashalipour
siavashalipour / package.swift
Created November 18, 2016 23:13
End-to-end Swift Solution with IBM Bluemix Part four - 1
import PackageDescription
let package = Package(
name: “Microservice1”,
targets: [
Target(name: “Microservice1”, dependencies: [])
],
dependencies: [
.Package(url: “https://github.com/IBM-Swift/Kitura.git", majorVersion: 1, minor: 0),
.Package(url: “https://github.com/IBM-Swift/HeliumLogger.git", majorVersion: 1, minor: 0),
.Package(url: “https://github.com/IBM-Swift/Swift-cfenv.git", majorVersion: 1, minor: 7),
@siavashalipour
siavashalipour / ProfileDatabase.swift
Created November 18, 2016 23:14
End-to-end Swift Solution with IBM Bluemix Part four - 2
//
// ProfileDatabase.swift
// Microservice1
//
// Created by Siavash Abbasalipour on 28/9/16.
//
//
import Foundation
import PostgreSQL
enum DBError: Error {
@siavashalipour
siavashalipour / Controller.swift
Created November 18, 2016 23:15
End-to-end Swift Solution with IBM Bluemix Part four - 3
public func postToDB(request: RouterRequest, response: RouterResponse, next: @escaping () -> Void) throws {
 Log.debug(“POST — /addtodb route handler…”)
 response.headers[“Content-Type”] = “application/json; charset=utf-8”
 var jsonResponse = JSON([:])
 if let body = request.body {
 switch body {
 case .json(let json):
 let fname = json[“fname”].stringValue
 let lname = json[“lname”].stringValue
 do {
@siavashalipour
siavashalipour / package.swift
Created November 18, 2016 23:17
End-to-end Swift Solution with IBM Bluemix Part three - 1
import PackageDescription
let package = Package(
 name: “Microservice2”,
 targets: [
 Target(name: “Microservice2”, dependencies: [])
 ],
 dependencies: [
 .Package(url: “https://github.com/IBM-Swift/Kitura.git", majorVersion: 1, minor: 0),
 .Package(url: “https://github.com/IBM-Swift/HeliumLogger.git", majorVersion: 1, minor: 0),
  .Package(url: “https://github.com/IBM-Swift/Swift-cfenv.git", majorVersion: 1, minor: 7),
@siavashalipour
siavashalipour / Controller.swift
Last active November 18, 2016 23:20
End-to-end Swift Solution with IBM Bluemix Part three - 2
//
// Controller.swift
// Microservice2
//
// Created by Siavash on 26/9/16.
//
//
import Foundation
import Kitura
import SwiftyJSON
@siavashalipour
siavashalipour / makefile
Created November 18, 2016 23:36
End-to-end Swift Solution with IBM Bluemix Part two - 1
# Copyright IBM Corporation 2016
#
# Licensed under the Apache License, Version 2.0 (the “License”);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an “AS IS” BASIS,
@siavashalipour
siavashalipour / package.swift
Created November 18, 2016 23:39
End-to-end Swift Solution with IBM Bluemix Part one - 1
import PackageDescription
let package = Package(
name: “Microservice1”,
targets: [
Target(name: “Microservice1”, dependencies: [])
],
dependencies: [
.Package(url: “https://github.com/IBM-Swift/Kitura.git", majorVersion: 1, minor: 0),
.Package(url: “https://github.com/IBM-Swift/HeliumLogger.git", majorVersion: 1, minor: 0),
.Package(url: “https://github.com/IBM-Swift/Swift-cfenv.git", majorVersion: 1, minor: 7),
@siavashalipour
siavashalipour / Controller.swift
Created November 18, 2016 23:40
End-to-end Swift Solution with IBM Bluemix Part one - 2
//
// Controller.swift
// Microservice1
//
// Created by Siavash on 26/9/16.
//
//
import Foundation
import Kitura
import SwiftyJSON
@siavashalipour
siavashalipour / main.swift
Created November 18, 2016 23:41
End-to-end Swift Solution with IBM Bluemix Part one - 3
import Foundation
import Kitura
import LoggerAPI
import HeliumLogger
import CloudFoundryEnv
import CloudFoundryDeploymentTracker
do {
 // HeliumLogger disables all buffering on stdout
 HeliumLogger.use(LoggerMessageType.info)
 let controller = try Controller()