├── .github └── workflows │ ├── deploy-preview.yml │ └── deploy-prod.yml ├── .gitignore ├── .swift-format ├── .swiftpm └── xcode │ └── xcshareddata │ └── xcschemes │ └── vercel-starter-kit.xcscheme ├── Package.resolved ├── Package.swift ├── README.md ├── Sources └── App │ └── App.swift ├── public └── robots.txt └── vercel.json /.github/workflows/deploy-preview.yml: -------------------------------------------------------------------------------- 1 | name: Vercel Preview 2 | 3 | on: 4 | workflow_dispatch: 5 | pull_request: 6 | 7 | env: 8 | VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} 9 | VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} 10 | VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} 11 | 12 | jobs: 13 | deploy: 14 | runs-on: ubuntu-latest 15 | container: swift:5.10-amazonlinux2 16 | 17 | steps: 18 | - uses: actions/checkout@v3 19 | 20 | - uses: actions/cache@v3 21 | with: 22 | path: .build 23 | key: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }} 24 | restore-keys: | 25 | ${{ runner.os }}-spm- 26 | 27 | - uses: actions/setup-node@v3 28 | with: 29 | node-version: 16 30 | 31 | - name: Install 32 | run: npm install -g vercel@latest 33 | 34 | - name: Deploy 35 | run: swift package --disable-sandbox vercel deploy 36 | -------------------------------------------------------------------------------- /.github/workflows/deploy-prod.yml: -------------------------------------------------------------------------------- 1 | name: Vercel Prod 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | env: 9 | VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} 10 | VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} 11 | VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} 12 | 13 | jobs: 14 | deploy: 15 | runs-on: ubuntu-latest 16 | container: swift:5.10-amazonlinux2 17 | 18 | steps: 19 | - uses: actions/checkout@v3 20 | 21 | - uses: actions/cache@v3 22 | with: 23 | path: .build 24 | key: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }} 25 | restore-keys: | 26 | ${{ runner.os }}-spm- 27 | 28 | - uses: actions/setup-node@v3 29 | with: 30 | node-version: 16 31 | 32 | - name: Install 33 | run: npm install -g vercel@latest 34 | 35 | - name: Deploy 36 | run: swift package --disable-sandbox vercel deploy --prod 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.build 3 | /Packages 4 | /*.xcodeproj 5 | xcuserdata/ 6 | DerivedData/ 7 | .swiftpm/config/registries.json 8 | .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata 9 | .netrc 10 | .vercel 11 | .vscode 12 | .env 13 | -------------------------------------------------------------------------------- /.swift-format: -------------------------------------------------------------------------------- 1 | { 2 | "indentation" : { 3 | "spaces": 4 4 | }, 5 | "tabWidth": 4, 6 | "version": 1 7 | } -------------------------------------------------------------------------------- /.swiftpm/xcode/xcshareddata/xcschemes/vercel-starter-kit.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 42 | 44 | 50 | 51 | 52 | 53 | 57 | 58 | 59 | 60 | 66 | 68 | 74 | 75 | 76 | 77 | 79 | 80 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "pins" : [ 3 | { 4 | "identity" : "async-http-client", 5 | "kind" : "remoteSourceControl", 6 | "location" : "https://github.com/swift-server/async-http-client.git", 7 | "state" : { 8 | "revision" : "291438696abdd48d2a83b52465c176efbd94512b", 9 | "version" : "1.20.1" 10 | } 11 | }, 12 | { 13 | "identity" : "async-kit", 14 | "kind" : "remoteSourceControl", 15 | "location" : "https://github.com/vapor/async-kit.git", 16 | "state" : { 17 | "revision" : "7ece208cd401687641c88367a00e3ea2b04311f1", 18 | "version" : "1.19.0" 19 | } 20 | }, 21 | { 22 | "identity" : "console-kit", 23 | "kind" : "remoteSourceControl", 24 | "location" : "https://github.com/vapor/console-kit.git", 25 | "state" : { 26 | "revision" : "a31f44ebfbd15a2cc0fda705279676773ac16355", 27 | "version" : "4.14.1" 28 | } 29 | }, 30 | { 31 | "identity" : "multipart-kit", 32 | "kind" : "remoteSourceControl", 33 | "location" : "https://github.com/vapor/multipart-kit.git", 34 | "state" : { 35 | "revision" : "12ee56f25bd3fc4c2d09c2aa16e69de61dc786e8", 36 | "version" : "4.6.0" 37 | } 38 | }, 39 | { 40 | "identity" : "routing-kit", 41 | "kind" : "remoteSourceControl", 42 | "location" : "https://github.com/vapor/routing-kit.git", 43 | "state" : { 44 | "revision" : "2a92a7eac411a82fb3a03731be5e76773ebe1b3e", 45 | "version" : "4.9.0" 46 | } 47 | }, 48 | { 49 | "identity" : "swift-algorithms", 50 | "kind" : "remoteSourceControl", 51 | "location" : "https://github.com/apple/swift-algorithms.git", 52 | "state" : { 53 | "revision" : "f6919dfc309e7f1b56224378b11e28bab5bccc42", 54 | "version" : "1.2.0" 55 | } 56 | }, 57 | { 58 | "identity" : "swift-atomics", 59 | "kind" : "remoteSourceControl", 60 | "location" : "https://github.com/apple/swift-atomics.git", 61 | "state" : { 62 | "revision" : "cd142fd2f64be2100422d658e7411e39489da985", 63 | "version" : "1.2.0" 64 | } 65 | }, 66 | { 67 | "identity" : "swift-aws-lambda-runtime", 68 | "kind" : "remoteSourceControl", 69 | "location" : "https://github.com/swift-server/swift-aws-lambda-runtime", 70 | "state" : { 71 | "revision" : "8d9f44b7838750b103ad2ad49055e8333d719e8a", 72 | "version" : "1.0.0-alpha.2" 73 | } 74 | }, 75 | { 76 | "identity" : "swift-collections", 77 | "kind" : "remoteSourceControl", 78 | "location" : "https://github.com/apple/swift-collections.git", 79 | "state" : { 80 | "revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb", 81 | "version" : "1.1.0" 82 | } 83 | }, 84 | { 85 | "identity" : "swift-crypto", 86 | "kind" : "remoteSourceControl", 87 | "location" : "https://github.com/apple/swift-crypto", 88 | "state" : { 89 | "revision" : "f0525da24dc3c6cbb2b6b338b65042bc91cbc4bb", 90 | "version" : "3.3.0" 91 | } 92 | }, 93 | { 94 | "identity" : "swift-http-types", 95 | "kind" : "remoteSourceControl", 96 | "location" : "https://github.com/apple/swift-http-types", 97 | "state" : { 98 | "revision" : "12358d55a3824bd5fed310b999ea8cf83a9a1a65", 99 | "version" : "1.0.3" 100 | } 101 | }, 102 | { 103 | "identity" : "swift-log", 104 | "kind" : "remoteSourceControl", 105 | "location" : "https://github.com/apple/swift-log.git", 106 | "state" : { 107 | "revision" : "e97a6fcb1ab07462881ac165fdbb37f067e205d5", 108 | "version" : "1.5.4" 109 | } 110 | }, 111 | { 112 | "identity" : "swift-metrics", 113 | "kind" : "remoteSourceControl", 114 | "location" : "https://github.com/apple/swift-metrics.git", 115 | "state" : { 116 | "revision" : "971ba26378ab69c43737ee7ba967a896cb74c0d1", 117 | "version" : "2.4.1" 118 | } 119 | }, 120 | { 121 | "identity" : "swift-nio", 122 | "kind" : "remoteSourceControl", 123 | "location" : "https://github.com/apple/swift-nio.git", 124 | "state" : { 125 | "revision" : "fc63f0cf4e55a4597407a9fc95b16a2bc44b4982", 126 | "version" : "2.64.0" 127 | } 128 | }, 129 | { 130 | "identity" : "swift-nio-extras", 131 | "kind" : "remoteSourceControl", 132 | "location" : "https://github.com/apple/swift-nio-extras.git", 133 | "state" : { 134 | "revision" : "a3b640d7dc567225db7c94386a6e71aded1bfa63", 135 | "version" : "1.22.0" 136 | } 137 | }, 138 | { 139 | "identity" : "swift-nio-http2", 140 | "kind" : "remoteSourceControl", 141 | "location" : "https://github.com/apple/swift-nio-http2.git", 142 | "state" : { 143 | "revision" : "0904bf0feb5122b7e5c3f15db7df0eabe623dd87", 144 | "version" : "1.30.0" 145 | } 146 | }, 147 | { 148 | "identity" : "swift-nio-ssl", 149 | "kind" : "remoteSourceControl", 150 | "location" : "https://github.com/apple/swift-nio-ssl.git", 151 | "state" : { 152 | "revision" : "7c381eb6083542b124a6c18fae742f55001dc2b5", 153 | "version" : "2.26.0" 154 | } 155 | }, 156 | { 157 | "identity" : "swift-nio-transport-services", 158 | "kind" : "remoteSourceControl", 159 | "location" : "https://github.com/apple/swift-nio-transport-services.git", 160 | "state" : { 161 | "revision" : "6cbe0ed2b394f21ab0d46b9f0c50c6be964968ce", 162 | "version" : "1.20.1" 163 | } 164 | }, 165 | { 166 | "identity" : "swift-numerics", 167 | "kind" : "remoteSourceControl", 168 | "location" : "https://github.com/apple/swift-numerics", 169 | "state" : { 170 | "revision" : "0a5bc04095a675662cf24757cc0640aa2204253b", 171 | "version" : "1.0.2" 172 | } 173 | }, 174 | { 175 | "identity" : "swift-system", 176 | "kind" : "remoteSourceControl", 177 | "location" : "https://github.com/apple/swift-system.git", 178 | "state" : { 179 | "revision" : "025bcb1165deab2e20d4eaba79967ce73013f496", 180 | "version" : "1.2.1" 181 | } 182 | }, 183 | { 184 | "identity" : "vapor", 185 | "kind" : "remoteSourceControl", 186 | "location" : "https://github.com/vapor/vapor", 187 | "state" : { 188 | "revision" : "11cdb29614a5c7f8c5289f3c97b3398c3d89b395", 189 | "version" : "4.92.5" 190 | } 191 | }, 192 | { 193 | "identity" : "vercel", 194 | "kind" : "remoteSourceControl", 195 | "location" : "https://github.com/swift-cloud/Vercel", 196 | "state" : { 197 | "branch" : "main", 198 | "revision" : "081a50f8d052d39b911af8ee3490488ad4401078" 199 | } 200 | }, 201 | { 202 | "identity" : "websocket-kit", 203 | "kind" : "remoteSourceControl", 204 | "location" : "https://github.com/vapor/websocket-kit.git", 205 | "state" : { 206 | "revision" : "4232d34efa49f633ba61afde365d3896fc7f8740", 207 | "version" : "2.15.0" 208 | } 209 | } 210 | ], 211 | "version" : 2 212 | } 213 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version: 5.10 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "vercel-starter-kit", 7 | platforms: [ 8 | .macOS(.v12) 9 | ], 10 | dependencies: [ 11 | .package(url: "https://github.com/swift-cloud/Vercel", branch: "main") 12 | ], 13 | targets: [ 14 | .executableTarget(name: "App", dependencies: ["Vercel"]) 15 | ] 16 | ) 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vercel-starter-kit 2 | 3 | A starter kit for deploying Swift to Vercel. 4 | 5 | [https://swift-starter-kit.vercel.app](https://swift-starter-kit.vercel.app) 6 | -------------------------------------------------------------------------------- /Sources/App/App.swift: -------------------------------------------------------------------------------- 1 | import Vercel 2 | 3 | @main 4 | struct App: RequestHandler { 5 | 6 | func onRequest(_ req: Request) async throws -> Response { 7 | return .status(.ok).send("Hello, Swift") 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Allow: / 3 | -------------------------------------------------------------------------------- /vercel.json: -------------------------------------------------------------------------------- 1 | { 2 | "buildCommand": "swift package --disable-sandbox vercel", 3 | "crons": [ 4 | { 5 | "path": "/api/cron", 6 | "schedule": "0 5 * * *" 7 | } 8 | ] 9 | } 10 | --------------------------------------------------------------------------------