./gradlew clean run
Launch the tests:
./gradlew clean test
Package your application:
./gradlew clean assemble
Go to http://localhost:8000.
Healthcheck
curl -i -H 'accept: application/json' http://localhost:8000/ping
Response
{
"status": "UP",
"checks": [
{
"id": "App connection",
"status": "UP"
}
],
"outcome": "UP"
}
Get user by id
curl -i -H 'accept: application/json' http://localhost:8000/users/1
Response
{
"id": 1,
"name": "smol"
}
Go to http://localhost:9000.
Use protobuf schema from User.proto.
service UserService {
rpc GetUser (GetUserRequest) returns (GetUserResponse) {}
}
message User {
int64 id = 1;
string name = 2;
}
message GetUserRequest {
int64 id = 1;
}
message GetUserResponse {
User user = 1;
}
GetUserRequest
{ "id": 1 }
GetUserResponse
{
"user": {
"id": "1",
"name": "smol"
}
}
Go to http://localhost:3306.
Run mysql container:
docker run --name backend-mysql -d \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=password \
-v mysql:/var/lib/mysql \
mysql:8
Create database and table:
docker exec -it backend-mysql bash
create database backend;
use backend;
CREATE TABLE IF NOT EXISTS `user` (
`id` BINARY(16) PRIMARY KEY NOT NULL DEFAULT (UUID_TO_BIN(UUID())),
`account_id` BIGINT(20) NOT NULL,
`name` VARCHAR(255) NOT NULL,
`created_at` DATETIME(3) DEFAULT CURRENT_TIMESTAMP(3),
`updated_at` DATETIME(3) DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
UNIQUE KEY `unique_name_index` (`account_id`, `name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
INSERT INTO `user` (`account_id`, `name`)VALUES (1, "smol");
user
Column | Type | Not Null | Default | Description |
---|---|---|---|---|
id | binary | yes | UUID in binary format | The ID of the user. This is 128-bit UUID stored in 16-bit binary format. |
account_id | bigint(20) | yes | The name of the user. This is a string with a maximum length of 255 characters. | |
name | varchar(255) | yes | The name of the user. This is a string with a maximum length of 255 characters. | |
created_at | datetime | yes | CURRENT_TIMESTAMP | The date and time the user was created. |
updated_at | datetime | yes | CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP | The date and time the user was last updated. |
Part 1. https://dev.to/smolthing/build-web-application-in-vertx-part-1-3jc4[Build web application in Vert.x] git log