/
index.ts
130 lines (113 loc) · 2.75 KB
/
index.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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import { app } from "@azure/functions";
import { getUsers, getUserById, postUsers } from "./functions/users";
import { getPaymentById, getPayments, postPayment } from "./functions/payments";
import { getReservationById, getReservations, patchReservationById } from "./functions/reservations";
import { getFavorites, postFavorites, deleteFavorite } from "./functions/favorites";
import { getListingById, getListings } from "./functions/listings";
import { openApi } from "./functions/openapi";
import { postCheckout } from "./functions/checkout";
// This route is used by nightly builds as a health check
app.get("get-root", {
route: "",
authLevel: "anonymous",
handler: async () => {
return {
status: 200,
body: "Welcome to Contoso Real Estate API",
};
}
});
//#region User Function
app.get("get-users", {
route: "users",
authLevel: "anonymous",
handler: getUsers,
});
app.get("get-users-by-id", {
route: "users/{id}",
authLevel: "anonymous",
handler: getUserById,
});
app.post("post-users", {
route: "users",
authLevel: "anonymous",
handler: postUsers,
});
//#endregion
//#region Payment Function
app.get("get-payments-by-id", {
route: "payments/{id}",
authLevel: "anonymous",
handler: getPaymentById,
});
app.get("get-payments", {
route: "payments",
authLevel: "anonymous",
handler: getPayments,
});
app.post("post-payment", {
route: "payments",
authLevel: "anonymous",
handler: postPayment,
});
//#endregion
//#region Reservation Function
app.get("get-reservations-by-id", {
route: "reservations/{id}",
authLevel: "anonymous",
handler: getReservationById,
});
app.get("get-reservations", {
route: "reservations",
authLevel: "anonymous",
handler: getReservations,
});
app.patch("patch-reservations-by-id", {
route: "reservations/{id}",
authLevel: "anonymous",
handler: patchReservationById,
});
//#endregion
//#region Favorite Function
app.get("get-favorites", {
route: "favorites",
authLevel: "anonymous",
handler: getFavorites,
});
app.post("post-favorites", {
route: "favorites",
authLevel: "anonymous",
handler: postFavorites,
});
app.deleteRequest("delete-favorites", {
route: "favorites",
authLevel: "anonymous",
handler: deleteFavorite,
});
//#endregion
//#region Listing Function
app.get("get-listings-by-id", {
route: "listings/{id}",
authLevel: "anonymous",
handler: getListingById,
});
app.get("get-listings", {
route: "listings",
authLevel: "anonymous",
handler: getListings,
});
//#endregion
//#region OpenApi Function
app.get("get-openapi", {
route: "{filename?}",
authLevel: "anonymous",
handler: openApi,
});
//#endregion
//#region Checkout Function
app.post("post-checkout", {
route: "checkout",
authLevel: "anonymous",
handler: postCheckout,
});
//#endregion