Questions tagged [vapor]
A web framework and server for Swift that works on macOS and Linux.
56
questions
412
votes
39answers
225k views
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
I installed vapor via homebrew and then immediately wanted to jump into a project by executing vapor new Hello but then got the following message back in the terminal:
dyld: Library not loaded: /usr/...
15
votes
3answers
14k views
Can't access FireBase Database via HTTP/REST error 403 Forbidden
Swift + Vapor framework for server + Xcode 8.1
I am trying to read Firebase Realtime Database making HTTP requests to my DB, but I get permission denied.
These are the steps:
1. create JWT sign it ...
3
votes
0answers
699 views
How to use multi-path update with the REST API in Firebase? Error 400
I would like to update multiple nodes in a single operation using the firebase REST API and Vapor framework.
When I make .patch request to Firebase I get error from Vapor client:
The operation ...
2
votes
1answer
125 views
Parameters after opening bracket
I am doing my first steps in Vapor, the web framework for Swift.
The first piece of code that called my attention was this:
app.get("welcome") { request in
return "Hello"
}
I don't understand ...
5
votes
2answers
839 views
Vapor server and companion iOS app examples
One of the reasons advocates of swift server side give for the use of swift is that it allows iOS developers to develop backends for their apps. But, I do not see many example of this usage pattern.
...
6
votes
2answers
2k views
How to use timer in Vapor (server-side Swift)?
Can I use timer, such as NSTimer in Vapor (server-side Swift)?
I hope my server written in Vapor can do some tasks proactively once in a while. For example, polling some data from the web every 15 ...
35
votes
1answer
7k views
Swift: What does backslash dot “\.” mean?
I'm new to backend Swift and thought I'd use Vapor to get up-and-running on a side project fast...
I ran vapor new WebServer --template=auth-template, and now I'm trying to figure out what something ...
12
votes
2answers
2k views
vapor toolbox broken after upgrading swift
Vapor toolbox is crashing when trying to use it after upgrading to Swift 3.1.
dyld: lazy symbol binding failed: Symbol not found: ...
10
votes
3answers
2k views
Image Upload in Vapor 3 using PostgreSQL
I'm following this guys Martin Lasek Tutorials and now i'm at "image upload".
It seems that no one has the answer to the question "How do you upload images i Vapor 3"
Db connection is ok, all the ...
5
votes
2answers
342 views
Is is possible to use Vapor 3 Postgres Fluent in a standalone script?
I am experimenting with a standalone script that will query a Postgres database using Vapor and Fluent. In a normal Vapor API application this is simply done by:
router.get("products") { request in
...
4
votes
1answer
3k views
How to send a POST request to Firebase Cloud Messaging API in Vapor
I am trying to make a POST request to a Firebase Notifications API using Vapor 1.5 and Firebase Legacy Protocol, but I get failure response.
response is JSON(node: Node.Node.object(["multicast_id":...
3
votes
4answers
797 views
Random Alphanumeric String Linux Swift 3
Im having 2 problems when trying to generate a random string in Linux with Swift 3.
arc4random_uniform is not available in Linux only on BSD. SO i was able to get away with using random() function. ...
1
vote
1answer
211 views
How do I read this Swift syntax? [duplicate]
I am using Vapor and one of the first thing is to use get method which looks like following:
drop.get("hello") { request in
return "Hello, world!"
}
Now my understanding was that the closures ...
8
votes
1answer
3k views
Vapor 3 Beta Example Endpoint Request
I am trying to find a simple example of how inside a router a person would send a request to the vapor sample endpoint http://example.vapor.codes/json, receive a response and map it to a struct or ...
4
votes
1answer
1k views
How to handle multipart request with Vapor 3
I'm a vapor beginner and I chose to start with Vapor 3-rc because it seems to break change from Vaport 2. Unfortunately, there isn't a complete documentation for now.
I'm currently trying to upload a ...
7
votes
2answers
3k views
How do I generate an auth token using JWT for Google firebase?
So I'm trying to authenticate the Firebase REST API.
I'm using the Vapor framework for server side swift and I installed the JWT package.
I'm trying to use the data in the serviceAccountKey.json file ...
7
votes
2answers
835 views
Compiling Vapor as Standalone App on MacOS
I would like to compile Vapor with my code as a MacOS app so I can place it on internal server (drag and click to launch it). I would prefer not to have to install Xcode, swift and other development ...
6
votes
1answer
381 views
Vapor upload multiple files at once
I want to upload multiple images in one POST request. Currently, the part of my request related to the file upload is taking one file and looks like this:
return try req.content.decode(File.self)....
4
votes
1answer
559 views
Using vapor-fluent to upsert models
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: ...
4
votes
1answer
2k views
Validate JWT token with RS256 or RS512 with Swift iOS
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 ...
2
votes
1answer
1k views
Doing joins with Fluent in a Vapor application
I'm struggling to figure out how to join my two tables together using fluent. In essence I want to run this SQL command:
SELECT p.name, o.amount, o.amount * p.amount total
FROM "OrderPoints" o
...
2
votes
2answers
2k views
Vapor doesn't work with xcode 9 and swift 4
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 --...
9
votes
1answer
3k views
Uploading files using Vapor
I've seen in documentation in Body section that there's a support for file uploading right now - or at least I understand it this way 😅
I have no strong foundation in backend development - ...
8
votes
2answers
3k views
Vapor 3 - send a HTTPRequest
How do you send an API request in Vapor 3 with the HTTPRequest struct?
I tried variations of the following code..
var headers: HTTPHeaders = .init()
let body = HTTPBody(string: a)
let ...
4
votes
2answers
1k views
How to respond with an image using Vapor?
I just want to have a controller action that is basically doing the same as accessing an image directly through the Public/ folder. The difference is that the route can be whatever you want and the ...
4
votes
1answer
804 views
How do I log SQL statements in Vapor 3/Fluent?
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 ...
3
votes
2answers
2k views
How do I download a file and send a file using Vapor server side swift?
How do I download a file using server side swift?
I have tried this:
let result = try drop.client.get("http://dropcanvas.com/ir4ok/1")
but result.body always = 0 elements
How do I send a file?
I ...
2
votes
1answer
320 views
How to assign elements of a dictionary to JSON object in Vapor 3?
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)...
2
votes
1answer
101 views
Receiving Websocket data in Swift
I'm carrying this on from this question, since the focus has changed.
I am trying to send string data from a vapor server over a websocket. The client side is where the main question is. This code ...
1
vote
2answers
1k views
Deploying Vapor with heroku
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("...
5
votes
2answers
1k views
Swift Vapor Leaf deliver html in a variable
I need to create a complex html-table inside a Swift Vapor App.
Problem is: Leaf doesn't seem to support counting up variables like #(somevar += 1) nor concatenating string variables like #(somevar1 +...
4
votes
2answers
475 views
Vapor 2 Validation Valid-Type throws “Use of undeclared type Valid”
I try to use the Vapor 2 Valid Type, but the compiler only say: "Use of undeclared type Valid".
I had read: https://docs.vapor.codes/2.0/validation/package/ + https://docs.vapor.codes/2.0/validation/...
3
votes
1answer
907 views
Gitlab - Google compute engine Continuous delivery
What I am trying to do is to enable Continuous delivery from GitLab to my compute engine on Google Cloude. I have Ubuntu 16.04 TSL running over there. I did install all components needed to run my ...
3
votes
2answers
402 views
Siblings relationship between same models in Vapor
I have a User model which I want to add a friends property to. Friends, are supposed to be other Users.
I created the UserFriendsPivot:
final class UserFriendsPivot: MySQLPivot, ModifiablePivot {
...
3
votes
2answers
811 views
Is it possible to access fields in a joined table in Vapor?
I have a Persons table and an Events table that are related via an Attends table, such that a record exists the Attends table when I wish to record the fact that a person is due to attend a particular ...
3
votes
2answers
419 views
Vapor 3 PostgreSQL CRUD without requests http
I am creating backend based on Vapor 3.1.10 using Xcode 11.2 and Swift 5.1, database is PostgreSQL 12. I have a question: how to interact with database (CRUD) without POST and GET requests. All ...
3
votes
0answers
358 views
How to upload images from the browser to Amazon S3 using Vapor and Leaf?
I have set up AWS S3 bucket and I'm able to upload files there using Vapor 3 and Postman (PUT -request and with headers: ["x-amz-acl" : "public-read"]) but I would like to do that from the browser (I'...
3
votes
1answer
151 views
Two almost identical targets in Vapor Xcode project
I want to configure Package.swift so that one target would be an extension to another, both of them should share the same code from the one folder, but for the "extended" version there is an ...
3
votes
2answers
703 views
Vapor 3 - How to check for similar email before saving object
I would like to create a route to let users update their data (e.g. changing their email or their username). To make sure a user cannot use the same username as another user, I would like to check if ...
2
votes
1answer
1k views
Vapor MySQL - not showing as an Import value
This question is about the Swift Web Framework, Vapor.
I am trying to import VaporMySQL framework using Swift's Package Manager.
I already have the database running locally, the mySQL port is open ...
2
votes
1answer
170 views
How to prevent SQL Injections with User-Search-Terms in Vapor 4 (Fluent 4)
I am currently implementing a Vapor 4 application, which will be used to manage machines.
The user should be able to search for a machine name, which I accomplished by
.filter(Machine.path(for: \...
2
votes
1answer
624 views
How to pass data from using POST/form leaf template?
I have a couple of major gaps in my understanding of vapor/leaf/html. I am working from the "todo" example that is created using the beta branch of vapor.
First, I made my own fluent model (no ...
1
vote
1answer
117 views
Create record only if parent exists in Vapor using Fluent
I have 3 tables, LastName, MiddleName and FirstName, I would like to create a new record or update record in FirstName, MiddleName only if lastName exists. if last name does not exist, then would like ...
1
vote
1answer
200 views
vapor - Obtaining data from mysql using alsodecode()
I'm trying to obtain data from a mysql database joining two of my tables (usuarios and colegios) with the function alsodecode().
My code looks like this:
func usuariosHandler(_ req: Request) ...
1
vote
2answers
93 views
How Do I Send a Dictionary to a Client using Vapor Websockets
I've continued this question here, because the focus has changed, but is related.
Vapor is communicating between a server and and iOS client. Just setup code, for learning purposes.
Now, I want to ...
1
vote
2answers
129 views
Not able to add Items to Database
// This is a continuation of the questions I have asked from a tutorial by Paul Hudson on youtube -
I have tried to add items to a database (see image below) -
When I should click on the "Add" ...
1
vote
1answer
125 views
Vapor 3 Rendering leaf template with script inline
I am trying to render a template in Vapor 3 with Leaf. Most of my HTML is in my base.leaf. In the login.leaf template, I need to add a JS script. Trouble is when it gets to the function it breaks and ...
1
vote
1answer
659 views
Vapor `client.get`, transform and return json
I’m trying to GET data from another web service, then transform it and return it. I found a Spotify example in the docs, but I’m not sure how to return a portion of the JSON.
drop.get("music") { ...
1
vote
2answers
362 views
Vapor 4 PostgreSQL CRUD without http requests
I am writing backend using Swift 5 and Vapor 4, database is PostgreSQL 12. I have a question: how to interact with database (CRUD) locally, without POST or GET requests? All tutorials show how to CRUD ...
1
vote
2answers
789 views
Swift Vapor unsupported_grant_type invalid signature / OAuth access token
I am running Xcode 8.1 with Vapor and SWIFT 3.
I am posting a request to to google server to get an auth token, so I can call FireBaseDB API, but I get error: unsupported_grant_type/Invalid ...