Migration done for the backend
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package be.vandewalleh.routing
|
||||
|
||||
import be.vandewalleh.extensions.noteTitle
|
||||
import be.vandewalleh.extensions.receiveNoteCreate
|
||||
import be.vandewalleh.extensions.respondStatus
|
||||
import be.vandewalleh.extensions.userId
|
||||
import be.vandewalleh.services.NotesService
|
||||
import io.ktor.application.*
|
||||
@@ -25,16 +23,9 @@ fun Routing.notes(kodein: Kodein) {
|
||||
|
||||
post("/notes") {
|
||||
val userId = call.userId()
|
||||
val noteUuid = call.parameters.noteTitle()
|
||||
val note = call.receiveNoteCreate()
|
||||
val exists = notesService.noteExistsWithTitle(userId, note.title)
|
||||
|
||||
if (exists) {
|
||||
return@post call.respondStatus(HttpStatusCode.Conflict)
|
||||
}
|
||||
|
||||
notesService.createNote(userId, note.title, note.tags)
|
||||
call.respondStatus(HttpStatusCode.Created)
|
||||
val uuid = notesService.createNote(userId, note)
|
||||
call.respond(HttpStatusCode.Created, mapOf("uuid" to uuid))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ fun Routing.title(kodein: Kodein) {
|
||||
val noteUuid = call.parameters.noteUuid()
|
||||
|
||||
val exists = notesService.noteExists(userId, noteUuid)
|
||||
if (exists) return@get call.respondStatus(HttpStatusCode.NotFound)
|
||||
if (!exists) return@get call.respondStatus(HttpStatusCode.NotFound)
|
||||
|
||||
val response = notesService.getNote(noteUuid)
|
||||
call.respond(response)
|
||||
|
||||
Reference in New Issue
Block a user