-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuserRoutes.js
More file actions
104 lines (97 loc) · 2.38 KB
/
userRoutes.js
File metadata and controls
104 lines (97 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import express from "express";
import {
getCars,
getUserData,
loginUser,
registerUser,
} from "../controllers/userController.js";
import { protect } from "../middleware/auth.js";
import { loginRateLimiter } from "../middleware/loginRateLimiter.js";
const userRouter = express.Router();
/**
* @openapi
* tags:
* - name: User
* description: Auth i user operacije
*/
/**
* @openapi
* /api/user/register:
* post:
* tags: [User]
* summary: Registracija korisnika
* requestBody:
* required: true
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/RegisterRequest'
* responses:
* 200:
* description: Uspešna registracija
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/AuthResponse'
*/
userRouter.post("/register", registerUser);
/**
* @openapi
* /api/user/login:
* post:
* tags: [User]
* summary: Login korisnika
* requestBody:
* required: true
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/LoginRequest'
* responses:
* 200:
* description: Uspešan login
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/AuthResponse'
*/
userRouter.post("/login", loginRateLimiter, loginUser);
/**
* @openapi
* /api/user/data:
* get:
* tags: [User]
* summary: Podaci o ulogovanom korisniku
* security:
* - bearerAuth: []
* responses:
* 200:
* description: User data
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/ApiResponse'
*/
userRouter.get("/data", protect, getUserData);
/**
* @openapi
* /api/user/cars:
* get:
* tags: [User]
* summary: Lista automobila (user view)
* responses:
* 200:
* description: Lista automobila
* content:
* application/json:
* schema:
* type: object
* properties:
* success: { type: boolean }
* cars:
* type: array
* items:
* $ref: '#/components/schemas/Car'
*/
userRouter.get("/cars", getCars);
export default userRouter;