Questions tagged [vapor]
A web framework and server for Swift that works on macOS and Linux.
920
questions
1
vote
1
answer
48
views
How do I commit a Vapor project to GitHub?
I'm getting started with Vapor and created a new hello-world Vapor project. However if I want to commit this project to my GitHub repo using GitHub Desktop, I don't really see any files to commit even ...
1
vote
0
answers
83
views
Nil value for required field of sibling relation in vapor / fluent causes fatal error
I have a question about fluent / vapor. Maybe someone here has an idea and can help me.
I have a sibling relation which I want to eager-load when fetching an entity.
let all = try await ExerciseBase
...
1
vote
2
answers
50
views
Vapor project swift run App serve --env production does not work
I follow the Vapor doc and try to deploy my project. I tried to run
swift run App serve --env production
or
.build/release/App serve --env production
[Vapor] ConsoleKit.ConsoleError(identifier: "...
1
vote
1
answer
58
views
Vapor(4.77) Leaf(4.2.4) 101: Unable to render a child leaf within its parent leaf (template)
Environment:
Vapor v4.77
Leaf v4.2.4
Neophyte Goal: To incorporate a child leaf into its parent leaf (template).
Scenario: Rendering the basic "hello" world is fine. It works as a stand-...
1
vote
1
answer
50
views
Vapor Logger doesn't log any messages into System Log
Environment:
Vapor 4.77
MacOS 13.5
Running on LocalHost:8080
Scenario:
I've created a subclass within Vapor's app.logger to collect logs.
Add set the logger base level to .info.
I've added a log ...
1
vote
0
answers
34
views
Postgre-Kit: Unable to complete code access to PostgreSQL DB
Goal: To connect to a Postgre database and merely add simple data to a database table.
Environment:
// swift-tools-version:5.9
import PackageDescription
let package = Package(
name: "...
1
vote
1
answer
50
views
How to decide to use siblings or parent/children relations in vapor?
I have a table named posts, and users can add any post to his favorites. From the perspective of the post, this is User(Parent)/Post(children) relation. But a post can be added to any user's favorites,...
3
votes
2
answers
96
views
How to make a optional query filter in Vapor
Here is my code:
var query = Post.query(on: req.db)
if needFilter == true {
query = query.filter(\.$board.$id == boardId)
}
return try await query
.with(\.$profile).all()
...
1
vote
1
answer
29
views
How can I handle empty query parameters in Vapor routes handler
I would like to handle this HTTP GET request http://localhost:8080/route?wsdl and return a static file
I have started with this route handler
app.get("route") { req throws -> ...
1
vote
0
answers
44
views
Unable to acquire ID for POST of Content-Type: Multipart/form-data to Postgre DB via Fluent
Environment: MacOS 13.5.1 Vapor 4.77
Scenario: Attempting to post:
{"title":"String", "description":"String", "Info":"Data"} to a Postgre DB ...
1
vote
1
answer
45
views
how do vapor fluent do a upsert?
I have a table named profile, and my model here:
final class Profile: Model, Content {
struct Keys {
static let userId: FieldKey = "user_id"
static let nickname: FieldKey ...
1
vote
1
answer
40
views
Vapor registered 'ToDo' database yet PostgreSQL doesn't show it from the prompt
Environment: Vapor v4.77
Database: Postgresql@15 via Homebrew
Here's the environment:
/Users/Ric> echo $DATABASE_NAME
ToDo
/Users/Ric> echo $DATABASE_HOST
localhost
/Users/Ric> echo $...
0
votes
1
answer
88
views
NIOCore.ChannelError.connectTimeout(NIOCore.TimeAmount(nanoseconds: 10000000000))
My project with Swift Vapor was working well, and one day, I started getting this warning in the Xcode console and web browser of my development computer. On the server side, the deployed code works ...
1
vote
0
answers
46
views
Vaper Persistent Store ID problem associated with Fluent
Scenario: Using local Postgres DB via Fluent package.
Goal: To produce a simple DB table with two fields: 'Name' (String) and 'Info' (Data).
I'm testing the storage & retrieval of JSON Data via a ...
-1
votes
1
answer
73
views
Best way to run an async job or operation upon Vapor app startup? [closed]
I have a Vapor app, and what I want to accomplish is this - upon app startup, I want to run an async job or some kind of async operation that can clear out and re-dispatch some dispatched jobs. I want ...
1
vote
1
answer
55
views
What's the best way to debug Vapor 4?
Environment: Vapor 4.77+
MacOS: 13.4.1
Goal: To step thru the vapor code in real time and inspect elements as I normally do with a regular iOS/MacOS app via Xcode.
Here's a snippet example of what I ...
1
vote
1
answer
59
views
IOS (simulator) --> Local Vapor POST Image/png: Abort.413: Payload Too Large
Environment: Vapor (v4.77+) MacOS v13.4.1
Scenario: Attempting to POST image/png (466 kb) to Server.
The server is local to my Mac: http://localhost:8080/upload
This is running concurrently with ...
1
vote
1
answer
124
views
uuid = UUID(uuidString: String) create uppercase Letters
I have a problem with the function UUID(uuidString: String). Passing a UUID as String with lower case letters the above function generates a UUID with upper case letters. Can anyone give me a hint as ...
-2
votes
1
answer
89
views
Backend project on swift 5.8 and vapor
I'm taking a vapor video course. I write code strictly according to it, and when I try to send a Post request (by postman), get a custom error code. In the course, everything is fine and it seems that ...
1
vote
1
answer
68
views
Swift Vapor query filtering and sorting by distance
I'm working on the swift vapor project. I need to filter and sort users by distance(it should not exceed 100 kilometers and the first user should be the closest). I have the coordinates latitude and ...
1
vote
1
answer
88
views
How can I run swift AVFoundation as server-side code?
So I have some swift code that I originally built for a native MacOS app that downloads a video from firebase, performs some AI processes on it, and then uploads several other shortened versions back ...
0
votes
2
answers
80
views
How to handle canceled request in vapor?
I am using Vapor on a mac server. The server makes lengthy computation so I need to allow the client to be able to cancel the computation.
On the client side, I have the following Javascript code to ...
1
vote
0
answers
50
views
Swift Vapor web sockets doesn't work on Ubuntu 22.04
I'm trynna set up my server application on Ubuntu 22.04. Everything works except websocets. When I ran the server on my computer locally they worked. When I trynna connect via Postman, the connection ...
1
vote
1
answer
41
views
How Do I Access Data in SQLRow object in Vapor/Fluent?
I am running raw sql queries in a Vapor app in a Fluent context.
The output I am getting for the object I'm interested in looks like:
(lldb) po words
▿ _PostgresSQLRow
▿ randomAccessView : ...
2
votes
0
answers
75
views
Calling URL request with private and public key
For Vapor script that runs on Linux I need to make a request that corresponds to following cURL but as of now, I was unable to find the best solution for this.
curl -X GET \
https://endpoint \
--...
1
vote
1
answer
41
views
Swift Vapor Package "Circular reference" error
.I'm getting a "Circular reference" error in my Vapor project's Package file, and I can't figure out why. The error appears when I add the APNS dependency (https://github.com/vapor/apns). ...
1
vote
1
answer
180
views
How to reset a Redis database set in Docker after a test?
I have the user access token saved in the Redis database on a Docker container when running tests.
The first time the test runs, it works well. But because I can not manage to reset the Docker ...
3
votes
3
answers
157
views
Swift server-side vapor: How to download file to disk?
I want to download multiple files in swift vapor. Some files have to be downloaded to disk and some should be just in-memory. For some i need to specify http-headers.
I know of the ClientRequest which ...
1
vote
1
answer
45
views
How to add a class to the body tag in a Leaf base template
I'm building a site with Vapor and using the Leaf templating engine. Say I have the following base template defined in Base.leaf:
<!DOCTYPE html>
<html lang="en">
<head>...
1
vote
1
answer
107
views
Supervisor can't find Run command of Vapor App
I am attempting to set up Supervisor to run a sample Vapor app written in Swift 5.8 on an Ubuntu 22.04 server (I have also tried on 20.4 with the same result). The app was created with vapor new hello ...
1
vote
1
answer
117
views
How to setup Heroku to read a private repository linked to my server app using a SSH key?
Heroku does not find the right SSH key when deploying my Vapor application, and fails immediately.
When trying to deploy my server on Heroku, I get this error as I added a private repository to my ...
1
vote
0
answers
48
views
Why Xcode / Swift does not show values during debugging?
Maybe this is because a Vapor code is debugged, but I do not see the value of variables, why?
func migrateRecipients(_ req: Request) async throws -> HTTPStatus {
let os = try await ...
4
votes
0
answers
203
views
How to stream data in Vapor Swift?
I'm building an Open AI chat stream backend using Vapor Swift. It connects to Open AI API using MacPaw's OpenAI wrapper. But I'm unsure how to stream the result to the client using SSE rather than as ...
1
vote
1
answer
26
views
how to solve this: vapor receive response property output format is changed?
I want use a content struct to decode the response, but some case the output property is:
"output": [
{
"file": "aaa.jpg"
}
],
and some case output ...
2
votes
0
answers
208
views
Streaming an API proxy in Vapor
I'm trying to make a proxy for the openAI chat api in Vapor, so that my iOS app won't need to know the api key. The thing that makes this a bit tricky is that I want to use streaming: stream=true. So ...
3
votes
1
answer
111
views
Is there any way to integrate cloudkit in a swift package more specifically in a vapor server package?
I was trying to build an api based on vapor 4 server and cloudKit. For that I need to connect the vapor 4 package with the cloudkit. Is there any way to connect cloudkit in a swift package?
Integrate ...
1
vote
0
answers
149
views
Files in volume are deleted when using docker-compose up
I have a Docker Compose setup with a web app in vapor and a database container. The web app container has a volume mounted to store user-uploaded files, like images. I noticed that when I rebuild the ...
2
votes
2
answers
368
views
How can I set ngrok on Vapor to work locally with an owned domain?
When setting up ngrok on my Vapor server application, using a docker container, I cannot manage to create a secure web connection using a custom domain that I own.
I would like to use my docker-...
1
vote
1
answer
85
views
Vapor 4 Fluent ORM cannot get Sort to work
I cannot for the life of me get this sort to work in Vapor 4, and cannot find more clarification in the documentation:
I have a function as follows:
func getTopIdeas(req: Request) throws -> ...
2
votes
1
answer
76
views
Unable to send email with VaporSMTPKit on a ubuntu server
I'm looking for sending email with VaporSMTPKit (https://github.com/Joannis/VaporSMTPKit) on a Ubuntu Server. When I'm trying to send the email with a get request, I have an "The request timed ...
1
vote
1
answer
175
views
Sign in with Apple using Vapor 4
I'm trying to implement Sign In with Apple using Vapor 4
I followed Vapor Docs
But when I use the api and send user's token (even as a request header or in the body), it returns the following error
{
...
1
vote
1
answer
40
views
Vapor 4, Schema Truncate
What is the easiest way to truncate a table on a migration reversion function in vapor 4? Must I write a custom query or is there a method like .delete() than can be called, like .truncate()?
func ...
2
votes
1
answer
349
views
How to update field from required to optional using vapor (fluent migration)?
I'm use vapor 4
struct MakeRegionOptional: AsyncMigration {
func prepare(on database: Database) async throws {
try await database.schema("Attraction")
....
1
vote
1
answer
70
views
Fluent with MySQL (MariaDB) Geometry column type
I need to retrieve latitude/longitude from MariaDB database stored as POINT data type and unable to find a solution for this.
I tried to read value as a string:
@Field(key: "location")
var ...
2
votes
1
answer
701
views
How to associate the localhost domain with my application identifier when using Passkey auth?
Working a Vapor application on localhost, and when trying to authenticate with Passkey using the iPhone simulator, the authorizationController(controller:didCompleteWithError:) delegate method ...
1
vote
1
answer
71
views
Swift Generic Function Without Explicit Declaration
I am facing problem in creating a generic function that will handle all the requests I receive in Vapor. I hope someone can help me to fix this issue
func boot(routes: RoutesBuilder) throws {
...
0
votes
1
answer
210
views
How to add SwiftLint to Swift Vapor project
I'm trying to add SwiftLint to my Swift Vapor project but had no luck figuring out these errors.
Full Package.swift code:
import PackageDescription
let package = Package(
name: "VaporApp&...
1
vote
0
answers
131
views
Vapor: How to get response URL using Vapor Client or async-http
Something I'm running into when using Vapor to crawl sites is if I enter a url like http://website(dot)com and it redirects to https://www.website(dot)com, I need to grab that final response URL to ...
3
votes
2
answers
697
views
Problems with token authentication - not authorized
I am following the book 'Server Side Swift with Vapor' and I am at chapter 18. I followed the instructions on how to generate a token when the user logs in. I created a Token class:
import Vapor
...
1
vote
1
answer
126
views
Vapor 4 Per object subordinate views/templates in Leaf?
.nameJust getting into Vapor and I think I've got the basics down relatively well. But I have a design model for a page that has me stumped.
I have a simple index of servers that displays in a table ...