Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .schema.sql.swp
Binary file not shown.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM openjdk:8-jdk-alpine
COPY ./target/crud-1.0.jar app.jar
ENTRYPOINT [ "java", "-jar", "app.jar" ]
42 changes: 42 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: '3.9'
networks:
weather-network:
driver: bridge
services:
weather-databasePHP:
image: phpmyadmin/phpmyadmin
ports:
- "8085:80"
environment:
PMA_HOST: weather-database
MYSQL_ROOT_PASSWORD: 1936
MYSQL_USER: Admin1
MYSQL_PASSWORD: 1936
networks:
- weather-network
weatherAPI:
container_name: weatherAPI
image: app01
build: .
ports:
- 8080:8080
environment:
- DATABASE_URL=jdbc:mysql://weather-database:3306/pb?useSSL=false&serverTimezone=UTC&useLegacyDateTimeCode=false&allowPublicKeyRetrieval=true
- DATABASE_USERNAME=root
- DATABASE_PASSWORD=1936
# Aqui iria la creacion de un super usuario base
networks:
- weather-network


depends_on:
- weather-database
weather-database:
image: mysql:latest
ports:
- "3307:3306"
environment:
MYSQL_ROOT_PASSWORD: 1936
MYSQL_DATABASE: pb
networks:
- weather-network
21 changes: 19 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,25 @@
<artifactId>bucket4j_jdk8-core</artifactId>
<version>8.3.0</version>
</dependency>


<!--
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
-->

</dependencies>

<build>
Expand Down
28 changes: 28 additions & 0 deletions schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
CREATE TABLE usuario (
id INT PRIMARY KEY AUTO_INCREMENT,
nombre VARCHAR(255) NOT NULL,
nombre_usuario VARCHAR(255) NOT NULL UNIQUE,
email VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL
);
CREATE TABLE rol (
id INT PRIMARY KEY AUTO_INCREMENT,
rol_nombre VARCHAR(255) NOT NULL
);
CREATE TABLE usuario_roles (
usuario_id INT,
rol_id INT,
PRIMARY KEY (usuario_id, rol_id),
FOREIGN KEY (usuario_id) REFERENCES usuario(id),
FOREIGN KEY (rol_id) REFERENCES rol(id)
);
CREATE TABLE consulta (
id_consulta INT PRIMARY KEY AUTO_INCREMENT,
ciudad VARCHAR(255) NOT NULL,
tipo_consulta VARCHAR(255) NOT NULL,
fecha_hora DATETIME NOT NULL,
respuesta TEXT NOT NULL,
usuario_id INT NOT NULL,
FOREIGN KEY (usuario_id) REFERENCES usuario(id)
);
insert into rol (rol_nombre) value ('CLIENT');
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons

private Bucket createNewBucket() {
return Bucket4j.builder()
.addLimit(Bandwidth.simple(3, Duration.ofHours(1)))
.addLimit(Bandwidth.simple(10, Duration.ofHours(1)))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ public class Consulta implements Serializable {
private Usuario usuario;



}
26 changes: 16 additions & 10 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#Conexion a MySQL
spring.datasource.url=jdbc:mysql://localhost:3306/pb?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrival=true&useLegacyDateTimeCode=false
#Conexion a MySQL
spring.datasource.url=jdbc:mysql://weather-database:3306/pb?useSSL=false&serverTimezone=UTC&useLegacyDateTimeCode=false&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=1936

#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

spring.jpa.show-sql = true
Expand All @@ -20,12 +21,17 @@ jwt.expiration = 20000000
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always

# Cloud Gateway Spring
#SpringDoc Configuration

#springdoc.api-docs.path=/api-docs

#springdoc.api-docs.enabled=true

#springdoc.swagger-ui.path=/swagger-ui.html

#springdoc.swagger-ui.enabled=true

#springdoc.paths-to-exclude=/refresh



spring.cloud.gateway.routes[0].id=api_route
spring.cloud.gateway.routes[0].uri=http://localhost:8080
spring.cloud.gateway.routes[0].predicates[0]=Path=/api/**
spring.cloud.gateway.routes[0].filters[0]=name=RequestRateLimiter
spring.cloud.gateway.routes[0].filters[0].args.redis-rate-limiter.replenishRate=10
spring.cloud.gateway.routes[0].filters[0].args.redis-rate-limiter.burstCapacity=20
spring.cloud.gateway.routes[0].filters[0].args.key-resolver=#{@userKeyResolver}