File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# ApplicationConfiguration
2- A simple and codable way to configure a Perfect Application
2+ A simple and codable way to configure a Perfect Application.
3+
4+ ** This module is a part of PerfectAcelerators brought to you by the Perfect Community!**
5+
6+ ## Installation
7+ Using Swift Package Manager, add the following to your packages.swift
8+
9+ ` .package(url: "https://github.com/PerfectAccelerators/ApplicationConfiguration.git", .branch("master")) `
10+
11+ Run ` swift package update ` and if you use Xcode run ` swift package generate-xcodeproj `
12+ ## Usage
13+ Create a file that includes the configuration for your application, for instance:
14+ {
15+ "server": {
16+ "baseURL": "localhost:8181",
17+ "baseDomain": "localhost",
18+ "port": 8181,
19+ "secure": 0
20+ },
21+ "os": 2,
22+ "environment": 1,
23+ "ssl": {
24+ "port": 443,
25+ "originCertificatePath": "",
26+ "privateKeyPath": "",
27+ "verifyMode": "peer"
28+ },
29+ "logging": {
30+ "requestLoggingPath": "./perfectRequests.log",
31+ "logPath": "./perfect.log"
32+ },
33+ "db": {
34+ "name": "perfect",
35+ "host": "localhost",
36+ "port": 3306,
37+ "user": "",
38+ "pass": "",
39+ "driverType": 1
40+ }
41+ }
42+
43+ Then modify your main.swift:
44+ import ApplicationConfiguration
45+
46+ #if os(Linux)
47+ let fileRoot = "/perfect-deployed/Perfect/"
48+ let filePath = "./config/ApplicationConfigurationLinux.json"
49+ #endif
50+
51+ let app = Application(name: "Perfect", path: filePath)
52+
53+ do {
54+ try HTTPServer.launch(app.server())
55+ } catch {
56+ fatalError("\( error)")
57+ }
58+
59+ ## Contributing
60+ To contribute a feature or idea to ** ApplicationConfiguration** , fork the project, make your changes and submit a pull request :)
You can’t perform that action at this time.
0 commit comments