Server/src/main/kotlin/dev/fyloz/backup/ApiRouting.kt
2022-06-26 15:46:40 -04:00

51 lines
1.5 KiB
Kotlin

package dev.fyloz.backup
import io.ktor.server.application.*
import io.ktor.server.routing.*
fun Application.configureApiRouting() {
routing {
route("/api/v1") {
configureAccountRoutes()
}
}
}
private fun Route.configureAccountRoutes() {
post("/login") {
// JWT tokens
}
}
private fun Route.configureBackupRoutes() {
route("/backup") {
post("create") {
// Start a new backup
// Returns a backup id and a public key to sign the data
}
post("finish/:id") {
// Finishes the backup with the given id
// Finished backups cannot be edited
}
put(":id") {
// Add a file to the backup with the given id
// The client has to send the file along with a checksums
// The file has to be encrypted with the public key created previously
// For incremental backups, the server will create a diff with the previous version
}
delete("cancel/:id") {
// Cancels the backup with the given id
// Removes all the files and denies the encryption key
}
delete("delete/:id") {
// Deletes the backup with the given id
// An incremental backup can only be deleted if it is the last one, as deleting previous ones will break the newest backups
// The last normal backup cannot be deleted as the incremental backups are be based on it
}
}
}