source: src/main/java/com/example/skychasemk/controller/ApplicationUserController.java@ 3d60932

Last change on this file since 3d60932 was 57e58a3, checked in by ste08 <sjovanoska@…>, 4 months ago

Initial commit

  • Property mode set to 100644
File size: 898 bytes
Line 
1package com.example.skychasemk.controller;
2
3import com.example.skychasemk.dto.ApplicationUserDTO;
4import com.example.skychasemk.model.ApplicationUser;
5import com.example.skychasemk.services.ApplicationUserService;
6import jakarta.validation.Valid;
7import org.springframework.beans.factory.annotation.Autowired;
8import org.springframework.http.ResponseEntity;
9import org.springframework.web.bind.annotation.*;
10
11@RestController
12@RequestMapping("/api/user")
13@CrossOrigin(origins = "http://localhost:5173") // Allow frontend access
14public class ApplicationUserController {
15
16 @Autowired
17 private ApplicationUserService userService;
18
19 @PostMapping("/signup")
20 public ResponseEntity<String> registerUser(@Valid @RequestBody ApplicationUserDTO userDTO) {
21 ApplicationUser savedUser = userService.registerUser(userDTO);
22 return ResponseEntity.ok("User saved successfully");
23 }
24
25}
Note: See TracBrowser for help on using the repository browser.