-
Notifications
You must be signed in to change notification settings - Fork 17
/
userRoutes.ts
52 lines (50 loc) · 1.2 KB
/
userRoutes.ts
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
import type { Routes } from '../../routes.js'
import {
deleteUser,
getUser,
patchUpdateUser,
postCreateUser,
} from '../controllers/UserController.js'
import {
CREATE_USER_BODY_SCHEMA,
DELETE_USER_PARAMS_SCHEMA,
GET_USER_PARAMS_SCHEMA,
UPDATE_USER_BODY_SCHEMA,
UPDATE_USER_PARAMS_SCHEMA,
} from '../schemas/userSchemas.js'
export const getUserRoutes = (): {
routes: Routes
} => {
return {
routes: [
{
method: 'POST',
url: '/users',
handler: postCreateUser,
schema: { body: CREATE_USER_BODY_SCHEMA, describe: 'Create user' },
},
{
method: 'GET',
url: `/users/:userId`,
handler: getUser,
schema: { params: GET_USER_PARAMS_SCHEMA, describe: 'Get user' },
},
{
method: 'DELETE',
url: `/users/:userId`,
handler: deleteUser,
schema: { params: DELETE_USER_PARAMS_SCHEMA, describe: 'Delete user' },
},
{
method: 'PATCH',
url: `/users/:userId`,
handler: patchUpdateUser,
schema: {
params: UPDATE_USER_PARAMS_SCHEMA,
body: UPDATE_USER_BODY_SCHEMA,
describe: 'Update user',
},
},
],
}
}