Add HikaryCP to pool db connections
This commit is contained in:
parent
6fbb7f7050
commit
9986e7a2d2
1
.gitignore
vendored
1
.gitignore
vendored
@ -118,3 +118,4 @@ dist
|
||||
|
||||
# Service worker
|
||||
sw.*
|
||||
*.private.env.json
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
# Register a new user
|
||||
POST http://localhost:8081/login
|
||||
POST http://localhost:8081/user/login
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"username": "hubert",
|
||||
"password": "test"
|
||||
"username": "{{username}}",
|
||||
"password": "{{password}}"
|
||||
}
|
||||
|
||||
> {%
|
||||
@ -23,32 +23,3 @@ client.test("Request executed successfully", function() {
|
||||
client.assert(response.status === 200, "Response status is not 200");
|
||||
});
|
||||
%}
|
||||
|
||||
### Create a note
|
||||
POST http://localhost:8081/notes/tortue
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
{
|
||||
"tags": [
|
||||
"Dev",
|
||||
"Server"
|
||||
]
|
||||
}
|
||||
|
||||
> {%
|
||||
client.test("Request executed successfully", function() {
|
||||
client.assert(response.status === 201, "Response status is not 200");
|
||||
});
|
||||
%}
|
||||
|
||||
### Read a note
|
||||
GET http://localhost:8081/notes/babar
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
> {%
|
||||
client.test("Request executed successfully", function() {
|
||||
client.assert(response.status === 200, "Response status is not 200");
|
||||
});
|
||||
%}
|
||||
|
||||
@ -128,6 +128,11 @@
|
||||
<artifactId>jbcrypt</artifactId>
|
||||
<version>${jbcrypt_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>3.4.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src</sourceDirectory>
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
package be.vandewalleh.features
|
||||
|
||||
import be.vandewalleh.auth.SimpleJWT
|
||||
import com.zaxxer.hikari.HikariConfig
|
||||
import com.zaxxer.hikari.HikariDataSource
|
||||
import io.ktor.application.*
|
||||
import org.kodein.di.Kodein
|
||||
import org.kodein.di.generic.bind
|
||||
import org.kodein.di.generic.instance
|
||||
import org.mariadb.jdbc.MariaDbDataSource
|
||||
import javax.sql.DataSource
|
||||
|
||||
/**
|
||||
@ -18,15 +19,14 @@ fun Application.configurationFeature() {
|
||||
val host = property("database.host").getString()
|
||||
val port = property("database.port").getString()
|
||||
val name = property("database.name").getString()
|
||||
val user = property("database.user").getString()
|
||||
val password = property("database.password").getString()
|
||||
|
||||
val url = "jdbc:mariadb://$host:$port/$name"
|
||||
|
||||
MariaDbDataSource(url).apply {
|
||||
this.user = user
|
||||
setPassword(password)
|
||||
val hikariConfig = HikariConfig().apply {
|
||||
jdbcUrl = "jdbc:mariadb://$host:$port/$name"
|
||||
username = this@with.property("database.user").getString()
|
||||
password = this@with.property("database.password").getString()
|
||||
}
|
||||
|
||||
HikariDataSource(hikariConfig)
|
||||
}
|
||||
|
||||
val simpleJwt = SimpleJWT(environment.config.property("jwt.secret").getString())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user