fun Route.routeInteractions() { route(interactionPath) { get { call.respond(interactionsCollection.find().toList()) } post { val requested = call.receive() val newInteraction = Interaction(requested.name) interactionsCollection.insertOne(newInteraction) call.respond(HttpStatusCode.OK, newInteraction) } delete("/{id}") { val id = call.parameters["id"]?.toInt() ?: error("Invalid delete request") interactionsCollection.deleteOne(Interaction::id eq id) call.respond(HttpStatusCode.OK) } } }