{"id":13465998,"url":"https://github.com/apodini/corvus","last_synced_at":"2025-03-25T21:31:01.330Z","repository":{"id":47241034,"uuid":"235788568","full_name":"Apodini/corvus","owner":"Apodini","description":"Corvus has been archived in favor of https://github.com/Apodini/Apodini .","archived":true,"fork":false,"pushed_at":"2020-07-21T12:40:23.000Z","size":462,"stargazers_count":39,"open_issues_count":0,"forks_count":6,"subscribers_count":7,"default_branch":"develop","last_synced_at":"2024-10-29T19:14:19.409Z","etag":null,"topics":["backend","corvus","databases","declarative","rest","rest-api","server","swift","vapor"],"latest_commit_sha":null,"homepage":"https://github.com/Apodini/Apodini","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Apodini.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-23T12:17:29.000Z","updated_at":"2024-06-19T22:12:19.000Z","dependencies_parsed_at":"2022-09-03T12:13:44.192Z","dependency_job_id":null,"html_url":"https://github.com/Apodini/corvus","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Apodini%2Fcorvus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Apodini%2Fcorvus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Apodini%2Fcorvus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Apodini%2Fcorvus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Apodini","download_url":"https://codeload.github.com/Apodini/corvus/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245547100,"owners_count":20633292,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","corvus","databases","declarative","rest","rest-api","server","swift","vapor"],"created_at":"2024-07-31T15:00:37.832Z","updated_at":"2025-03-25T21:31:01.030Z","avatar_url":"https://github.com/Apodini.png","language":"Swift","readme":"# Corvus\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"200\" src=\"https://raw.githubusercontent.com/Apodini/corvus/release/images/crow.png\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"https://apodini.github.io/corvus/\"\u003e\n        \u003cimg src=\"http://img.shields.io/badge/read_the-docs-2196f3.svg\" alt=\"Documentation\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"LICENSE\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/license-MIT-brightgreen.svg\" alt=\"MIT License\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/Apodini/corvus/actions\"\u003e\n        \u003cimg src=\"https://github.com/Apodini/corvus/workflows/test/badge.svg?branch=release\" alt=\"Continuous Integration\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://swift.org\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/swift-5.2-brightgreen.svg\" alt=\"Swift 5.2\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n\nCorvus is the first truly declarative server-side framework for Swift. It provides a declarative, composable syntax which makes it easy to get APIs up and running. It is based heavily on the existing work from [Vapor](https://github.com/vapor/vapor).\n\n# Example\n\nBelow is an example of a full-featured API that manages Bank Accounts and Transactions belonging to certain users. It also showcases the ease of using authentication and setting authorization rules for specific routes.\n\n```Swift\nlet xpenseApi = Api(\"api\") {\n    User\u003cCorvusUser\u003e(\"users\")\n    \n    Login\u003cCorvusToken\u003e(\"login\")\n    \n    BearerAuthGroup\u003cCorvusToken\u003e {\n        AccountsEndpoint()\n        TransactionsEndpoint()\n    }\n}\n```\n\nBecause Corvus is composable, it is easy to use a group of components as its own component:\n```Swift\nfinal class AccountsEndpoint: Endpoint {\n    let parameter = Parameter\u003cAccount\u003e()\n    \n    var content: Endpoint {\n        Group(\"accounts\") {\n            Create\u003cAccount\u003e().auth(\\.$user)\n            ReadAll\u003cAccount\u003e().auth(\\.$user)\n            \n            Group(parameter.id) {\n                ReadOne\u003cAccount\u003e(parameter.id).auth(\\.$user)\n                Update\u003cAccount\u003e(parameter.id).auth(\\.$user)\n                Delete\u003cAccount\u003e(parameter.id).auth(\\.$user)\n            }\n        }\n    }\n}\n```\n\n# How to set up\n\nAfter your Swift Project, in the `Package.Swift` file, you will need to add the dependencies \nfor `Corvus` and a `Fluent` database driver of your choice. Below is an example with an \n`SQLite` driver:\n\n```Swift\n// swift-tools-version:5.2\nimport PackageDescription\n\nlet package = Package(\n    name: \"XpenseServer\",\n    platforms: [\n        .macOS(.v10_15)\n    ],\n    products: [\n        .library(name: \"XpenseServer\", targets: [\"XpenseServer\"])\n    ],\n    dependencies: [\n        .package(url: \"https://github.com/Apodini/corvus.git\", from: \"0.0.14\"),\n        .package(url: \"https://github.com/vapor/vapor.git\", from: \"4.0.0\"),\n        .package(url: \"https://github.com/vapor/fluent-sqlite-driver.git\", from: \"4.0.0-rc\")\n    ],\n    targets: [\n        .target(name: \"Run\",\n                dependencies: [\n                    .target(name: \"XpenseServer\")\n                ]),\n        .target(name: \"XpenseServer\",\n                dependencies: [\n                    .product(name: \"Corvus\", package: \"corvus\"),\n                    .product(name: \"FluentSQLiteDriver\", package: \"fluent-sqlite-driver\")\n                ]),\n        .testTarget(name: \"XpenseServerTests\",\n                    dependencies: [\n                        .target(name: \"XpenseServer\"),\n                        .product(name: \"XCTVapor\", package: \"vapor\"),\n                        .product(name: \"FluentSQLiteDriver\", package: \"fluent-sqlite-driver\")\n                    ])\n    ]\n)\n```\n\nAdditionally, under the application's `Source` folder (by default that is `Sources/App`), two setup functions need to be present:\n\n`configure.swift`, in which you can configure middlewares, databases and migrations used\nin the application:\n\n```Swift\nimport Corvus\nimport Vapor\nimport FluentSQLiteDriver\n\npublic func configure(_ app: Application) throws {\n    app.middleware.use(CorvusUser.authenticator())\n    app.middleware.use(CorvusToken.authenticator())\n    \n    app.databases.use(.sqlite(.file(\"db.sqlite\")), as: .sqlite)\n    app.migrations.add(CreateAccount())\n    app.migrations.add(CreateTransaction())\n    app.migrations.add(CreateCorvusUser())\n    app.migrations.add(CreateCorvusToken())\n\n    try app.autoMigrate().wait()\n}\n```\n\nAnd `routes.swift`, which registers the routes from the `Corvus` API:\n```Swift\nimport Corvus\nimport Vapor\n\npublic func routes(_ app: Application) throws {\n    try app.register(collection: xpenseApi)\n}\n```\n\nFinally the application's `main.swift` file (which is usually under the path `Sources/Run`) should look like this:\n\n```Swift\nimport App\nimport Vapor\n\nvar environment = try Environment.detect()\ntry LoggingSystem.bootstrap(from: \u0026environment)\nlet app = Application(environment)\ntry configure(app)\ntry routes(app)\ndefer {\n    app.shutdown()\n}\ntry app.run()\n```\n\n# How to use\n\nIn general, there are two types of building blocks for a `Corvus` API: Group components, which\nallow users to group more groups or concrete endpoints under a common route path, or \ncomponents that provide concrete functionality, like `Create` or `ReadAll`. Check out the \n[docs](https://apodini.github.io/corvus/) and the [example project](https://github.com/Apodini/corvus-example-project) to learn more!\n\n# How to contribute\n\nReview our [contribution guidelines](https://github.com/Apodini/.github/blob/release/CONTRIBUTING.md) for contribution formalities.\n\n# Sources\nThe logo: Made by [Freepik](https://www.flaticon.com/authors/freepik)\n\n[Vapor](https://github.com/vapor/vapor)\n\n[Fluent](https://github.com/vapor/fluent)\n","funding_links":[],"categories":["Libs","Network [🔝](#readme)","REST"],"sub_categories":["Network"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapodini%2Fcorvus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapodini%2Fcorvus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapodini%2Fcorvus/lists"}