Difference between revisions of "Vapor"

From Coder Merlin
m (Editorial review and minor corrections)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Getting Started ==
== Getting Started ==
<pre>
{{ConsoleLine|john-williams@codermerlin:~$ |<nowiki>git clone https://github.com/TheCoderMerlin/VaporShell</nowiki> }}
vapor new hello -n
</pre>


== Configuration ==
== Building ==
In the path: {{Pathname|./Sources/App/configure.swift}}:
{{ConsoleLine|john-williams@codermerlin:~$ |build}}


<syntaxhighlight lang="swift">
== Run ==
// Set local port
{{ConsoleLine|john-williams@codermerlin:~$ |run}}
guard let portString = Environment.get("VAPOR_LOCAL_PORT"),
      let port = Int(portString) else {
    fatalError("Failed to determine VAPOR LOCAL PORT from environment")
}
app.http.server.configuration.port = port


// Set local host
The server then answers at https://www.codermerlin.com/vapor/(user-name)/.
guard let hostname = Environment.get("VAPOR_LOCAL_HOST") else {
    fatalError("Failed to determine VAPOR LOCAL HOST from environment")
}
app.http.server.configuration.hostname = hostname
</syntaxhighlight>


== References ==
{{Hint|If the page doesn't load, you might be forgetting a slash at the end! This is a common problem. (It has something to do with semantics. See more at [https://stackoverflow.com/a/5949201/15982771 Stackoverflow])}}
=== Fluent ===
* [https://theswiftdev.com/get-started-with-the-fluent-orm-framework-in-vapor-4/ Getting Started with Fluent] (TheSwiftDev)

Latest revision as of 11:25, 21 April 2024

Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder

Getting Started[edit]

john-williams@codermerlin:~$  git clone https://github.com/TheCoderMerlin/VaporShell

Building[edit]

john-williams@codermerlin:~$  build

Run[edit]

john-williams@codermerlin:~$  run

The server then answers at https://www.codermerlin.com/vapor/(user-name)/.

Hint.pngHelpful Hint
If the page doesn't load, you might be forgetting a slash at the end! This is a common problem. (It has something to do with semantics. See more at Stackoverflow)