Skip to content

Commit

Permalink
feat: add cross origin for port 3000 (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
HunorTotBagi authored Sep 17, 2024
1 parent bc935d1 commit b1c63f0
Show file tree
Hide file tree
Showing 17 changed files with 76 additions and 643 deletions.
5 changes: 4 additions & 1 deletion bin/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ build/
!**/src/test/**/build/

### VS Code ###
.vscode/
.vscode/

### Ignore logs files recursively ###
logs/
4 changes: 4 additions & 0 deletions bin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ This is a backend system for an electronic diary. The system includes functional

- Implement a logger to track system events and errors
- Provide an endpoint to download the log file

### Swagger

- Swagger for generating all endpoints implemented
672 changes: 30 additions & 642 deletions bin/logs/spring-boot-logging.log

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions bin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,24 @@
<artifactId>spring-boot-starter-security</artifactId>
<version>3.3.1</version>
</dependency>

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

<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.6.0</version>
</dependency>

<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-core</artifactId>
<version>2.2.22</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -18,6 +19,7 @@

@RestController
@RequestMapping(path = "/api/v1/classes")
@CrossOrigin(origins = "http://localhost:3000")
public class ClassController {
@Autowired
protected ClassService classService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.electric_diary.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -11,6 +12,7 @@

@RestController
@RequestMapping(path = "/api/v1/emails")
@CrossOrigin(origins = "http://localhost:3000")
public class EmailController {
@Autowired
private EmailService emailService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -21,6 +22,7 @@

@RestController
@RequestMapping(path = "/api/v1/grades")
@CrossOrigin(origins = "http://localhost:3000")
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class GradeController {
@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -13,6 +14,7 @@

@RestController
@RequestMapping(path = "/api/v1/logs")
@CrossOrigin(origins = "http://localhost:3000")
public class LogController {
@Secured("ROLE_ADMIN")
@GetMapping("/download")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -21,6 +22,7 @@

@RestController
@RequestMapping(path = "/api/v1/parents")
@CrossOrigin(origins = "http://localhost:3000")
public class ParentController {
@Autowired
protected ParentService parentService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -18,6 +19,7 @@

@RestController
@RequestMapping(path = "/api/v1/roles")
@CrossOrigin(origins = "http://localhost:3000")
public class RoleController {
@Autowired
protected RoleService roleService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -23,6 +24,7 @@

@RestController
@RequestMapping(path = "/api/v1/students")
@CrossOrigin(origins = "http://localhost:3000")
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class StudentController {
@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -18,6 +19,7 @@

@RestController
@RequestMapping(path = "/api/v1/subjects")
@CrossOrigin(origins = "http://localhost:3000")
public class SubjectController {
@Autowired
protected SubjectService subjectService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -20,6 +21,7 @@

@RestController
@RequestMapping(path = "/api/v1/teachers")
@CrossOrigin(origins = "http://localhost:3000")
public class TeacherController {
@Autowired
protected TeacherService teacherService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -20,6 +21,7 @@

@RestController
@RequestMapping(path = "/api/v1/users")
@CrossOrigin(origins = "http://localhost:3000")
public class UserController {
@Autowired
protected UserService userService;
Expand Down

0 comments on commit b1c63f0

Please sign in to comment.