@@ -3,7 +3,141 @@ import { registerUser, loginUser } from '../controllers/user-controller';
33
44const router = Router ( ) ;
55
6+ /**
7+ * @swagger
8+ * tags:
9+ * name: Authentication
10+ * description: API for user authentication
11+ */
12+
13+ /**
14+ * @swagger
15+ * /auth/register:
16+ * post:
17+ * summary: Register a new user
18+ * tags: [Authentication]
19+ * requestBody:
20+ * required: true
21+ * content:
22+ * application/json:
23+ * schema:
24+ * type: object
25+ * required:
26+ * - name
27+ * - email
28+ * - password
29+ * properties:
30+ * name:
31+ * type: string
32+ * example: Full Name
33+ * email:
34+ * type: string
35+ * format: email
36+ * example: user@example.com
37+ * password:
38+ * type: string
39+ * format: password
40+ * example: password123
41+ * responses:
42+ * 200:
43+ * description: User registered successfully
44+ * content:
45+ * application/json:
46+ * schema:
47+ * type: object
48+ * properties:
49+ * success:
50+ * type: boolean
51+ * example: true
52+ * message:
53+ * type: string
54+ * example: User registered successfully
55+ * data:
56+ * type: object
57+ * properties:
58+ * id:
59+ * type: string
60+ * example: "123e4567-e89b-12d3-a456-426614174000"
61+ * 400:
62+ * description: Bad request (Missing fields or email already registered)
63+ * content:
64+ * application/json:
65+ * examples:
66+ * missing_fields:
67+ * summary: Missing required fields
68+ * value:
69+ * success: false
70+ * message: "Name, email, and password are required"
71+ * email_registered:
72+ * summary: Email already exists
73+ * value:
74+ * success: false
75+ * message: "Email is already registered"
76+ * 500:
77+ * description: Internal server error
78+ */
679router . post ( '/register' , registerUser ) ;
80+
81+ /**
82+ * @swagger
83+ * /auth/login:
84+ * post:
85+ * summary: Login a user
86+ * tags: [Authentication]
87+ * requestBody:
88+ * required: true
89+ * content:
90+ * application/json:
91+ * schema:
92+ * type: object
93+ * required:
94+ * - email
95+ * - password
96+ * properties:
97+ * email:
98+ * type: string
99+ * format: email
100+ * example: user@example.com
101+ * password:
102+ * type: string
103+ * format: password
104+ * example: password123
105+ * responses:
106+ * 200:
107+ * description: Login successful, returns a JWT token
108+ * content:
109+ * application/json:
110+ * schema:
111+ * type: object
112+ * properties:
113+ * success:
114+ * type: boolean
115+ * example: true
116+ * message:
117+ * type: string
118+ * example: Login successful
119+ * data:
120+ * type: object
121+ * properties:
122+ * token:
123+ * type: string
124+ * example: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
125+ * 401:
126+ * description: Unauthorized
127+ * content:
128+ * application/json:
129+ * schema:
130+ * type: object
131+ * properties:
132+ * success:
133+ * type: boolean
134+ * example: false
135+ * message:
136+ * type: string
137+ * example: Unauthorized
138+ * 500:
139+ * description: Internal server error
140+ */
7141router . post ( '/login' , loginUser ) ;
8142
9143export default router ;
0 commit comments