Vapor 4 App / Tests sub-directory structure & style guide

I just started using Vapor 4 seriously and noticed that the style guide which was part of the Vapor 3 documentation is no longer part of the Vapor 4 docs. Having a background in Ruby on Rails myself, I really like how such a style guide can help simplify naming & base structuring processes by providing sensible & flexible-enough suggestions for typical use cases. This can not only help unexperienced developers just starting with backend development to follow the separation of concerns principle, it also makes it easier for experienced developers to switch projects.

While Ruby on Rails strictly follows the Convention over Configuration principle, we don't have to go as far as auto-generating the structure for every "blank" project. But I think having a suggestion for a base structure liek in the old docs and maybe even an optional template which can automatically creat it is a good idea.

In my project, I am now following the architecture style guide from Vapor 3 (due to the lack of an updated one), but I'm missing guidance on the Tests subfolder, it only provides tips for the App folder. But maybe that's because testing is lacking documentation and tips overall in the entire documentation, but that's probably a separate topic.

Hey there! I'm the original author of the style guide - thanks for checking it and Vapor out. This is an issue that has been on my radar for a while now. Unfortunately I haven't had the time to dig in to update it for Vapor 4 but I definitely want to. Just have to carve out the time.

That being said, PRs are welcome of course using the initial style guide as a base :) CC @tanner0101 here in case he has feedback/ideas as well.

1 Like

Great to hear that it's still planned. Given that I'm just starting with Vapor and already had a lot of questions or feedback on the documentation, I might actually post some PRs on the documentation. But before doing that, of course I want to get your feedback if I have actually understood everything correctly and not missed something. Regarding the style guide for example, I'm really missing more guidance on the testing part which I feel like was not a big focus until now in the development of Vapor. At least I can't find much on the topic, feel free to point me to some links to read up on it if I missed something.

I'm talking about something similar to the Testing Guide for Ruby on Rails where they not only mention how to test on the "request -> response" level (which Vapor already documents), but also how to test models, controllers, routes, helpers, services, async operations etc. separately. Of course, we might simply be missing helpers there, but I'm sure some people who have bigger Vapor projects in production already wrote some solutions here which they could share and which could guide new developers by mentioning them as examples within the documentation. Especially considering that many people trying out Vapor have an iOS development background, I think it is very important to document the parts very clearly which differ most. And testing in iOS apps is most of the time focused on the correct behavior of screen navigation and less about model-layer validation. But on backends, I think having unit tests on every layer is very important and can save a lot of time.

Terms of Service

Privacy Policy

Cookie Policy