Commit 3335d62c authored by Sumaiyya Burney's avatar Sumaiyya Burney

Fixes properties and adds CORS

parent 9353e892
...@@ -6,23 +6,19 @@ import com.nisum.ascend.inventory.model.Product; ...@@ -6,23 +6,19 @@ import com.nisum.ascend.inventory.model.Product;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.ascend.inventory.service.ProductService; import com.nisum.ascend.inventory.service.ProductService;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.function.server.ServerResponse; import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import com.nisum.ascend.inventory.service.ProductService; import com.nisum.ascend.inventory.service.ProductService;
@CrossOrigin(origins = "*")
@RestController @RestController
@RequestMapping("/api/products") @RequestMapping("/api/products")
public class ProductController { public class ProductController {
...@@ -40,7 +36,7 @@ public class ProductController { ...@@ -40,7 +36,7 @@ public class ProductController {
public ResponseEntity<Flux<ProductDto>> getAllProducts() { public ResponseEntity<Flux<ProductDto>> getAllProducts() {
return ResponseEntity.ok(productService.findAllProducts()); return ResponseEntity.ok(productService.findAllProducts());
} }
}
@PostMapping("") @PostMapping("")
public Mono<ProductDto> postProduct(@RequestBody Product product) { public Mono<ProductDto> postProduct(@RequestBody Product product) {
......
...@@ -3,4 +3,4 @@ spring.config.import=classpath:secret.properties ...@@ -3,4 +3,4 @@ spring.config.import=classpath:secret.properties
server.port=8080 server.port=8080
spring.data.mongodb.uri=mongodb+srv://admin:${db.password}@inventory-promotions.d4nfz.mongodb\ spring.data.mongodb.uri=mongodb+srv://admin:${db.password}@inventory-promotions.d4nfz.mongodb\
.net/${spring.data.mongodb.database}?retryWrites=true&w=majority .net/${spring.data.mongodb.database}?retryWrites=true&w=majority
spring.data.mongodb.database=test spring.data.mongodb.database=products-promotions-DB
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment