From 3c386dcea7407151147c057d075e342ebb4c44cb Mon Sep 17 00:00:00 2001 From: AK Date: Sat, 3 Oct 2026 00:23:23 +0300 Subject: [PATCH] some bullshit --- .vscode/extensions.json | 3 - Package.resolved | 267 ++++++++++++++++++ .../Errors/wrongPriorityError.swift | 9 + .../SwiftBackendShit/Repository/model.swift | 32 +++ .../SwiftBackendShit/Repository/notDB.swift | 18 ++ Sources/SwiftBackendShit/routes.swift | 14 + 6 files changed, 340 insertions(+), 3 deletions(-) delete mode 100644 .vscode/extensions.json create mode 100644 Package.resolved create mode 100644 Sources/SwiftBackendShit/Errors/wrongPriorityError.swift create mode 100644 Sources/SwiftBackendShit/Repository/model.swift create mode 100644 Sources/SwiftBackendShit/Repository/notDB.swift diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index 42783d7..0000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "recommendations": ["swiftlang.swift-vscode", "Vapor.vapor-vscode"] -} \ No newline at end of file diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..074366e --- /dev/null +++ b/Package.resolved @@ -0,0 +1,267 @@ +{ + "originHash" : "7b889bd4dfd92aae5d52611fe32347461bb429de5ad0e3560b58e39e870fc680", + "pins" : [ + { + "identity" : "async-http-client", + "kind" : "remoteSourceControl", + "location" : "https://github.com/swift-server/async-http-client.git", + "state" : { + "revision" : "4c005f955e83f888d5616e579717a36d2dfc6301", + "version" : "1.36.2" + } + }, + { + "identity" : "async-kit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/vapor/async-kit.git", + "state" : { + "revision" : "6bbb83cbf9d886623a967a965c8fb1b73e6566f9", + "version" : "1.22.0" + } + }, + { + "identity" : "console-kit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/vapor/console-kit.git", + "state" : { + "revision" : "15121e1ec44a0a2064e43545d1390f02cc19b07d", + "version" : "4.16.1" + } + }, + { + "identity" : "multipart-kit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/vapor/multipart-kit.git", + "state" : { + "revision" : "3498e60218e6003894ff95192d756e238c01f44e", + "version" : "4.7.1" + } + }, + { + "identity" : "routing-kit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/vapor/routing-kit.git", + "state" : { + "revision" : "1a10ccea61e4248effd23b6e814999ce7bdf0ee0", + "version" : "4.9.3" + } + }, + { + "identity" : "swift-algorithms", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-algorithms.git", + "state" : { + "revision" : "87e50f483c54e6efd60e885f7f5aa946cee68023", + "version" : "1.2.1" + } + }, + { + "identity" : "swift-asn1", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-asn1.git", + "state" : { + "revision" : "3b6410f7dee09eb33cdd26260c5fd47fda19b0e2", + "version" : "1.7.3" + } + }, + { + "identity" : "swift-async-algorithms", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-async-algorithms.git", + "state" : { + "revision" : "13713a4ffdee8abd929f92568ee9462a46ae26e0", + "version" : "1.1.7" + } + }, + { + "identity" : "swift-atomics", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-atomics.git", + "state" : { + "revision" : "0442cb5a3f98ab802acb777929fdb446bda11a34", + "version" : "1.3.1" + } + }, + { + "identity" : "swift-certificates", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-certificates.git", + "state" : { + "revision" : "ff86b924ead66f853b8baf91f3c41926a8f36177", + "version" : "1.21.0" + } + }, + { + "identity" : "swift-collections", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-collections.git", + "state" : { + "revision" : "98ef3c98609a1e31b7e157b5b619579001a789d6", + "version" : "1.7.1" + } + }, + { + "identity" : "swift-configuration", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-configuration.git", + "state" : { + "revision" : "3533f65d3e36dcdffc91ce34ef4d3c9c1887fd4b", + "version" : "1.2.1" + } + }, + { + "identity" : "swift-crypto", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-crypto.git", + "state" : { + "revision" : "da9d28d69ebe3894b18376c8f2395c2f37b8448f", + "version" : "4.5.2" + } + }, + { + "identity" : "swift-distributed-tracing", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-distributed-tracing.git", + "state" : { + "revision" : "cc504a45f6ce73ce6067837d7ac19fa67b229a56", + "version" : "1.5.0" + } + }, + { + "identity" : "swift-http-structured-headers", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-http-structured-headers.git", + "state" : { + "revision" : "933538faa42c432d385f02e07df0ace7c5ecfc47", + "version" : "1.7.0" + } + }, + { + "identity" : "swift-http-types", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-http-types.git", + "state" : { + "revision" : "bff4b6903cdc99dda49649dd52f46c11cfd3ed50", + "version" : "1.8.0" + } + }, + { + "identity" : "swift-log", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-log.git", + "state" : { + "revision" : "9c6fb14227f55d8f711ce3847dc2f419fb0ecacb", + "version" : "1.15.1" + } + }, + { + "identity" : "swift-metrics", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-metrics.git", + "state" : { + "revision" : "087e8074afa97040c3b870c8664fe5482fb87cc4", + "version" : "2.11.0" + } + }, + { + "identity" : "swift-nio", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio.git", + "state" : { + "revision" : "21de5f08c1a166a6dd293d0e587ad977bf8dac5d", + "version" : "2.103.0" + } + }, + { + "identity" : "swift-nio-extras", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio-extras.git", + "state" : { + "revision" : "41449336c8ecfadac6b4b5be75f9c3c306e61ced", + "version" : "1.35.1" + } + }, + { + "identity" : "swift-nio-http2", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio-http2.git", + "state" : { + "revision" : "0f3e54e29c944c2e835ad52159da7d9e1c94ac69", + "version" : "1.46.0" + } + }, + { + "identity" : "swift-nio-ssl", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio-ssl.git", + "state" : { + "revision" : "322f3c2a4a21df31c84ca416bf65ee5e9059e440", + "version" : "2.37.5" + } + }, + { + "identity" : "swift-nio-transport-services", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio-transport-services.git", + "state" : { + "revision" : "67787bb645a5e67d2edcdfbe48a216cc549222d5", + "version" : "1.28.0" + } + }, + { + "identity" : "swift-numerics", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-numerics.git", + "state" : { + "revision" : "0c0290ff6b24942dadb83a929ffaaa1481df04a2", + "version" : "1.1.1" + } + }, + { + "identity" : "swift-service-context", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-service-context.git", + "state" : { + "revision" : "d0997351b0c7779017f88e7a93bc30a1878d7f29", + "version" : "1.3.0" + } + }, + { + "identity" : "swift-service-lifecycle", + "kind" : "remoteSourceControl", + "location" : "https://github.com/swift-server/swift-service-lifecycle.git", + "state" : { + "revision" : "7f9326b0326ff86e3646295ea6e891f68c471c5e", + "version" : "2.12.0" + } + }, + { + "identity" : "swift-system", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-system.git", + "state" : { + "revision" : "869129b7bf4ecc57b97d0193ad29690ca2134750", + "version" : "1.8.1" + } + }, + { + "identity" : "vapor", + "kind" : "remoteSourceControl", + "location" : "https://github.com/vapor/vapor.git", + "state" : { + "revision" : "33e61d0a02a9ddc9f025f8398a0dc24774f6cbe1", + "version" : "4.122.2" + } + }, + { + "identity" : "websocket-kit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/vapor/websocket-kit.git", + "state" : { + "revision" : "90bbbdab3ede12c803cfbe91646f291c092517a3", + "version" : "2.16.2" + } + } + ], + "version" : 3 +} diff --git a/Sources/SwiftBackendShit/Errors/wrongPriorityError.swift b/Sources/SwiftBackendShit/Errors/wrongPriorityError.swift new file mode 100644 index 0000000..62c0bb3 --- /dev/null +++ b/Sources/SwiftBackendShit/Errors/wrongPriorityError.swift @@ -0,0 +1,9 @@ + +struct WrongPriorityError: Error { + enum Kind{ + case tooHigh + case tooLow + } + + let kind: Kind +} diff --git a/Sources/SwiftBackendShit/Repository/model.swift b/Sources/SwiftBackendShit/Repository/model.swift new file mode 100644 index 0000000..fa63837 --- /dev/null +++ b/Sources/SwiftBackendShit/Repository/model.swift @@ -0,0 +1,32 @@ + +import Foundation + +class Task { + + let id: UUID = UUID() + + var name: String + var description: String + var priority: Int { + set { + if newValue > 4 { + self.priority = 4 + + } else if newValue < 1 { + self.priority = 1 + + } else { + self.priority = newValue + } + } + get{ + return self.priority + } + } + + init(name: String, description: String, priority: Int){ + self.name = name + self.description = description + self.priority = priority + } +} diff --git a/Sources/SwiftBackendShit/Repository/notDB.swift b/Sources/SwiftBackendShit/Repository/notDB.swift new file mode 100644 index 0000000..250a670 --- /dev/null +++ b/Sources/SwiftBackendShit/Repository/notDB.swift @@ -0,0 +1,18 @@ +import Foundation + +final class NotDB{ + var tasks: [Task] = [] + + func getTasks() -> [Task]{ + return self.tasks + } + + func createTask(task: Task) -> Bool { + do { + self.tasks.append(task) + return true + } catch { + return false + } + } +} diff --git a/Sources/SwiftBackendShit/routes.swift b/Sources/SwiftBackendShit/routes.swift index 2edcc8f..ec5ab35 100644 --- a/Sources/SwiftBackendShit/routes.swift +++ b/Sources/SwiftBackendShit/routes.swift @@ -1,5 +1,9 @@ import Vapor +let superDB: NotDB = NotDB() + +let result = superDB.createTask(task: Task(name: "Test", description: "someTest", priority: 2)) + func routes(_ app: Application) throws { app.get { req async in "It works!" @@ -8,4 +12,14 @@ func routes(_ app: Application) throws { app.get("hello") { req async -> String in "Hello, world!" } + + app.get("tasks") { req async -> [String] in + var list: [String] = [] + for task in superDB.getTasks() { + list.append(task.name) + } + return list + } + + }