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
@available(macOS 14, iOS 13.0, watchOS 6.0, tvOS 13.0, *) | |
final class DispatchSerialExecutor: SerialExecutor { | |
let queue: DispatchQueue | |
init(queue: DispatchQueue) { | |
self.queue = queue | |
} | |
init() { | |
self.queue = DispatchQueue( |
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 SwiftUI | |
@MainActor class ViewModel: ObservableObject { | |
private let events = AsyncStream<AwaitableEvent>.makeStream() | |
struct AwaitableEvent { | |
let event: Event | |
let continuation: CheckedContinuation<Void, Never> | |
} |
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
final class NetworkUsers: URLRepresentable { | |
let apiVersion: APIVersion | |
let network: String | |
init(apiVersion: APIVersion, network: String) { | |
self.apiVersion = apiVersion | |
self.network = network | |
} | |
func makeURL() throws -> URL { |
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 MeowVapor | |
import JWT | |
final class CMSContext: Service { | |
struct Value { | |
public let meow: Meow.Context | |
public let token: AdministrativeUserToken? | |
public let user: AdministrativeUser? | |
} | |
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
// https://github.com/vapor/vapor | |
import Vapor | |
// https://github.com/Ikiga/IkigaJSON | |
import IkigaJSON | |
public struct JSONSafetyMiddleware: Middleware { | |
public init() {} | |
public func respond(to request: Request, chainingTo next: Responder) throws -> EventLoopFuture<Response> { |
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 encoder = JSONEncoder() | |
let decoder = JSONDecoder() | |
struct User: Codable { | |
let id: Int | |
let name: String | |
let age: Double | |
let roles: [String] | |
let awesome: Bool | |
} |
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 Foundation | |
let date = Date() | |
var array = [Any]() | |
for _ in 0..<100_000 { | |
array.append("Hello, world") | |
} |
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 Leopard | |
import Lynx | |
import Sockets | |
import HTTP | |
public final class LynxServer : ServerProtocol, AsyncRouter { | |
public func register(at path: [String], method: Lynx.Method?, isFallbackHandler: Bool, handler: @escaping RequestHandler) { | |
router.register(at: path, method: method, isFallbackHandler: isFallbackHandler, handler: handler) | |
} |
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 MongoKitten | |
import Foundation | |
let client = try Server("mongodb://localhost") | |
// Creating a user Document | |
func createUser() throws -> Document { | |
return [ | |
"username": "Joannis", | |
"age": 20, |
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 MongoKitten | |
import HTTP | |
import Vapor | |
protocol RolesRepresentable { | |
var roles: [Role] { get } | |
} | |
protocol Role { | |
var authorizationLevel: AuthorizationLevel { get } |
NewerOlder