-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51767eb
commit 4d65693
Showing
5 changed files
with
107 additions
and
4 deletions.
There are no files selected for viewing
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
15 changes: 15 additions & 0 deletions
15
SolardVPNCommunityCoreiOS/SOLARdVPNCommunityCoreiOS/Common/Utilities/ClientConstants.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// ClientConstants.swift | ||
// SOLARdVPNCommunityCoreiOS | ||
// | ||
// Created by Viktoriia Kostyleva on 27.09.2022. | ||
// | ||
|
||
import Foundation | ||
|
||
enum ClientConstants { | ||
static let host = "localhost" | ||
static let port = 3876 | ||
|
||
static let apiPath = "api" | ||
} |
39 changes: 39 additions & 0 deletions
39
SolardVPNCommunityCoreiOS/SOLARdVPNCommunityCoreiOS/DVPNServer.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// DVPNServer.swift | ||
// SOLARdVPNCommunityCoreiOS | ||
// | ||
// Created by Viktoriia Kostyleva on 26.09.2022. | ||
// | ||
|
||
import Vapor | ||
|
||
class DVPNServer: ObservableObject { | ||
let app: Application | ||
|
||
init() { | ||
app = Application(.development) | ||
configure(app) | ||
} | ||
} | ||
|
||
extension DVPNServer { | ||
func start() { | ||
Task(priority: .background) { | ||
do { | ||
try app.register(collection: NodesRouteCollection()) | ||
try app.start() | ||
} catch { | ||
fatalError(error.localizedDescription) | ||
} | ||
} | ||
} | ||
} | ||
|
||
// MARK: - Private | ||
|
||
extension DVPNServer { | ||
private func configure(_ app: Application) { | ||
app.http.server.configuration.hostname = ClientConstants.host | ||
app.http.server.configuration.port = ClientConstants.port | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
SolardVPNCommunityCoreiOS/SOLARdVPNCommunityCoreiOS/NodesRouteCollection.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// NodesRouteCollection.swift | ||
// SOLARdVPNCommunityCoreiOS | ||
// | ||
// Created by Viktoriia Kostyleva on 27.09.2022. | ||
// | ||
|
||
import Vapor | ||
|
||
struct NodesRouteCollection: RouteCollection { | ||
func boot(routes: RoutesBuilder) throws { | ||
routes.get(use: getNodes) | ||
routes.get(.init(stringLiteral: ClientConstants.apiPath), "nodes", use: getNodes) | ||
} | ||
} | ||
|
||
extension NodesRouteCollection { | ||
func getNodes(_ req: Request) async throws -> Int { | ||
|
||
return 1 | ||
} | ||
} |
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