Blogfy backend REST API is built with Ktor framework with PostgreSQL as database and deployed on the Heroku.
Currently this API is deployed on https://blogfy-server.herokuapp.com
. You can try it 😃.
- If you want to work with your own SDK Admin Firebase take a look here:
- https://levelup.gitconnected.com/how-to-integrate-firebase-authentication-with-ktors-auth-feature-dc2c3893a0cc
- Authentication for email based auth.
- Authentication for Google identity provider (authenticate with Firebase JWT).
- Refresh and revoke Ktor JWT.
- Create, update, and delete blog.
- Check blog author.
- Fetch blogs with pagination.
- Fetch account properties and update account password.
- Send push notifications to android clients.
- Validate requests body and authorization header (custom Ktor JWT challenge).
- Automatic and easy deployment to Heroku.
dev.zlagi.application # Root Package
.
├── application # Ktor application entry point and API routes
| ├── auth
| ├── controller
│ ├── exception
│ ├── model
│ ├── plugins
│ ├── router
│ ├── utils
│ └── Application.Kt
│
|
└── data # Data source and operations.
├── dao
├── database
├── di
├── entity
└── model
- Ktor - Ktor is an asynchronous framework for creating microservices, web applications, and more. It’s fun, free, and open source.
- Firebase Admin - The Admin SDK is a set of server libraries that lets you interact with Firebase.
- One Signal - An Api for Push Notifications, Email, SMS & In-App..
- Exposed - An ORM/SQL framework for Kotlin.
- PostgreSQL JDBC Driver - JDBC Database driver for PostgreSQL.
- HikariCP - High performance JDBC connection pooling.
- Koin - Dependency injection framework.
- jBCrypt - Password hashing algorithm.
- Commons Email - An API for sending email.
POST http://localhost:8080/auth/signup
Content-Type: application/json
{
"email" : "[email protected]",
"username" : "user",
"password": "12346789",
"confirmPassword" : "12346789"
}
POST http://localhost:8080/auth/signin
Content-Type: application/json
{
"email" : "[email protected]",
"password": "12346789"
}
POST http://localhost:8080/auth/idp/google
Content-Type: application/json
Authorization: Bearer YOUR_FIREBASE_AUTH_TOKEN
{
"username" : "user"
}
POST http://localhost:8080/auth/token/refresh
Content-Type: application/json
{
"token" : "token"
}
POST http://localhost:8080/auth/token/revoke
Content-Type: application/json
{
"token" : "token"
}
POST http://localhost:8080/auth/reset-password
Content-Type: application/json
{
"email" : "[email protected]"
}
POST http://localhost:8080/auth/confirm-reset-password?token=KTOR_AUTH_TOKEN
Content-Type: application/json
{
"currentPassword": "oldpassword",
"newPassword": "newpassword",
"confirmNewPassword": "newpassword"
}
GET http://localhost:8080/blog/list
Content-Type: application/json
Authorization: Bearer KTOR_AUTH_TOKEN
GET http://localhost:8080/blog/list?search_query=test&page=2&limit=5
Content-Type: application/json
Authorization: Bearer KTOR_AUTH_TOKEN
POST http://localhost:8080/blog
Content-Type: application/json
Authorization: Bearer KTOR_AUTH_TOKEN
{
"title": "Hey there! This is title",
"description": "Write some description here...",
"creationTime": "Date: 2022-03-07 Time: 22:10:56"
}
PUT http://localhost:8080/blog/BLOG_ID_HERE
Content-Type: application/json
Authorization: Bearer KTOR_AUTH_TOKEN
{
"title": "Updated title!",
"note": "Updated body here...",
"creationTime": "Date: 2022-03-07 Time: 22:20:38"
}
DELETE http://localhost:8080/blog/BLOG_ID_HERE
Content-Type: application/json
Authorization: Bearer KTOR_AUTH_TOKEN
DELETE http://localhost:8080/blog/BLOG_ID_HERE/is_author
Content-Type: application/json
Authorization: Bearer KTOR_AUTH_TOKEN
POST http://localhost:8080/blog/notification
Content-Type: application/json
Authorization: Bearer KTOR_AUTH_TOKEN
Get http://localhost:8080/account
Content-Type: application/json
Authorization: Bearer KTOR_AUTH_TOKEN
PUT http://localhost:8080/account/password
Content-Type: application/json
Authorization: Bearer KTOR_AUTH_TOKEN
{
"currentPassword": "oldpassword",
"newPassword": "newpassword",
"confirmNewPassword": "newpassword"
}
This is project is a sample, to inspire you and should handle most of the common cases, but please take a look at additional resources.
Other high-quality projects will help you to find solutions that work for your project:
- Bug fixes and Pull Requests are highly appreciated and you're more than welcome to send us your feedbacks <3
Copyright 2022 Haythem Mejerbi.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.