Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Package to Swift 4 #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 0 additions & 59 deletions LICENSE.zh_CN

This file was deleted.

37 changes: 26 additions & 11 deletions Perfect-ToDo-API/Package.swift
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
// swift-tools-version:4.0
import PackageDescription

let package = Package(
name: "ToDO-Backend",
products: [
.executable(
name: "ToDoAPI",
targets: ["ToDoAPI"]
)
],
dependencies: [
.package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", .upToNextMinor(from: "3.0.3")),
.package(url: "https://github.com/SwiftORM/MySQL-StORM.git", .upToNextMinor(from: "3.1.1")),
.package(url: "https://github.com/PerfectlySoft/Perfect-Turnstile-MySQL.git", .upToNextMinor(from: "3.0.0")),
.package(url: "https://github.com/rymcol/SwiftSQL.git", .upToNextMinor(from: "0.2.2")),
],
targets: [
Target(
name: "ToDo-API",
.target(
name: "ToDoAPI",
dependencies: [
.Target(name: "ToDoModel")
.target(name: "ToDoModel"),
"PerfectHTTPServer",
"MySQLStORM",
"PerfectTurnstileMySQL",
"SwiftSQL"
]
),
Target(
.target(
name: "ToDoModel",
dependencies: []
dependencies: [
"SwiftSQL",
"MySQLStORM",
"PerfectTurnstileMySQL"
]
)
],
dependencies: [
.Package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", majorVersion: 3),
.Package(url: "https://github.com/SwiftORM/MySQL-StORM.git", majorVersion: 3),
.Package(url: "https://github.com/PerfectlySoft/Perfect-Turnstile-MySQL.git", majorVersion: 3),
.Package(url: "https://github.com/rymcol/SwiftSQL.git", majorVersion: 0),
]
)
2 changes: 1 addition & 1 deletion Perfect-ToDo-iOS/Perfect-ToDo-iOS/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

import Foundation

let apiEndpoint = "http://0.0.0.0:8181/api"
let apiEndpoint = "http://127.0.0.1:8181/api"
3 changes: 2 additions & 1 deletion Perfect-ToDo-iOS/Perfect-ToDo-iOS/DataService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ class DataService {

URLSession.shared.dataTask(with: request) { (data, response, error) in

if error != nil {
if let err = error {
NotificationCenter.default.post(Notification(name: .apiServerUnreachable))
debugPrint(urlPath, err.localizedDescription)
}

do {
Expand Down
14 changes: 8 additions & 6 deletions Perfect-ToDo-iOS/Perfect-ToDo-iOS/RemoteUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,20 @@ class RemoteUser {

print("Logging in user: \(_username) with password: \(_password)")

let urlPath = "\(apiEndpoint)/v1/login/?username=\(_username)&password=\(_password)"
let urlPath = "\(apiEndpoint)/v1/login?" + ("username=\(_username)&password=\(_password)".addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) ?? "fault")
guard let endpoint = URL(string: urlPath) else {
print("Error creating endpoint")
return
}
var request = URLRequest(url: endpoint)
request.timeoutInterval = 3
request.timeoutInterval = 10
request.httpMethod = "POST"

URLSession.shared.dataTask(with: request) { (data, response, error) in

if error != nil {
if let err = error {
NotificationCenter.default.post(Notification(name: .apiServerUnreachable))
debugPrint(urlPath, err.localizedDescription)
}

do {
Expand Down Expand Up @@ -76,19 +77,20 @@ class RemoteUser {

print("Registering user: \(_username) with password: \(_password)")

let urlPath = "\(apiEndpoint)/v1/register/?username=\(_username)&password=\(_password)"
let urlPath = "\(apiEndpoint)/v1/register?" + ("username=\(_username)&password=\(_password)".addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) ?? "fault")
guard let endpoint = URL(string: urlPath) else {
print("Error creating endpoint")
return
}
var request = URLRequest(url: endpoint)
request.timeoutInterval = 3
request.timeoutInterval = 30
request.httpMethod = "POST"

URLSession.shared.dataTask(with: request) { (data, response, error) in

if error != nil {
if let err = error {
NotificationCenter.default.post(Notification(name: .apiServerUnreachable))
debugPrint(urlPath, err.localizedDescription)
}

do {
Expand Down
Loading