Skip to content

Adds Vapor backend to project#109

Open
loloop wants to merge 7 commits into
developfrom
mauricio/vapor
Open

Adds Vapor backend to project#109
loloop wants to merge 7 commits into
developfrom
mauricio/vapor

Conversation

@loloop
Copy link
Copy Markdown
Member

@loloop loloop commented Sep 29, 2025

This PR intends to:
• Add a vapor backend starter base to the project
• Remove the SwiftSoup dependency for meetup fetching from the app, delegating that feature to the backend instead

Tasks:

  • Create a common shared package between the apps and the backend (CocoaHeadsCore)
  • Move SwiftSoup and the meetup fetching service to the backend

Next steps

  • Migrate the app to use the backend functions
  • Automate testing and deployment of new versions of the backend
  • Piece by piece move Chapters, Raffles, Q&A and everything that depends on CloudKit to the backend

@loloop loloop marked this pull request as ready for review September 30, 2025 20:11
Copy link
Copy Markdown
Collaborator

@unnamedd unnamedd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@loloop, thanks for the effort here. As I am not working—not even a bit—in the CH projects, I do not see myself in a position to block your work with a "Request changes" from GitHub's Pull Request; however, I’m raising some points here for your appreciation.

Give a check, and if you think they are addressable, apply the comments and, if you want me to give you a second review, just re-request a review and I will do so with great pleasure.

Comment on lines +22 to +28
guard
let url = URL(string: meetup.url),
case (let data, _) = try await URLSession.shared.data(from: url),
let html = String(data: data, encoding: .utf8)
else {
throw Error.urlError
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest you to split into two different guards here. You are not being clear enough when raising errors.
If something goes wrong with the URL, then you will throw Error.urlError, however, in case you get an error while you are requesting the content from that URL using URLSession or get an error while you are converting from the received data into a String, you will also throw Error.urlError. You had to separate at least in two more guards to throw the proper error.

throw Error.urlError
}

guard !url.absoluteString.contains("Entrar") else {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is "Entrar" a safe string to use?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used to be, but meetup has released a completely new design while I was working on moving this code around, so I'll need to do more testing to figure out if everything here still works

case .addressError:
"Erro ao buscar o endereço"
case .coordinateError:
"Erro no parse das coordenadas"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are going to use the error messages in portuguese, perhaps here we should use "extrair" instead of "parse". What do you think?

Suggested change
"Erro no parse das coordenadas"
"Erro ao extrair as coordenadas"

Copy link
Copy Markdown
Member Author

@loloop loloop Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These errors used to be part of the UI when SwiftSoup was directly integrated in the app. I'm totally down to translate these messages to english now that they're part of the API

case .coordinateError:
"Erro no parse das coordenadas"
case .dateError:
"Não consegui encontrar ou fazer decode da data"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Não consegui encontrar ou fazer decode da data"
"Não foi possível encontrar ou decodificar a data"


extension String {
fileprivate func removingFirstOccurrence(of word: String) -> String {
guard let range = range(of: "\\b\(word)\\b", options: [.regularExpression, .caseInsensitive]) else {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we have just one use case, but I was wondering if would be a good place to make use of RegexBuilder here

// Created by Mauricio on 5/14/25.
//

import CocoaHeadsCore
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CocoaHeadsKit or CocoaHeadsCore? I see them being mixed here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CocoaHeadsKit is the package that provides all the code for the apps, CocoaHeadsCore is a new package that provides shared code between the apps and the Vapor backend

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps it would be better if they were renamed in order to avoid confusion. To me, as you probably noticed, they were just getting mixed with each other, while in fact, they do separate things, but I am completely out of ideas to suggest something better haha

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think better documenting them would help with this

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, it would

@loloop loloop changed the title WIP: Adds Vapor backend to project Adds Vapor backend to project Dec 4, 2025
@CocoaHeadsConference CocoaHeadsConference deleted a comment from claude Bot Apr 4, 2026
@CocoaHeadsConference CocoaHeadsConference deleted a comment from claude Bot Apr 4, 2026
@CocoaHeadsConference CocoaHeadsConference deleted a comment from claude Bot Apr 4, 2026
@CocoaHeadsConference CocoaHeadsConference deleted a comment from claude Bot Apr 4, 2026
@CocoaHeadsConference CocoaHeadsConference deleted a comment from claude Bot Apr 4, 2026
@CocoaHeadsConference CocoaHeadsConference deleted a comment from claude Bot Apr 7, 2026
@loloop
Copy link
Copy Markdown
Member Author

loloop commented Apr 7, 2026

@unnamedd I know it's been a while, but can you check the PR again? Most of what you reviewed before was scrapped due to a change in how meetup works in favor of adopting an AI scraping provider

@unnamedd
Copy link
Copy Markdown
Collaborator

unnamedd commented Apr 8, 2026

Yeah sure, @loloop! Will do it! 😉

@unnamedd
Copy link
Copy Markdown
Collaborator

@loloop sorry mate, I completely forgot about your request here! I will give a check still this week! ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants