Add ktlint config
This commit is contained in:
@@ -44,7 +44,6 @@ val mainModule = DI.Module("main") {
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
bind<SimpleJWT>(tag = "auth") with singleton { simpleJwtFactory(instance<Config>().jwt.auth) }
|
||||
bind<SimpleJWT>(tag = "refresh") with singleton { simpleJwtFactory(instance<Config>().jwt.refresh) }
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.kodein.di.instance
|
||||
import org.slf4j.Logger
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
|
||||
fun main() {
|
||||
val di = DI { import(mainModule) }
|
||||
val config by di.instance<Config>()
|
||||
@@ -41,7 +40,6 @@ fun serve(di: DI) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun Application.module(di: DI) {
|
||||
val builders: Set<ApplicationBuilder> by di.instance()
|
||||
|
||||
|
||||
@@ -7,4 +7,4 @@ import io.ktor.auth.*
|
||||
* @property username
|
||||
* @property password
|
||||
*/
|
||||
data class UsernamePasswordCredential(val username: String, val password: String) : Credential
|
||||
data class UsernamePasswordCredential(val username: String, val password: String) : Credential
|
||||
|
||||
@@ -8,4 +8,4 @@ interface Tag : Entity<Tag> {
|
||||
val id: Int
|
||||
var name: String
|
||||
var note: Note
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import io.ktor.response.*
|
||||
import io.ktor.utils.io.errors.*
|
||||
import java.sql.SQLTransientConnectionException
|
||||
|
||||
|
||||
class ErrorHandler : ApplicationBuilder({
|
||||
install(StatusPages) {
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ fun StatusPages.Configuration.jacksonErrors() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class InvalidFormatError(val value: Any?, targetType: Class<*>) {
|
||||
val msg = "Wrong type"
|
||||
val required = targetType.simpleName
|
||||
|
||||
@@ -8,7 +8,6 @@ import kotlinx.coroutines.launch
|
||||
import org.flywaydb.core.Flyway
|
||||
import javax.sql.DataSource
|
||||
|
||||
|
||||
class MigrationHook(migration: Migration) : ApplicationBuilder({
|
||||
environment.monitor.subscribe(ApplicationStarted) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
|
||||
@@ -29,7 +29,6 @@ class NoteRoutes(noteService: NoteService) : RoutingBuilder({
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
private fun Route.createNote(noteService: NoteService) {
|
||||
post {
|
||||
val userId = call.authenticatedUserId()
|
||||
@@ -42,7 +41,7 @@ private fun Route.createNote(noteService: NoteService) {
|
||||
private fun Route.getAllNotes(noteService: NoteService) {
|
||||
get {
|
||||
val userId = call.authenticatedUserId()
|
||||
val limit = call.parameters["limit"]?.toInt() ?: 20// FIXME validate
|
||||
val limit = call.parameters["limit"]?.toInt() ?: 20 // FIXME validate
|
||||
val after = call.parameters["after"]?.let { UUID.fromString(it) } // FIXME validate
|
||||
val notes = noteService.findAll(userId, limit, after)
|
||||
call.respond(notes)
|
||||
|
||||
@@ -59,7 +59,6 @@ private fun Route.deleteUser(userService: UserService) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun Route.createUser(userService: UserService) {
|
||||
post {
|
||||
val user = call.receiveValidated(registerValidator)
|
||||
@@ -74,7 +73,6 @@ private fun Route.createUser(userService: UserService) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun Route.login(
|
||||
userService: UserService,
|
||||
passwordHash: PasswordHash,
|
||||
@@ -99,7 +97,6 @@ private fun Route.login(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun Route.refreshToken(userService: UserService, authJWT: SimpleJWT, refreshJWT: SimpleJWT) {
|
||||
post {
|
||||
val token = call.receive<RefreshToken>().refreshToken
|
||||
|
||||
@@ -61,7 +61,6 @@ class NoteService(private val db: Database) {
|
||||
db.sequenceOf(Notes, withReferences = false).any { it.userId eq userId and (it.uuid eq uuid) }
|
||||
}
|
||||
|
||||
|
||||
suspend fun create(userId: Int, note: Note): Note = launchIo {
|
||||
val uuid = UUID.randomUUID()
|
||||
val newNote = note.copy().apply {
|
||||
@@ -79,7 +78,6 @@ class NoteService(private val db: Database) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
newNote
|
||||
}
|
||||
@@ -126,7 +124,6 @@ class NoteService(private val db: Database) {
|
||||
it.noteUuid to note.uuid
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ class UserService(private val db: Database, private val passwordHash: PasswordHa
|
||||
.find { it.id eq id }
|
||||
}
|
||||
|
||||
|
||||
suspend fun exists(username: String) = launchIo {
|
||||
db.sequenceOf(Users, withReferences = false)
|
||||
.any { it.username eq username }
|
||||
@@ -65,6 +64,4 @@ class UserService(private val db: Database, private val passwordHash: PasswordHa
|
||||
else -> error("??")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user