This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Part 1: Build the app using Maven | |
FROM maven:3.6.0-jdk-8-alpine | |
## download dependencies | |
ADD pom.xml / | |
RUN mvn verify clean | |
## build after dependencies are down so it wont redownload unless the POM changes | |
ADD . / | |
RUN mvn package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package codemwnci.bootsocket | |
import com.fasterxml.jackson.databind.ObjectMapper | |
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper | |
import org.springframework.boot.autoconfigure.SpringBootApplication | |
import org.springframework.boot.runApplication | |
import org.springframework.context.annotation.Configuration | |
import org.springframework.web.socket.* | |
import org.springframework.web.socket.config.annotation.* | |
import org.springframework.web.socket.handler.TextWebSocketHandler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Chat - Websocket Kotlin</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | |
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
ext { | |
kotlinVersion = '1.2.10' | |
springBootVersion = '2.0.0.M7' | |
} | |
repositories { | |
mavenCentral() | |
maven { url "https://repo.spring.io/snapshot" } | |
maven { url "https://repo.spring.io/milestone" } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package codemwnci.kotlinspringboot | |
import org.springframework.data.jpa.repository.JpaRepository | |
import org.springframework.web.bind.annotation.* | |
import javax.persistence.* | |
import java.time.Instant | |
@RestController @RequestMapping(value = "/todo") | |
class TodoResources(val todoRepo: TodoReposiory) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package codemwnci | |
import spark.Spark.* | |
import kotliquery.* | |
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper | |
import java.time.LocalDateTime | |
fun main(args: Array<String>) { | |
setupDB() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
toggleCheck: function(todo) { | |
todo.done = !todo.done; | |
this.update(todo); | |
}, | |
update: function(todo) { | |
axios.put("http://localhost:9000/todo/"+todo.id, {"text": todo.text, "done": todo.done}).then(response => { | |
for(var i = this.todos.length; i--;){ | |
if (this.todos[i].id === todo.id) { | |
this.todos[i].done = response.data.done; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<li v-for="todo in todos"> | |
<input type="checkbox" :checked="todo.done" @click="toggleCheck(todo)"> | |
{{todo.text}} | |
<a href="#" v-if="todo.done" @click="deleteTodo(todo.id)">(delete)</a> | |
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deleteTodo: function(id) { | |
axios.delete("http://localhost:9000/todo/"+id).then(response => { | |
if (response.data = "ok") { | |
for(var i = this.todos.length; i--;){ | |
if (this.todos[i].id === id) this.todos.splice(i, 1); | |
} | |
} | |
}); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mounted() { | |
axios.get('http://localhost:9000/todo/').then(response => { | |
this.todos = response.data; | |
}); | |
} |
NewerOlder