Skip to content

Commit ab8dd5a

Browse files
committed
Merge branch 'develop'
2 parents a940a8c + b3407e4 commit ab8dd5a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2418
-215
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ hs_err_pid*
2424

2525
# own team
2626
.DS_Store
27+
28+
# Examples
29+
pruebas/

backend/api_ADMIN.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
ADMIN:
2+
3+
Users(/api/users/admin(
4+
GET
5+
GET idUser
6+
PUT idUser
7+
DELETE idUser
8+
9+
Categories(/api/categories/admin)
10+
GET
11+
GET idCategory --> Category
12+
GET idCategory image
13+
POST
14+
POST idCategory image
15+
PUT idCategory
16+
DELETE idCategory
17+
DELETE idCategory image
18+
19+
Report(/api/reports/admin)
20+
GET
21+
GET idReport --> Report
22+
PUT idReport
23+
DELETE idReport
24+
25+
Favorites(/api/favorites/admin)
26+
GET
27+
GET idUser --> Lista<Articulo>
28+
GET idUser idArticle --> Favorito
29+
POST idUser idArticulo
30+
DELETE idUser idArticulo

backend/api_ALL.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
ALL
2+
3+
Login(/api/auth)
4+
POST /login
5+
6+
Article(/api/articles)
7+
GET
8+
GET idArticle
9+
10+
Report(/api/reports)
11+
POST
12+
13+
User(/api/users)
14+
POST
15+
16+
Category(/api/categories)
17+
GET
18+
GET idCategory --> List<Article>

backend/api_USERS.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
USER LOGGED:
2+
3+
4+
Login(/api/auth)
5+
POST /refresh
6+
POST /logout
7+
8+
Article(/api/articles)
9+
GET me
10+
GET idArticle
11+
POST
12+
PUT idArticle
13+
DELETE idArticle
14+
15+
16+
Favorites(/api/favorites)
17+
GET
18+
POST idArticle
19+
DELETE idArticle
20+
21+
User(/api/users)
22+
GET
23+
PUT
24+
DELETE

backend/create_heroku_app.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
heroku create $1
4+
5+
heroku addons:create heroku-postgresql --app $1
6+
7+
heroku config:set SERVER_SSL_ENABLED=false --app $1
8+
heroku config:set SPRING_JPA_HIBERNATE_DDL-AUTO=update --app $1

backend/deploy_heroku_app.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
mvn spring-boot:build-image -Dspring-boot.build-image.imageName=registry.heroku.com/$1/web
4+
5+
docker push registry.heroku.com/$1/web
6+
7+
heroku container:release web -a $1
8+
9+
heroku logs --tail -a $1

backend/docker-compose.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: "3.9"
2+
services:
3+
web:
4+
image: codeurjc/wallypop-web-app
5+
ports:
6+
- 8443:8443
7+
environment:
8+
- SPRING_DATASOURCE_URL=jdbc:postgresql://db/wallypop
9+
- SPRING_DATASOURCE_USERNAME=postgres
10+
- SPRING_DATASOURCE_PASSWORD=password
11+
- SPRING_JPA_HIBERNATE_DDL-AUTO=update
12+
db:
13+
image: postgres:14.2
14+
environment:
15+
- POSTGRES_PASSWORD=password
16+
- POSTGRES_DB=wallypop
17+
volumes:
18+
- ./postgresql:/var/lib/postgresql/data

backend/pom.xml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<name>wallypop-1</name>
1616
<description>Demo project for Spring Boot</description>
1717
<properties>
18-
<java.version>17</java.version>
18+
<java.version>11</java.version>
1919
</properties>
2020
<dependencies>
2121
<dependency>
@@ -30,12 +30,6 @@
3030
<groupId>org.springframework.boot</groupId>
3131
<artifactId>spring-boot-starter-web</artifactId>
3232
</dependency>
33-
34-
<dependency>
35-
<groupId>com.h2database</groupId>
36-
<artifactId>h2</artifactId>
37-
<scope>runtime</scope>
38-
</dependency>
3933
<dependency>
4034
<groupId>org.postgresql</groupId>
4135
<artifactId>postgresql</artifactId>
@@ -54,13 +48,38 @@
5448
<artifactId>javax.mail</artifactId>
5549
<version>1.6.2</version>
5650
</dependency>
51+
<dependency>
52+
<groupId>io.jsonwebtoken</groupId>
53+
<artifactId>jjwt</artifactId>
54+
<version>0.7.0</version>
55+
</dependency>
56+
57+
<dependency>
58+
<groupId>org.springdoc</groupId>
59+
<artifactId>springdoc-openapi-ui</artifactId>
60+
<version>1.5.12</version>
61+
</dependency>
62+
63+
5764
</dependencies>
5865

5966
<build>
6067
<plugins>
6168
<plugin>
6269
<groupId>org.springframework.boot</groupId>
6370
<artifactId>spring-boot-maven-plugin</artifactId>
71+
<configuration>
72+
<image>
73+
<env>
74+
<BPE_OVERRIDE_JAVA_TOOL_OPTIONS>
75+
-Xss256K
76+
-XX:ReservedCodeCacheSize=64M
77+
-XX:MaxMetaspaceSize=100000K
78+
-Xmx64M
79+
</BPE_OVERRIDE_JAVA_TOOL_OPTIONS>
80+
</env>
81+
</image>
82+
</configuration>
6483
</plugin>
6584
</plugins>
6685
</build>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package es.codeurjc.wallypop.configuration;
2+
3+
import com.zaxxer.hikari.HikariConfig;
4+
import com.zaxxer.hikari.HikariDataSource;
5+
import org.slf4j.LoggerFactory;
6+
import org.springframework.beans.factory.annotation.Value;
7+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
8+
import org.springframework.context.annotation.Bean;
9+
import org.springframework.context.annotation.Configuration;
10+
11+
import javax.sql.DataSource;
12+
import java.net.URI;
13+
import java.net.URISyntaxException;
14+
import java.util.logging.Level;
15+
import java.util.logging.Logger;
16+
17+
@Configuration
18+
public class DatabaseConfig {
19+
@Value("${DATABASE_URL:null}")
20+
private String databaseUrl;
21+
@Bean
22+
@ConditionalOnProperty("DATABASE_URL")
23+
public DataSource dataSource() throws URISyntaxException {
24+
HikariConfig config = new HikariConfig();
25+
URI uri = new URI(databaseUrl);
26+
String url = "jdbc:" + new URI("postgresql", null, uri.getHost(), uri.getPort(), uri.getPath(),
27+
uri.getQuery(), uri.getFragment()).toString();
28+
String[] userInfoParts = uri.getUserInfo().split(":");
29+
String username = userInfoParts[0];
30+
String password = userInfoParts[1];
31+
config.setJdbcUrl(url);
32+
config.setUsername(username);
33+
config.setPassword(password);
34+
config.setAutoCommit(false);
35+
return new HikariDataSource(config);
36+
}
37+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package es.codeurjc.wallypop.configuration;
2+
3+
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
4+
import org.springframework.boot.SpringBootConfiguration;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.jdbc.support.DatabaseStartupValidator;
7+
8+
import javax.persistence.EntityManagerFactory;
9+
import javax.sql.DataSource;
10+
import java.util.stream.Stream;
11+
12+
@SpringBootConfiguration
13+
public class DatabaseWaitConfigurator {
14+
@Bean
15+
public DatabaseStartupValidator databaseStartupValidator(DataSource dataSource) {
16+
DatabaseStartupValidator dsv = new DatabaseStartupValidator();
17+
dsv.setDataSource(dataSource);
18+
// Configuration delay and timeout
19+
dsv.setInterval(5);
20+
dsv.setTimeout(120);
21+
return dsv;
22+
}
23+
@Bean
24+
public static BeanFactoryPostProcessor dependsOnPostProcessor() {
25+
return bf ->
26+
{
27+
// Let beans that need the database depend on the DatabaseStartupValidator
28+
// like the JPA EntityManagerFactory
29+
String[] jpa = bf.getBeanNamesForType(EntityManagerFactory.class);
30+
Stream.of(jpa)
31+
.map(bf::getBeanDefinition)
32+
.forEach(it -> it.setDependsOn("databaseStartupValidator"));
33+
};
34+
}
35+
}

0 commit comments

Comments
 (0)