This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "8A5B3531-4B20-4F08-8167-79701AFAC748", | |
"name": "user1@gmail.com" | |
}, | |
{ | |
"id": "48023C64-8D76-4E39-865C-04DD95C1FA6C", | |
"name": "user2@gmail.com" | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mappedUsers = allUsers.map { users -> [UserDto] in | |
var userContainer = [UserDto]() | |
users.forEach({ user in | |
userContainer.append(UserDto(id: user.id, name: user.email)) | |
}) | |
return userContainer | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// RESTController.swift | |
// App | |
// | |
// Created by Benjamin Baumann on 06.07.18. | |
// | |
import Foundation | |
import Vapor | |
import Authentication |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// State.swift | |
// App | |
// | |
// Created by Benjamin Baumann on 28.09.17. | |
// | |
import Vapor | |
import FluentProvider | |
import HTTP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Capital.swift | |
// App | |
// | |
// Created by Benjamin Baumann on 28.09.17. | |
// | |
import Vapor | |
import FluentProvider | |
import HTTP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Country.swift | |
// App | |
// | |
// Created by Benjamin Baumann on 28.09.17. | |
// | |
import Vapor | |
import FluentProvider | |
import HTTP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//1. Modify this controller to be built by "authRoutes" to protect all it's routes | |
/// GET /hello/... | |
authRoutes.resource("hello", HelloController(view)) | |
//2. create the login route | |
builder.get("login") { req in | |
return try self.view.make("login") | |
} | |
//3. implement the login logic, built by the "loginRouteBuilder" so our session is persisted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@_exported import Vapor | |
extension Droplet { | |
public func setup() throws { | |
let routes = Routes(view,drop: self) | |
try collection(routes) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vapor | |
import AuthProvider | |
import Sessions | |
import HTTP | |
final class Routes: RouteCollection { | |
let view: ViewRenderer | |
//route builder for protected routes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// GET / | |
builder.get { req in | |
return try self.view.make("welcome") | |
} | |
builder.get("register") { req in | |
return try self.view.make("register") | |
} | |
builder.post("register") { req in |
NewerOlder