parent
88364fc096
commit
401d5ef679
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"originHash" : "39da4f005434f990c0dece54faba957e7edc27104875be011d48221ad538739d",
|
"originHash" : "d54afbeb9301d3df649cfb4bef5794fb7abe1c6aa826c3651df7253a5656b124",
|
||||||
"pins" : [
|
"pins" : [
|
||||||
{
|
{
|
||||||
"identity" : "async-http-client",
|
"identity" : "async-http-client",
|
||||||
|
|
@ -28,6 +28,33 @@
|
||||||
"version" : "4.15.2"
|
"version" : "4.15.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"identity" : "fluent",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/vapor/fluent.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "223b27d04ab2b51c25503c9922eecbcdf6c12f89",
|
||||||
|
"version" : "4.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "fluent-kit",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/vapor/fluent-kit.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "8baacd7e8f7ebf68886c496b43bbe6cdcc5b57e0",
|
||||||
|
"version" : "1.52.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "fluent-postgres-driver",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/vapor/fluent-postgres-driver.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "095bc5a17ab3363167f4becb270b6f8eb790481c",
|
||||||
|
"version" : "2.10.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"identity" : "leaf",
|
"identity" : "leaf",
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,14 @@
|
||||||
import PackageDescription
|
import PackageDescription
|
||||||
|
|
||||||
let package = Package(
|
let package = Package(
|
||||||
name: "ManagableUsers",
|
name: "ManageableUsers",
|
||||||
platforms: [
|
platforms: [
|
||||||
.macOS(.v13)
|
.macOS(.v13)
|
||||||
],
|
],
|
||||||
products: [
|
products: [
|
||||||
.library(
|
.library(
|
||||||
name: "ManagableUsers",
|
name: "ManageableUsers",
|
||||||
targets: ["ManagableUsers"]
|
targets: ["ManageableUsers"]
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
dependencies: [
|
dependencies: [
|
||||||
|
|
@ -28,7 +28,7 @@ let package = Package(
|
||||||
],
|
],
|
||||||
targets: [
|
targets: [
|
||||||
.target(
|
.target(
|
||||||
name: "ManagableUsers",
|
name: "ManageableUsers",
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.product(name: "Fluent", package: "fluent"),
|
.product(name: "Fluent", package: "fluent"),
|
||||||
.product(name: "FluentPostgresDriver", package: "fluent-postgres-driver"),
|
.product(name: "FluentPostgresDriver", package: "fluent-postgres-driver"),
|
||||||
|
|
@ -43,7 +43,7 @@ let package = Package(
|
||||||
.executableTarget(
|
.executableTarget(
|
||||||
name: "SampleApp",
|
name: "SampleApp",
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.target(name: "ManagableUsers"),
|
.target(name: "ManageableUsers"),
|
||||||
],
|
],
|
||||||
swiftSettings: swiftSettings
|
swiftSettings: swiftSettings
|
||||||
),
|
),
|
||||||
|
|
|
||||||
18
README.md
18
README.md
|
|
@ -1,4 +1,4 @@
|
||||||
# ManagableUsers
|
# ManageableUsers
|
||||||
|
|
||||||
A package providing basic user management when using the Vapor web framework and a PostgreSQL database.
|
A package providing basic user management when using the Vapor web framework and a PostgreSQL database.
|
||||||
|
|
||||||
|
|
@ -76,34 +76,34 @@ Create a new Vapor project, or reuse an existing one.
|
||||||
|
|
||||||
### Dependencies
|
### Dependencies
|
||||||
|
|
||||||
Add dependency on `managable-users` by adding the package to `Package.swift` as
|
Add dependency on `manageable-users` by adding the package to `Package.swift` as
|
||||||
```swift
|
```swift
|
||||||
.package(url: "https://git.carlberg.org/public/manageable-users.git", from: "1.0.0"),
|
.package(url: "https://git.carlberg.org/public/manageable-users.git", from: "1.0.0"),
|
||||||
```
|
```
|
||||||
|
|
||||||
…and adding to the executable target's dependencies as
|
…and adding to the executable target's dependencies as
|
||||||
```swift
|
```swift
|
||||||
.product(name: "ManagableUsers", package: "managable-users"),
|
.product(name: "ManageableUsers", package: "manageable-users"),
|
||||||
``
|
``
|
||||||
|
|
||||||
Copy the contents of the `Resources/Views` folder from the `managable-users` into the `Resources/Views` folder
|
Copy the contents of the `Resources/Views` folder from the `manageable-users` into the `Resources/Views` folder
|
||||||
in the new project, and also copy the contents of the `Public` folder into the `Public` folder.
|
in the new project, and also copy the contents of the `Public` folder into the `Public` folder.
|
||||||
|
|
||||||
In the `configure.swift` file, add the import
|
In the `configure.swift` file, add the import
|
||||||
```swift
|
```swift
|
||||||
import ManagableUsers
|
import ManageableUsers
|
||||||
```
|
```
|
||||||
|
|
||||||
…and add
|
…and add
|
||||||
```swift
|
```swift
|
||||||
try await ManagableUsers.configure (app)
|
try await ManageableUsers.configure (app)
|
||||||
```
|
```
|
||||||
|
|
||||||
into the `configure()` function.
|
into the `configure()` function.
|
||||||
|
|
||||||
In the `routes.swift` file, add the import
|
In the `routes.swift` file, add the import
|
||||||
```swift
|
```swift
|
||||||
import ManagableUsers
|
import ManageableUsers
|
||||||
```
|
```
|
||||||
|
|
||||||
…and replace everything in the `routes()` function with
|
…and replace everything in the `routes()` function with
|
||||||
|
|
@ -137,13 +137,13 @@ To use a consistent look, use `base.leaf` in your Leaf templates for pages.
|
||||||
To add items to the main menu, do that in `configure.swift` by replacing
|
To add items to the main menu, do that in `configure.swift` by replacing
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
try await ManagableUsers.configure (app)
|
try await ManageableUsers.configure (app)
|
||||||
```
|
```
|
||||||
|
|
||||||
with something like
|
with something like
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
try await ManagableUsers.configure(app, mainMenu: [MenuItem (section: "inventory", path: "inventory", name: "Inventory")])
|
try await ManageableUsers.configure(app, mainMenu: [MenuItem (section: "inventory", path: "inventory", name: "Inventory")])
|
||||||
```
|
```
|
||||||
|
|
||||||
For `MenuItem`
|
For `MenuItem`
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import Fluent
|
||||||
import FluentPostgresDriver
|
import FluentPostgresDriver
|
||||||
import SwiftSMTPVapor
|
import SwiftSMTPVapor
|
||||||
|
|
||||||
public struct ManagableUsers {
|
public struct ManageableUsers {
|
||||||
public static func configure (_ app: Application, mainMenu: [MenuItem] = [], homePageName: String = "Home", userAdminPageName: String = "User Administration") async throws {
|
public static func configure (_ app: Application, mainMenu: [MenuItem] = [], homePageName: String = "Home", userAdminPageName: String = "User Administration") async throws {
|
||||||
app.databases.use(DatabaseConfigurationFactory.postgres(configuration: .init(
|
app.databases.use(DatabaseConfigurationFactory.postgres(configuration: .init(
|
||||||
hostname: Environment.get("DATABASE_HOST") ?? "localhost",
|
hostname: Environment.get("DATABASE_HOST") ?? "localhost",
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import ManagableUsers
|
import ManageableUsers
|
||||||
import Vapor
|
import Vapor
|
||||||
|
|
||||||
public func configure (_ app: Application) async throws {
|
public func configure (_ app: Application) async throws {
|
||||||
app.middleware.use(FileMiddleware(publicDirectory: app.directory.publicDirectory))
|
app.middleware.use(FileMiddleware(publicDirectory: app.directory.publicDirectory))
|
||||||
|
|
||||||
try await ManagableUsers.configure (app)
|
try await ManageableUsers.configure (app)
|
||||||
|
|
||||||
try routes(app)
|
try routes(app)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import ManagableUsers
|
import ManageableUsers
|
||||||
import Vapor
|
import Vapor
|
||||||
|
|
||||||
func routes(_ app: Application) throws {
|
func routes(_ app: Application) throws {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import ManagableUsers
|
import ManageableUsers
|
||||||
@testable import SampleApp
|
@testable import SampleApp
|
||||||
import VaporTesting
|
import VaporTesting
|
||||||
import SQLKit
|
import SQLKit
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
@testable import SampleApp
|
@testable import SampleApp
|
||||||
import ManagableUsers
|
import ManageableUsers
|
||||||
import VaporTesting
|
import VaporTesting
|
||||||
import SQLKit
|
import SQLKit
|
||||||
import Testing
|
import Testing
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue