vapor

Vapor doesn't work with xcode 9 and swift 4

别等时光非礼了梦想. 提交于 2019-12-09 14:09:09
问题 When I try to compiled my newly created vapor project with Xcode 9 I get 189 compile errors. What's the trick to making this work? I installed vapor and the toolbox, and create via 'vapor new test --template=api' and then 'vapor xcode' to start it up. 回答1: Check that everything is up to date. The following builds and runs for me at this time: Use latest vapor toolbox. Currently: vapor new test --template=api cd test swift package tools-version # 4.0.0 # use `swift package tools-version --set

Deploying Vapor with heroku

会有一股神秘感。 提交于 2019-12-08 16:26:26
I have created a very simple app with one route in main.swift . It reads a city from a query string and use it to get the weather (through the yahoo API) of that city. this is the route: drop.get("whether") { request in guard let city = request.data["city"]?.string else { return try JSON(node: ["Error": "no city given"]) } return try drop.client.get("https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22\(city)%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys") } The

How to assign elements of a dictionary to JSON object in Vapor 3?

时光毁灭记忆、已成空白 提交于 2019-12-07 21:37:10
问题 In Vapor 1.5 I used to assign the elements of an existing dictionary to a JSON object as shown below. How can I do this Vapor 3? func makeCustomJSON(jsonFromReading: JSON, clientData: DataFromClient) throws -> JSON{ var dictionaryOfStrings = [String:String]() dictionaryOfStrings["ChangesMadeBy"] = "Cleaner" dictionaryOfStrings["BookingNumber"] = clientData.bookingNumber dictionaryOfStrings["Claimed"] = "false" //some 50 properties more... //object read from /Users var finalJsonObj =

How do I log SQL statements in Vapor 3/Fluent?

我是研究僧i 提交于 2019-12-07 07:55:16
问题 It looks like in Vapor 2 you could do something like: let query = <some fluent query object> logger?.debug(query) and it would print out the full SQL statement, but I'm not seeing any documentation of how to do that now in Vapor 3. How can I see what SQL is being generated by my QueryBuilder ? 回答1: Thanks to Nick in the comments, who pointed me to the right set of docs. This can be accomplished by using the enableLogging method. So now my configure.swift includes this code: let dbConfig:

Bystack跨链技术源码解读

对着背影说爱祢 提交于 2019-12-06 20:52:54
Bystack是由比原链团队提出的一主多侧链架构的BaaS平台。其将区块链应用分为三层架构:底层账本层,侧链扩展层,业务适配层。底层账本层为Layer1,即为目前比较成熟的采用POW共识的Bytom公链。侧链扩展层为Layer2,为多侧链层,vapor侧链即处于Layer2。 (图片来自Bystack白皮书) Vapor侧链采用DPOS和BBFT共识,TPS可以达到数万。此处就分析一下连接Bytom主链和Vapor侧链的跨链模型。 主侧链协同工作模型 1、技术细节 POW当前因为能源浪费而饱受诟病,而且POW本身在提高TPS的过程中遇到诸多问题,理论上可以把块变大,可以往块里面塞更多的交易。TPS是每秒出块数*块里面的交易数。但是也存在问题:小节点吃不消存储这么大的容量的内容,会慢慢变成中心化的模式,因为只有大财团和大机构才有财力去组建机房设备,成为能出块的节点。同时传输也存在问题,网络带宽是有限的,块的大小与网络传输的边际是有关的,不可能无限的去增加块的大小,网络边际上的人拿不到新块的信息,也会降低去中心化的程度,这就是为什么POW不能在提高可靠性的情况下,提高TPS的原因。 而BFT虽然去中心化较弱,但其效率和吞吐量高,也不需要大量的共识计算,非常环保节能,很符合Bystack侧链高TPS的性能需求 (1)跨链模型架构 在Bystack的主侧链协同工作模型中,包括有主链

How to assign elements of a dictionary to JSON object in Vapor 3?

戏子无情 提交于 2019-12-06 09:13:27
In Vapor 1.5 I used to assign the elements of an existing dictionary to a JSON object as shown below. How can I do this Vapor 3? func makeCustomJSON(jsonFromReading: JSON, clientData: DataFromClient) throws -> JSON{ var dictionaryOfStrings = [String:String]() dictionaryOfStrings["ChangesMadeBy"] = "Cleaner" dictionaryOfStrings["BookingNumber"] = clientData.bookingNumber dictionaryOfStrings["Claimed"] = "false" //some 50 properties more... //object read from /Users var finalJsonObj = jsonFromReading //assign the values of dictionaryOfStrings to finalJsonObj for i in dictionaryOfStrings { let

Validate JWT token with RS256 or RS512 with Swift iOS

空扰寡人 提交于 2019-12-06 07:13:49
问题 I am building an iOS application in Swift that needs to be able to validate a JWT token signature with a public key certificate using either RS256 or RS512. I've been trying to find libraries that support such functionalities but have had issues implementing the ones I have found. My question is therefore what the recommended way to implement such functionality for a Swift iOS app is? The ideal scenario is to be able to use one of the recognized frameworks on JWT.io. The only Swift library on

Using vapor-fluent to upsert models

左心房为你撑大大i 提交于 2019-12-06 06:27:40
问题 I am currently struggling with doing an upsert with vapor/fluent. I have a model something like this: struct DeviceToken: PostgreSQLModel { var id: Int? var token: String var updatedAt: Date = Date() init(id: Int? = nil, token: String, updatedAt: Date = Date()) { self.id = id self.token = token self.updatedAt = updatedAt } } struct Account: PostgreSQLModel { var id: Int? let username: String let service: String ... let deviceTokenId: DeviceToken.ID init(id: Int? = nil, service: String,

Vapor Installation Issues (First time using Vapor) using Swift 5

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 03:39:04
After installing vapor i am getting below error dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Referenced from: /usr/local/bin/vapor Reason: image not found Abort trap: 6 Here lies my issue, I have no idea how to solve that.even I am not able to create new project. Please help. I never faced with that issue but saw this tricky solution in some chat ln -s /usr/local/opt/openssl/lib/libssl.1.1.dylib /usr/local/opt/openssl/lib/libssl.1.0.0.dylib ln -s /usr/local/opt/openssl/lib/libcrypto.1.1.dylib /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib Have you tried ? brew

How do I log SQL statements in Vapor 3/Fluent?

纵然是瞬间 提交于 2019-12-05 15:33:34
It looks like in Vapor 2 you could do something like: let query = <some fluent query object> logger?.debug(query) and it would print out the full SQL statement, but I'm not seeing any documentation of how to do that now in Vapor 3. How can I see what SQL is being generated by my QueryBuilder ? Thanks to Nick in the comments, who pointed me to the right set of docs. This can be accomplished by using the enableLogging method. So now my configure.swift includes this code: let dbConfig: PostgreSQLDatabaseConfig if let url = Environment.get("DATABASE_URL"), let psqlConfig = PostgreSQLDatabaseConfig