{"id":18936389,"url":"https://github.com/vaporexampleslab/vaporapiwebtemplate","last_synced_at":"2026-03-21T03:30:15.903Z","repository":{"id":133101683,"uuid":"107157822","full_name":"VaporExamplesLab/VaporApiWebTemplate","owner":"VaporExamplesLab","description":"A starting point for vapor api (Fluent) + web (Leaf) applications.","archived":false,"fork":false,"pushed_at":"2019-06-30T22:33:54.000Z","size":131,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-31T21:26:11.455Z","etag":null,"topics":["swift","template","vapor","vapor-template"],"latest_commit_sha":null,"homepage":"","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/VaporExamplesLab.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-16T17:05:54.000Z","updated_at":"2019-10-28T13:59:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"c7936460-3cee-4d54-bb0c-71ad5142644c","html_url":"https://github.com/VaporExamplesLab/VaporApiWebTemplate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VaporExamplesLab%2FVaporApiWebTemplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VaporExamplesLab%2FVaporApiWebTemplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VaporExamplesLab%2FVaporApiWebTemplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VaporExamplesLab%2FVaporApiWebTemplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VaporExamplesLab","download_url":"https://codeload.github.com/VaporExamplesLab/VaporApiWebTemplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239937702,"owners_count":19721482,"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":["swift","template","vapor","vapor-template"],"created_at":"2024-11-08T12:07:15.883Z","updated_at":"2026-03-21T03:30:15.844Z","avatar_url":"https://github.com/VaporExamplesLab.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"README_files/AWT.png\" width=\"480\" alt=\"API + Web Template\"\u003e\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \u003ca href=\"http://docs.vapor.codes/3.0/\"\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=\"http://img.shields.io/badge/license-MIT-brightgreen.svg\" alt=\"MIT License\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://swift.org\"\u003e\n        \u003cimg src=\"http://img.shields.io/badge/swift-4.2-brightgreen.svg\" alt=\"Swift 4.2\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e NOTE: After an Xcode update to Swift 4.2, `NIO`, `NIOFoundationCompat`, `NIOHTTP1`, and `NIOHTTP1` warnings can be silenced by setting the `SWIFT_VERSION` to \"Swift 4\" in the Target build settings. \n\n\u003ca id=toc\u003e\u003c/a\u003e\n[Example Routes](#ExampleRoutes) • \n[Components](#Components) • \n[Use](#Use) • \n[Resources](#Resources)\n\n`VaporApiWebTemplate` is an API + Web Template (AWT) hybrid based on [vapor/api-template](https://github.com/vapor/api-template) and [vapor/web-template](https://github.com/vapor/web-template).  `VaporApiWebTemplate` template uses Vapor 3, Swift 4.1 and Xcode 9.\n\n`VaporApiWebTemplate` also includes a set of lightweight examples: \n\n* api routes which use SQLite (`TextpostApiController`, `Textpost`)\n* web page routes which serve static files from \"Public/\" (`FileMiddleware` enabled)\n* web page routes which use Leaf templating (`LeafWebController`)\n* simple custom `Middleware` (`ExampleMiddleware`)\n* simple custom `Service` (`ExampleService`, `ExampleFortuneService`, `ExampleQuoteService`, `ExampleServiceProvider`)\n* UUID extension for RFC 4122 compliance\n* `XCTest` unit test examples\n\n## Example Routes \u003ca id=\"ExampleRoutes\"\u003e\u003c/a\u003e[▴](#toc)\n\nExample routes setup in the baseline template.\n\n**Basic**\n\n`http://localhost:8080/hello`\n\n```\nHello, world!\n```  \n\n`http://localhost:8080/hellojson`  \n\n``` JSON\n{\"hello\":\"world\"}\n```\n\n`http://localhost:8080/info`  \n\nReturns a description of http request.\n\n``` http\nGET /api/info HTTP/1.1\nHost: localhost:8080\nAccept: */*\nAccept-Language: en-US,en;q=0.5\nAccept-Encoding: gzip, deflate\nConnection: keep-alive\nUser-Agent: …\n\u003cno body\u003e\n```\n\n**Dynamic API (Fluent)**\n\n* `/api/textposts` POST creates one database entry for valid JSON `Textpost`.\n* `/api/textposts` GET returns an array of all available `Textpost`\n* `/api/textposts/uuid` GET returns one specific `Textpost`\n* `/api/textposts` PUT updates an existing `Textpost` or create a new `Textpost`. \n* `/api/textposts/uuid` PATCH applies partial update modification to specific `Textpost` entry.\n* `/api/textposts/uuid` DELETE removes one specific `Textpost`.\n\n**Static HTML**\n\n* `http://localhost:8080/` redirects to '/index.html'.\n* `http://localhost:8080/index.html` minimal HTML 5.\n\n**Web HTML Templates (Leaf)**\n\n* `http://localhost:8080/leaf` simple leaf example.  \n* `http://localhost:8080/leaf/hello`\n* `http://localhost:8080/leaf/hello/Sunshine` leaf with a `String` parameter.\n\n\n``` markup\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n\t\u003ctitle\u003eHello, Sunshine!\u003c/title\u003e\n\t\u003clink rel=\"stylesheet\" href=\"/styles/app.css\"\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003ch1\u003eHello, Sunshine!\u003c/h1\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n* `http://localhost:8080/leaf/bootstrap` example page with Bootstrap, Swift data objects and Leaf. \n\n## Components  \u003ca id=\"Components\"\u003e\u003c/a\u003e[▴](#toc)\n\n### API Fluent\n\n```\nSources/App/\n  Controllers/\n    TextpostController.swift\n  Models/\n    Textpost.swift\nTests/AppTests/\n  TextpostControllerTests.swift\n```\n\n### Web Leaf Template\n\nLeaf templating components.\n\n```\nSources/App/\n  Controllers/\n    LeafWebController.swift\n  Public/\n    images/it-works.png\n    scripts/.gitkeep\n    styles/app.css\n  Resources/\n    Views/\n      bootstrap_web.leaf\n      bootstrap_welcome.leaf\n      web_base.leaf\n      web_hello.leaf\nTests/AppTests/\n  LeafWebControllerTests.swift\n```\n\n## Use \u003ca id=\"Use\"\u003e\u003c/a\u003e[▴](#toc)\n\n``` bash\nvapor new PROJECT_NAME --template=marc-medley/004.77_VaporApiWebTemplate\ncd PROJECT_NAME\nvapor update\n```\n\nSet the Xcode active scheme to `Run \u003e My Mac`.\n\n![](README_files/XcodeSchemeSetting.png)\n\n## Resources \u003ca id=\"Resources\"\u003e\u003c/a\u003e[▴](#toc)\n\n[Atom: language-leaf ⇗](https://atom.io/packages/language-leaf)  \n[Mac App Store: RESTed - Simple HTTP Requests ⇗](https://itunes.apple.com/us/app/rested-simple-http-requests/id421879749) _…free._\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaporexampleslab%2Fvaporapiwebtemplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvaporexampleslab%2Fvaporapiwebtemplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaporexampleslab%2Fvaporapiwebtemplate/lists"}