A simple and efficient backend starter project built with Swift using the Vapor framework. This project provides a foundation for building RESTful APIs with essential configurations, authentication, and database integration.
- ✅ Built with Swift and Vapor
- ✅ RESTful API structure
- ✅ Authentication & JWT support
- ✅ Database integration (PostgreSQL/MySQL/SQLite)
- ✅ Environment configuration handling
- ✅ Dependency injection with
Service
- ✅ Middleware support
- ✅ Docker support (optional)
- Install Swift
- Install Vapor Toolbox
- Setup your preferred database (PostgreSQL, MySQL, or SQLite)
-
Clone the repository:
git clone https://github.com/sinakhanjani/vapor-starter-kit-backend-in-swift.git cd vapor-starter-kit-backend-in-swift
-
Install dependencies:
swift package update swift package resolve
-
Setup environment variables:
cp .env.example .env
Edit
.env
and configure your database credentials. -
Run migrations (if applicable):
vapor run migrate
-
Start the server:
vapor run serve
The API will be available at
http://localhost:8080
.
├── Sources/
│ ├── App/
│ │ ├── Controllers/
│ │ ├── Models/
│ │ ├── Config/
│ │ ├── Routes.swift
│ │ ├── Middleware.swift
│ │ ├── main.swift
│ ├── Run/
│ │ ├── main.swift
├── Public/
├── Resources/
├── Tests/
├── Package.swift
├── README.md
Method | Endpoint | Description |
---|---|---|
GET | /api/ping |
Health check |
POST | /api/login |
User authentication |
GET | /api/users |
List all users |
POST | /api/users |
Create a new user |
Contributions are welcome! Feel free to open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE
file for details.
For any questions, reach out to @sinakhanjani.