Skip to content

Instantly share code, notes, and snippets.

View zastrozzi's full-sized avatar

zastrozzi zastrozzi

View GitHub Profile
@zastrozzi
zastrozzi / EnumArrayProperty.swift
Created June 17, 2024 13:21
Fluent Enum Arrays
import Fluent
import PostgresNIO
import FluentPostgresDriver
import PostgresKit
extension Fields {
public typealias EnumArray<EnumValue> = EnumArrayProperty<Self, EnumValue> where EnumValue: FluentEnumConvertible
}
@propertyWrapper
import Foundation
import Fluent
extension Fields {
public typealias AsyncTransformableField<Value, TransformedValue> = AsyncTransformableFieldProperty<Self, Value, TransformedValue> where Value: Codable
}
@propertyWrapper
public final class AsyncTransformableFieldProperty<Model, Value, TransformedValue> where Model: FluentKit.Fields, Value: Codable {
@zastrozzi
zastrozzi / async-convertible-commands.swift
Last active July 3, 2023 22:48
Async Convertible Command extension
import Vapor
// Standard async configure function
public func configure(_ app: Application) async throws {
app.commands.use(Cowsay(), as: "cowsay")
}
public protocol AsyncConvertibleCommand: Command, AsyncCommand, AnyAsyncCommand {
}