func getList(req:Request) async throws -> ResponseModel<[Mirror]> {
let paginate = try await Mirror.query(on: req.db).paginate(for: req)
return .init(success: paginate.items, page: .init(page: paginate.metadata.page,
per: paginate.metadata.per,
total: paginate.metadata.total))
}
struct ResponseModel<T: Content>: Content {
let code:Int
let message:String
let data:T?
let isSuccess:Bool
let page:Page?
init(success data:T, message:String = "success", page:Page? = nil) {
self.code = 200
self.message = message
self.data = data
self.isSuccess = true
self.page = page
}
init(failure code:Int, message:String) {
self.code = code
self.message = message
self.isSuccess = false
self.data = nil
self.page = nil
}
}
extension ResponseModel {
struct Page: Content {
let page: Int
let per: Int
let total: Int
var pageCount: Int {
let count = Int((Double(self.total)/Double(self.per)).rounded(.up))
return count < 1 ? 1 : count
}
}
}
final class Mirror: Model, Content {
static var schema: String { "mirror" }
@ID(key: .id)
var id: UUID?
@Field(key: "origin")
var origin:String
@Field(key: "mirror")
var mirror:String
@Timestamp(key: "create_time", on: .create, format: .unix)
var createTime:Date?
init() {
}
}
app_1 | Received signal 4. Backtrace:
app_1 | 0x5571d3930682, Backtrace.(printBacktrace in _B82A8C0ED7C904841114FDF244F9E58E)(signal: Swift.Int32) -> () at /build/.build/checkouts/swift-backtrace/Sources/Backtrace/Backtrace.swift:66
app_1 | 0x7f164adb93bf
app_1 | 0x5571d44d7cbd
app_1 | 0x5571d44d891b
app_1 | 0x5571d44f48e6
app_1 | 0x5571d44fea5a
app_1 | 0x5571d44ffb51
app_1 | 0x5571d41673ea
app_1 | 0x5571d415ff2e
app_1 | 0x5571d3c4220d, FluentKit.(ContainerEncoder in _4C082E18F4DDB8092F01BD9878C0524E).encode<A where A: Swift.Encodable>(A) throws -> () at /build/.build/checkouts/fluent-kit/Sources/FluentKit/Model/Fields+Codable.swift:134
app_1 | 0x5571d3c42a15, protocol witness for Swift.SingleValueEncodingContainer.encode<A where A1: Swift.Encodable>(A1) throws -> () in conformance FluentKit.(ContainerEncoder in _4C082E18F4DDB8092F01BD9878C0524E) : Swift.SingleValueEncodingContainer in FluentKit at /build/<compiler-generated>:0
app_1 | 0x5571d4397a17
app_1 | 0x5571d3c6c520, FluentKit.TimestampProperty.encode(to: Swift.Encoder) throws -> () at /build/.build/checkouts/fluent-kit/Sources/FluentKit/Properties/Timestamp.swift:134
app_1 | 0x5571d3c6c655, protocol witness for FluentKit.AnyCodableProperty.encode(to: Swift.Encoder) throws -> () in conformance FluentKit.TimestampProperty<A, B> : FluentKit.AnyCodableProperty in FluentKit at /build/<compiler-generated>:0
app_1 | 0x5571d3c4098a, closure #1 (Swift.String, FluentKit.AnyCodableProperty) throws -> () in (extension in FluentKit):FluentKit.Fields.encode(to: Swift.Encoder) throws -> () at /build/.build/checkouts/fluent-kit/Sources/FluentKit/Model/Fields+Codable.swift:27
app_1 | 0x5571d3c4098a, reabstraction thunk helper from @callee_guaranteed (@guaranteed Swift.String, @guaranteed FluentKit.AnyCodableProperty) -> (@error @owned Swift.Error) to @escaping @callee_guaranteed (@in_guaranteed (key: Swift.String, value: FluentKit.AnyCodableProperty)) -> (@error @owned Swift.Error) at /build/<compiler-generated>:0
app_1 | 0x5571d3c4098a, generic specialization <Swift.Dictionary<Swift.String, FluentKit.AnyCodableProperty>> of (extension in Swift):Swift.Sequence.forEach((A.Element) throws -> ()) throws -> () at /build/<compiler-generated>:0
app_1 | 0x5571d3c4098a, (extension in FluentKit):FluentKit.Fields.encode(to: Swift.Encoder) throws -> () at /build/.build/checkouts/fluent-kit/Sources/FluentKit/Model/Fields+Codable.swift:24
app_1 | 0x5571d3754f7a, protocol witness for Swift.Encodable.encode(to: Swift.Encoder) throws -> () in conformance App.Mirror : Swift.Encodable in App at /build/<compiler-generated>:0
app_1 | 0x5571d4396e23
app_1 | 0x5571d44f49d0
app_1 | 0x5571d4501553
app_1 | 0x5571d4502145
app_1 | 0x5571d4177263
app_1 | 0x5571d4177344
app_1 | 0x5571d4396e23
app_1 | 0x5571d44f49d0
app_1 | 0x5571d44fea5a
app_1 | 0x5571d44ffb51
app_1 | 0x5571d415fca6
app_1 | 0x5571d44ffcc4
app_1 | 0x5571d41688fa
app_1 | 0x5571d416025e
app_1 | 0x5571d3757ea3, App.ResponseModel.encode(to: Swift.Encoder) throws -> () at /build/<compiler-generated>:0
app_1 | 0x5571d3758115, protocol witness for Swift.Encodable.encode(to: Swift.Encoder) throws -> () in conformance App.ResponseModel<A> : Swift.Encodable in App at /build/<compiler-generated>:0
app_1 | 0x5571d4396e23
app_1 | 0x5571d44f49d0
app_1 | 0x5571d44f409a
app_1 | 0x5571d44f3df5
app_1 | 0x5571d401e001, (extension in Vapor):Foundation.JSONEncoder.encode<A where A: Swift.Encodable>(_: A, to: inout NIOCore.ByteBuffer, headers: inout NIOHTTP1.HTTPHeaders) throws -> () at /build/.build/checkouts/vapor/Sources/Vapor/Content/JSONCoders+Content.swift:6
app_1 | 0x5571d401e05a, protocol witness for Vapor.ContentEncoder.encode<A where A1: Swift.Encodable>(_: A1, to: inout NIOCore.ByteBuffer, headers: inout NIOHTTP1.HTTPHeaders) throws -> () in conformance Foundation.JSONEncoder : Vapor.ContentEncoder in Vapor at /build/<compiler-generated>:0
app_1 | 0x5571d40a0337, Vapor.Response.(_ContentContainer in _12BFF3A48F379674C1B262B432833FCC).encode<A where A: Swift.Encodable>(_: A, using: Vapor.ContentEncoder) throws -> () at /build/.build/checkouts/vapor/Sources/Vapor/Response/Response.swift:77
app_1 | 0x5571d40a074f, protocol witness for Vapor.ContentContainer.encode<A where A1: Swift.Encodable>(_: A1, using: Vapor.ContentEncoder) throws -> () in conformance Vapor.Response.(_ContentContainer in _12BFF3A48F379674C1B262B432833FCC) : Vapor.ContentContainer in Vapor at /build/<compiler-generated>:0
app_1 | 0x5571d401d2b7, (extension in Vapor):Vapor.ContentContainer.encode<A where A1: Vapor.Content>(_: A1, as: Vapor.HTTPMediaType) throws -> () at /build/.build/checkouts/vapor/Sources/Vapor/Content/ContentContainer.swift:68
app_1 | 0x5571d401cdd9, (extension in Vapor):Vapor.ContentContainer.encode<A where A1: Vapor.Content>(A1) throws -> () at /build/.build/checkouts/vapor/Sources/Vapor/Content/ContentContainer.swift:37
app_1 | 0x5571d40124fa, function signature specialization <Arg[0] = Dead> of (extension in Vapor):Vapor.Content.encodeResponse(for: Vapor.Request) async throws -> Vapor.Response at /build/.build/checkouts/vapor/Sources/Vapor/Concurrency/ResponseCodable+Concurrency.swift:113
app_1 | 0x5571d41283cc
app_1 | 0x5571d4128a58
app_1 | 0x5571d4452774
app_1 | 0x5571d4452522
app_1 | 0x5571d445e481
app_1 | 0x7f164adad608
app_1 | 0x7f164aaac162
app_1 | 0xffffffffffffffff
spm_mirror_server_app_1 exited with code 132